diff --git a/lib/language.js b/lib/language.js index 1966f0e4ec0..951ddb7c07d 100644 --- a/lib/language.js +++ b/lib/language.js @@ -30,7 +30,7 @@ function init(fs) { , { code: 'nb', file: 'nb_NO', language: 'Norsk (Bokmål)', speechCode: 'no-NO' } , { code: 'nl', file: 'nl_NL', language: 'Nederlands', speechCode: 'nl-NL' } , { code: 'pl', file: 'pl_PL', language: 'Polski', speechCode: 'pl-PL' } - , { code: 'pt', file: 'pr_BR', language: 'Português (Brasil)', speechCode: 'pt-BR' } + , { code: 'pt', file: 'pt_BR', language: 'Português (Brasil)', speechCode: 'pt-BR' } , { code: 'ro', file: 'ro_RO', language: 'Română', speechCode: 'ro-RO' } , { code: 'ru', file: 'ru_RU', language: 'Русский', speechCode: 'ru-RU' } , { code: 'sk', file: 'sl_SL', language: 'Slovenčina', speechCode: 'sk-SK' } @@ -113,8 +113,10 @@ function init(fs) { } // this is a server only call and needs fs by reference as the class is also used in the client - language.loadLocalization = function loadLocalization(fs) { - const l = fs.readFileSync('./translations/' + this.getFilename(this.lang)); + language.loadLocalization = function loadLocalization(fs, path) { + let filename = './translations/' + this.getFilename(this.lang); + if (path) filename = path.resolve(__dirname, filename); + const l = fs.readFileSync(filename); this.offerTranslations(JSON.parse(l)); } @@ -128,6 +130,14 @@ function init(fs) { return language(); }; + language.get = function get(lang) { + var r; + language.languages.forEach(function (l) { + if (l.code === lang) r = l; + }); + return r; + } + // if run on server and we get a filesystem handle, load english by default if (fs) { language.set('en');