mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-05-17 08:10:59 -04:00
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:
parent
0e82f99515
commit
8ae98d703f
15 changed files with 312 additions and 229 deletions
src/lib
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue