2017-04-04 06:32:46 +00:00
|
|
|
/*
|
|
|
|
* vim: ts=4:sw=4:expandtab
|
|
|
|
*/
|
|
|
|
;(function() {
|
|
|
|
'use strict';
|
2017-05-15 21:48:19 +00:00
|
|
|
|
|
|
|
// preload.js loads this, pulling it from main.js (where it was loaded from disk)
|
|
|
|
var messages = window.config.localeMessages;
|
|
|
|
var locale = window.config.locale;
|
|
|
|
|
2017-04-04 06:32:46 +00:00
|
|
|
window.i18n = function (message, substitutions) {
|
2017-05-15 21:48:19 +00:00
|
|
|
if (!messages[message]) {
|
2017-04-12 23:27:10 +00:00
|
|
|
return;
|
|
|
|
}
|
2017-05-15 21:48:19 +00:00
|
|
|
var s = messages[message].message;
|
2017-04-04 06:32:46 +00:00
|
|
|
if (substitutions instanceof Array) {
|
|
|
|
substitutions.forEach(function(sub) {
|
|
|
|
s = s.replace(/\$.+?\$/, sub);
|
|
|
|
});
|
|
|
|
} else if (substitutions) {
|
|
|
|
s = s.replace(/\$.+?\$/, substitutions);
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
};
|
|
|
|
|
|
|
|
i18n.getLocale = function() {
|
2017-05-15 21:48:19 +00:00
|
|
|
return locale;
|
2017-04-04 06:32:46 +00:00
|
|
|
};
|
|
|
|
})();
|