mapswipe/website-old

Translate various dynamic strings (eg. map legend)

laurentS opened this issue · 0 comments

@jhenshall Here are a couple of ideas we could use for things like the legend on the map:

  • Create one version of the script per language, the same way we do for the page content. Pros: structure of the build code is ready, just add more pages. Cons: this prevents user browsers from caching the files and we end up with N copies of almost the same file, which is a bit of a waste. Also, the i18n code probably relies on html tags to work, so it may not actually work in the js content.
  • Have the code load the translated strings from a specific translations file. Efficient, but you need to figure out the deployment logic to generate that translation file, and ideally limit it to the useful content, to avoid having everything loaded twice in the browser.
  • Hard code the strings in a hidden part of the page during the gulp build and then have the dynamic code pull it at run time (with something like a jquery selector). My guess is that this is the easiest, you just add a hidden div at the bottom of the relevant page(s) with an html tag for each string to translate like the rest of the code (so no new deployment logic to invent), then just change the js code above to pull the relevant string from the hidden part of the page.