From b4873738428966dfa4530e03472eb3bed53e8d6e Mon Sep 17 00:00:00 2001 From: Jorge Maroto Date: Tue, 1 Dec 2015 11:51:58 +0100 Subject: [PATCH] Suport base language --- vendor/i18n.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vendor/i18n.js b/vendor/i18n.js index eb0d402..96a1de6 100644 --- a/vendor/i18n.js +++ b/vendor/i18n.js @@ -82,6 +82,9 @@ // Set default locale. This locale will be used when fallback is enabled and // the translation doesn't exist in a particular locale. defaultLocale: "en" + // Set the base language. If it is not null, key will be returned directly when + // use this language in the device. + , baseLanguage: null // Set the current locale to `en`. , locale: "en" // Set the translation key separator. @@ -107,6 +110,10 @@ // the translation doesn't exist in a particular locale. this.defaultLocale = DEFAULT_OPTIONS.defaultLocale; + // Set the base language. If it is not null, key will be returned directly when + // use this language in the device. + this.baseLanguage = DEFAULT_OPTIONS.baseLanguage; + // Set the current locale to `en`. this.locale = DEFAULT_OPTIONS.locale; @@ -136,6 +143,9 @@ if (typeof(this.defaultLocale) === "undefined" && this.defaultLocale !== null) this.defaultLocale = DEFAULT_OPTIONS.defaultLocale; + if (typeof(this.baseLanguage) === "undefined" && this.baseLanguage !== null) + this.baseLanguage = DEFAULT_OPTIONS.baseLanguage; + if (typeof(this.locale) === "undefined" && this.locale !== null) this.locale = DEFAULT_OPTIONS.locale; @@ -280,6 +290,12 @@ while (locales.length) { locale = locales.shift(); + + if (this.baseLanguage !== null && locale == this.baseLanguage) { + console.log(`Devolviendo inglés: ${scope}`) + return scope; + } + scopes = scope.split(this.defaultSeparator); translations = this.translations[locale];