Opened 11 years ago

Closed 11 years ago

#1919 closed defect (fixed)

Rails translations that interact with JavaScript enforce word order

Reported by: avar Owned by: Tom Hughes
Priority: major Milestone:
Component: website Version:
Keywords: i18n Cc:


Some of the translations in .rjs files in rails_port/app/views/browse/ use string concat to glue together translations. This will make hard or impossible to translate in some languages:

ack --nocolor --nogroup  'I18n.*\+' *rjs
    p.appendChild(document.createTextNode("#{I18n.t('browse.start_rjs.loaded_an_area')} " + browseFeatureList.length + " #{I18n.t('browse.start_rjs.browsers')}"));
      setStatus("#{I18n.t('browse.start_rjs.unable_to_load')} " + size + " #{I18n.t('browse.start_rjs.must_be_smaller')}");
    heading.appendChild(document.createTextNode("#{I18n.t('browse.start_rjs.history_for')} " + featureName(this.feature)));
      item.appendChild(document.createTextNode("#{I18n.t('browse.start_rjs.edited_by')} " + user + " #{I18n.t('browse.start_rjs.at_timestamp')} " + timestamp));

The sanest way to do this is probably something like e.g. this:

p.appendChild(document.createTextNode(i18n_hack("#{I18n.t('browse.start_rjs.loaded_an_area')}", { size: browseFeatureList.length })))

Where i18n_hack is a JavaScript? function that takes a string and a hash and replaces all occurrences of "{{size}}" in the string with the appropriate hash key.

My JavaScript?-fu isn't sufficient to write that function in a way that won't break on some random browser:)

Change History (1)

comment:1 Changed 11 years ago by avar

Resolution: fixed
Status: newclosed

I've fixed all of those with my javascript-fu. I'll file new bugs for any remaining issues.

Note: See TracTickets for help on using tickets.