Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations do not load properly when launching the minified version #16

Closed
samreid opened this issue May 1, 2013 · 9 comments
Closed
Assignees

Comments

@samreid
Copy link
Member

samreid commented May 1, 2013

After minification with grunt, the translation files can no longer be loaded. The error is:

Uncaught Error: undefined missing ../nls/fr/ohms-law-strings ohms-law-debug.js:296
main ohms-law-debug.js:296
req ohms-law-debug.js:358
(anonymous function) ohms-law-debug.js:145
(anonymous function) ohms-law-debug.js:534
main ohms-law-debug.js:300
...

I've assigned this to myself and will work on it shortly.

@ghost ghost assigned samreid May 1, 2013
@samreid
Copy link
Member Author

samreid commented May 1, 2013

There are 2 bugs causing this issue. One is that the path is loaded incorrectly for the i18n plugin. The other bug is that not all translations are being bundled into the minified file. The former problem has already been fixed in master of our fork: https://github.com/phetsims/i18n but needs to be moved here.

@samreid
Copy link
Member Author

samreid commented May 1, 2013

We haven't yet decided how to deliver translated sims to customers--we would eventually like a download to not have to contain all translations (to decrease bandwidth requirements) but our short term solution is to provide all of the i18n files and select from amongst them using a query parameter. The problem is that only the i18n file corresponding to the locale specified in the config.js is being combined into the minified file. There is an outstanding request on the i18n plugin site asking for that feature: requirejs/i18n#2 and @jrburke said he may add support for that feature after requirejs 2.0 is delivered: https://groups.google.com/forum/?fromgroups=#!topic/requirejs/0N8S7TJheLU

As a short term solution, I am planning to write a utility that will generate a list of the languages to be included in the minified file. This will increase maintenance costs, since there will now be 3 steps to adding a language:

  1. Add the language file
  2. Update the root file to indicate the presence of the new file in its list of locale:true items
  3. Update the string loader file to ensure the file must be included in the minified file

samreid added a commit that referenced this issue May 1, 2013
@samreid
Copy link
Member Author

samreid commented May 1, 2013

I think I have addressed all of the problems causing the failure in this ticket. Reassigning to @jbphet for review, and to discuss applying this solution to https://github.com/phetsims/resistance-in-a-wire and https://github.com/phetsims/example-sim

@ghost ghost assigned jbphet May 1, 2013
@samreid
Copy link
Member Author

samreid commented May 1, 2013

By the way, my script for generating the require statements is available in our svn repo at this location:
trunk\simulations-html\build-tools\src\ListLocalesToInclude.java

@jbphet
Copy link
Contributor

jbphet commented May 7, 2013

I tested this on a number of platforms - Windows + Chome, Windows + IE9, iPad2, and Nexus 7. I tested roughly three languages on each. It all worked fine. I looked briefly at the code, and am okay with the approach. Assigning to @pixelzoom for review and potential closure.

@pixelzoom
Copy link
Contributor

This ticket doesn't contain enough info for me to evaluate.
Please summarize:
(1) What was done
(2) What needs to be added to JS sims for i18n support
(3) The process for converting Java strings.properties to JS

@ghost ghost assigned samreid May 9, 2013
@samreid
Copy link
Member Author

samreid commented May 10, 2013

I used the new Gruntfile provided by @pixelzoom which includes almond and tested i18n on the following systems:

1. Windows 8/IE10
2. Windows 8/Firefox
3. Windows 8/Chrome
4. Windows 7/IE9
5. iOS/Safari
6. OSX/Safari
7. OSX/Chrome
8. OSX/Firefox
9. Nexus 7/Chrome

Worked great on all of them!

In an upcoming ticket comment, I'll summarize what was done, how to add i18n support and the process for converting java strings.

@samreid
Copy link
Member Author

samreid commented May 10, 2013

Comments 1-4 describe the new work that was done for this ticket to get i18n working in the minified code. To summarize, we have reverted back to the unforked i18n and instead run 'update-locale.js' after our requirejs code is loaded but before it is run.

To convert Strings from Java, run:
svn\trunk\simulations-html\build-tools\src\PropertiesToRequireJSI18n.java

To convert Strings from Flash, run:
svn\trunk\simulations-html\build-tools\src\XMLToRequireJSI18n.java

To populate the Strings loader javascript file, use and copy/paste the output to the javascript sim.
svn\trunk\simulations-html\build-tools\src\ListLocalesToInclude.java

For an example, please see Ohm's Law or Forces and Motion Basics.

@samreid
Copy link
Member Author

samreid commented Oct 9, 2013

We have written our own string plugin, and translations can load during development or production. We still need to build translated files for other languages, but that will be another ticket. Closing this one.

@samreid samreid closed this as completed Oct 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants