mirror of
https://github.com/status-im/react-native-i18n.git
synced 2025-02-01 23:05:16 +00:00
Suport base language
This commit is contained in:
parent
c1336d331f
commit
b487373842
16
vendor/i18n.js
vendored
16
vendor/i18n.js
vendored
@ -82,6 +82,9 @@
|
|||||||
// Set default locale. This locale will be used when fallback is enabled and
|
// Set default locale. This locale will be used when fallback is enabled and
|
||||||
// the translation doesn't exist in a particular locale.
|
// the translation doesn't exist in a particular locale.
|
||||||
defaultLocale: "en"
|
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`.
|
// Set the current locale to `en`.
|
||||||
, locale: "en"
|
, locale: "en"
|
||||||
// Set the translation key separator.
|
// Set the translation key separator.
|
||||||
@ -107,6 +110,10 @@
|
|||||||
// the translation doesn't exist in a particular locale.
|
// the translation doesn't exist in a particular locale.
|
||||||
this.defaultLocale = DEFAULT_OPTIONS.defaultLocale;
|
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`.
|
// Set the current locale to `en`.
|
||||||
this.locale = DEFAULT_OPTIONS.locale;
|
this.locale = DEFAULT_OPTIONS.locale;
|
||||||
|
|
||||||
@ -136,6 +143,9 @@
|
|||||||
if (typeof(this.defaultLocale) === "undefined" && this.defaultLocale !== null)
|
if (typeof(this.defaultLocale) === "undefined" && this.defaultLocale !== null)
|
||||||
this.defaultLocale = DEFAULT_OPTIONS.defaultLocale;
|
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)
|
if (typeof(this.locale) === "undefined" && this.locale !== null)
|
||||||
this.locale = DEFAULT_OPTIONS.locale;
|
this.locale = DEFAULT_OPTIONS.locale;
|
||||||
|
|
||||||
@ -280,6 +290,12 @@
|
|||||||
|
|
||||||
while (locales.length) {
|
while (locales.length) {
|
||||||
locale = locales.shift();
|
locale = locales.shift();
|
||||||
|
|
||||||
|
if (this.baseLanguage !== null && locale == this.baseLanguage) {
|
||||||
|
console.log(`Devolviendo inglés: ${scope}`)
|
||||||
|
return scope;
|
||||||
|
}
|
||||||
|
|
||||||
scopes = scope.split(this.defaultSeparator);
|
scopes = scope.split(this.defaultSeparator);
|
||||||
translations = this.translations[locale];
|
translations = this.translations[locale];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user