Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Rails translations that interact with JavaScript enforce word order #1919

Closed
openstreetmap-trac opened this issue Jul 23, 2021 · 1 comment
Closed

Comments

@openstreetmap-trac
Copy link

Reporter: avarab[at]gmail.com
[Submitted to the original trac issue database at 8.55pm, Thursday, 4th June 2009]

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:)

@openstreetmap-trac
Copy link
Author

Author: avarab[at]gmail.com
[Added to the original trac issue at 6.42pm, Saturday, 20th June 2009]

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant