discourse/discourse — pull request #278 by kubabrecka (2013-02-27 08:46:49+00:00)
Title: first attempt to serve correct localized js files as rails pipeline assets

Hi, this is a first attempt to implement locale switching into Discourse. I removed translations.js.erb (from both discourse/ and admin/) and instead created individual en.js.erb, fr.js.erb, etc. files in app/assets/javascripts/locales.

Now, it's possible to change locale simply by `config.i18n.locale = :fr` in config/application.rb.

Note that setting the locale on the JS side is a little bit tricky. I loaded the correct strings js file at the very beginning of application.html.erb, but you can't set `I18n.locale = xxx`, because the i18n library is not yet initialized and it will be overriden back to 'en'. So I hacked this place to save the current locale to a `window.currentLocale` variable and at the right place (right after I18n is initialized), it is loaded into `I18n.locale`. Also note that you can't simply set the locale *after* all the scripts, because some of them needs l10n strings already during their init (doing it will bring subtle bugs, e.g. some strings will be missing).

Comments and changes are welcome.