Make localizations view-based

1. Load locale strings into `window._messages` in a separate file added to `template.html`, which contains view-specific and general strings
2. Update build-locales to compile separate files
This commit is contained in:
Matthew Taylor 2016-01-06 14:09:32 -05:00
parent 0e82f99515
commit 8ae98d703f
15 changed files with 312 additions and 229 deletions
src/lib

View file

@ -5,8 +5,16 @@ var IntlProvider = ReactIntl.IntlProvider;
var render = function (jsx, element) {
// Get locale and messages from global namespace (see "init.js")
var locale = window._locale;
var messages = window._translations[locale];
var locale = window._locale || 'en';
if (typeof window._messages[locale] === 'undefined') {
// Fall back on the split
locale = locale.split('-')[0];
}
if (typeof window._messages[locale] === 'undefined') {
// Language appears to not be supported fall back to 'en'
locale = 'en';
}
var messages = window._messages[locale];
// Render component
var component = ReactDOM.render(