xtuple/xtuple — pull request #910 by shackbarth (2013-10-03 18:50:41+00:00)
Title: issue #18917: allow translations

This is a workable implementation of the translatability of the app, although it lacks many of the bells and whistles that we might ultimately build in.

There are some basic changes to the framework that everyone should be aware of:
-You no longer need an extensions/debug.js file
-There is a new "unregister" option for an extension in the build tool

The strings.js files have a new convention. It is no longer appropriate to include them in the package.js tree. It is also important to have an exports command at the bottom of them, as you can see in all of the newly updated files. These files will get built into the database during the build tool, and will get served from the database, in whatever supported language matches the locale of the user. The changes should be seamless for users and devs.

I've also written command-line tools to facilitate translation:
./scripts/export_database.js will dump the English strings into a file to be translated. If you supply a Google Translate API key then it will automatically translate them all into the file. It takes Google about a minute to translate our 1200 strings into a single foreign language, and costs about $0.60, for which I am not intending to file an expense report. https://developers.google.com/translate/v2/using_rest
./scripts/import_database.js will load the dictionary file back into the database for the requested language.

The workflow then is to export a file from the English strings in the database (with Google taking a first crack), then update the file by hand if you want to improve upon Google, then import the file into the database, or share the dictionary file with your friends. I have not implemented a mechanism to centrally manage these files.

If you want to see this in action,
-grab my Spanish-language translation here:
https://raw.github.com/shackbarth/how-to/master/dropbox/es_MX_dictionary.js
-use import_dictionary.js to put this data in your database
-change your user locale to "Spanish"
-refresh the app