mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2025-05-16 15:51:19 -04:00
Migrate to using a loader method
This moves all locale/translation building to a dependency, `scratch-www-intl-loader`, as well as tests associated with it. Also gets rid of the `make translations` step.
This commit is contained in:
parent
d5ffd9fcc0
commit
214430b0c4
24 changed files with 88 additions and 399 deletions
src/lib
|
@ -3,22 +3,21 @@ var ReactDOM = require('react-dom');
|
|||
var ReactIntl = require('./intl.jsx');
|
||||
var IntlProvider = ReactIntl.IntlProvider;
|
||||
|
||||
var render = function (jsx, element) {
|
||||
var render = function (jsx, element, messages) {
|
||||
// Get locale and messages from global namespace (see "init.js")
|
||||
var locale = window._locale || 'en';
|
||||
if (typeof window._messages[locale] === 'undefined') {
|
||||
if (typeof messages[locale] === 'undefined') {
|
||||
// Fall back on the split
|
||||
locale = locale.split('-')[0];
|
||||
}
|
||||
if (typeof window._messages[locale] === 'undefined') {
|
||||
if (typeof 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(
|
||||
<IntlProvider locale={locale} messages={messages}>
|
||||
<IntlProvider locale={locale} messages={messages[locale]}>
|
||||
{jsx}
|
||||
</IntlProvider>,
|
||||
element
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue