mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-28 18:15:37 -05:00
Adding requires for Intl.js locale-data
This commit is contained in:
parent
d984dba0a6
commit
c194ca8c2b
3 changed files with 11 additions and 4 deletions
|
@ -24,7 +24,8 @@
|
||||||
"WebKitCSSMatrix": true,
|
"WebKitCSSMatrix": true,
|
||||||
"Settings": true,
|
"Settings": true,
|
||||||
"MediaLib": true,
|
"MediaLib": true,
|
||||||
"webkitAudioContext": true
|
"webkitAudioContext": true,
|
||||||
|
"require": true
|
||||||
},
|
},
|
||||||
"extends": "eslint:recommended"
|
"extends": "eslint:recommended"
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
"esformatter-quotes": "^1.0.3",
|
"esformatter-quotes": "^1.0.3",
|
||||||
"esformatter-semicolons": "^1.1.2",
|
"esformatter-semicolons": "^1.1.2",
|
||||||
"eslint": "^1.10.3",
|
"eslint": "^1.10.3",
|
||||||
|
"expose-loader": "^0.7.1",
|
||||||
"strip-sourcemap-loader": "0.0.1",
|
"strip-sourcemap-loader": "0.0.1",
|
||||||
"webpack": "^1.12.11"
|
"webpack": "^1.12.11"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
import Cookie from './Cookie';
|
import Cookie from './Cookie';
|
||||||
import Intl from 'intl';
|
import Intl from 'intl';
|
||||||
import IntlMessageFormat from 'intl-messageformat';
|
|
||||||
|
|
||||||
window.Intl = Intl;
|
window.Intl = Intl;
|
||||||
|
|
||||||
|
require('intl/locale-data/jsonp/en.js');
|
||||||
|
require('intl/locale-data/jsonp/es.js');
|
||||||
|
|
||||||
|
require('expose?IntlMessageFormat!intl-messageformat');
|
||||||
|
require('intl-messageformat/dist/locale-data/en');
|
||||||
|
require('intl-messageformat/dist/locale-data/es');
|
||||||
|
|
||||||
let currentLocale;
|
let currentLocale;
|
||||||
let root = '';
|
let root = '';
|
||||||
let localizationMessages = {};
|
let localizationMessages = {};
|
||||||
|
@ -68,7 +73,7 @@ export default class Localization {
|
||||||
static localize (key, formatting) {
|
static localize (key, formatting) {
|
||||||
var message;
|
var message;
|
||||||
if (key in localizationMessages) {
|
if (key in localizationMessages) {
|
||||||
message = new IntlMessageFormat(localizationMessages[key], currentLocale);
|
message = new window.IntlMessageFormat(localizationMessages[key], currentLocale);
|
||||||
return message.format(formatting);
|
return message.format(formatting);
|
||||||
}
|
}
|
||||||
return 'String missing: ' + key;
|
return 'String missing: ' + key;
|
||||||
|
|
Loading…
Reference in a new issue