@next-core/i18n 1.0.40 → 1.0.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_i18next","_interopRequireDefault","require","_init","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_text","i18n","process","env","NODE_ENV","i18next","default"],"sources":["../../src/index.ts"],"sourcesContent":["import i18next from \"i18next\";\n\nexport const i18n =\n process.env.NODE_ENV === \"test\"\n ? (i18next as unknown as typeof i18next.default)\n : /* istanbul ignore next */ i18next.default;\n\nexport * from \"./init.js\";\nexport * from \"./text.js\";\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,KAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,KAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,KAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,KAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAW,KAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,KAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,KAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AANO,MAAMU,IAAI,GAAAL,OAAA,CAAAK,IAAA,GACfC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,GAC1BC,gBAAO,GACR,0BAA2BA,gBAAO,CAACC,OAAO"}
1
+ {"version":3,"file":"index.js","names":["_i18next","_interopRequireDefault","require","_init","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_text","i18n","process","env","NODE_ENV","i18next","default"],"sources":["../../src/index.ts"],"sourcesContent":["import i18next from \"i18next\";\n\nexport const i18n =\n process.env.NODE_ENV === \"test\"\n ? (i18next as unknown as typeof i18next.default)\n : /* istanbul ignore next */ i18next.default;\n\nexport * from \"./init.js\";\nexport * from \"./text.js\";\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAOA,IAAAC,KAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,KAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,KAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,KAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,KAAA,GAAAd,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAW,KAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAS,KAAA,CAAAT,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,KAAA,CAAAT,GAAA;IAAA;EAAA;AAAA;AANO,MAAMU,IAAI,GAAAL,OAAA,CAAAK,IAAA,GACfC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,GAC1BC,gBAAO,GACR,0BAA2BA,gBAAO,CAACC,OAAO","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","names":["_i18n","require","_i18nextBrowserLanguagedetector","_interopRequireDefault","initialized","initializedNamespaces","Set","initializeI18n","NS","locales","i18n","use","process","env","NODE_ENV","LanguageDetector","default","init","fallbackLng","debug","supportedLngs","nonExplicitSupportedLngs","interpolation","escapeValue","react","useSuspense","compatibilityJSON","resources","has","add","lang","Object","entries","addResourceBundle"],"sources":["../../src/init.ts"],"sourcesContent":["import { i18n } from \"@next-core/i18n\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\n\nlet initialized = false;\nconst initializedNamespaces = new Set<string>();\n\nexport type Locales = Record<string, Record<string, string | undefined>>;\n\nexport function initializeI18n(): void;\nexport function initializeI18n(NS: string, locales: Locales): void;\nexport function initializeI18n(NS?: string, locales?: Locales) {\n if (!initialized) {\n initialized = true;\n i18n\n // learn more: https://github.com/i18next/i18next-xhr-backend\n // .use(Backend)\n // learn more: https://github.com/i18next/i18next-browser-languageDetector\n .use(\n process.env.NODE_ENV === \"test\"\n ? LanguageDetector\n : /* istanbul ignore next */ (\n LanguageDetector as unknown as { default: LanguageDetector }\n ).default\n )\n // for all options read: https://www.i18next.com/overview/configuration-options\n .init({\n fallbackLng: \"zh\",\n debug: process.env.NODE_ENV === \"development\",\n supportedLngs: [\"zh\", \"en\"],\n nonExplicitSupportedLngs: true,\n interpolation: {\n escapeValue: false, // not needed for react as it escapes by default\n },\n react: {\n useSuspense: false,\n },\n compatibilityJSON: \"v3\",\n resources: {},\n });\n }\n\n if (!NS || !locales || initializedNamespaces.has(NS)) {\n return;\n }\n initializedNamespaces.add(NS);\n for (const [lang, resources] of Object.entries(locales)) {\n i18n.addResourceBundle(lang, NS, resources);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,+BAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAIG,WAAW,GAAG,KAAK;AACvB,MAAMC,qBAAqB,GAAG,IAAIC,GAAG,CAAS,CAAC;AAMxC,SAASC,cAAcA,CAACC,EAAW,EAAEC,OAAiB,EAAE;EAC7D,IAAI,CAACL,WAAW,EAAE;IAChBA,WAAW,GAAG,IAAI;IAClBM;IACE;IACA;IACA;IAAA,CACCC,GAAG,CACFC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,GAC3BC,uCAAgB,GAChB,0BACEA,uCAAgB,CAChBC,OACR;IACA;IAAA,CACCC,IAAI,CAAC;MACJC,WAAW,EAAE,IAAI;MACjBC,KAAK,EAAEP,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa;MAC7CM,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;MAC3BC,wBAAwB,EAAE,IAAI;MAC9BC,aAAa,EAAE;QACbC,WAAW,EAAE,KAAK,CAAE;MACtB,CAAC;MACDC,KAAK,EAAE;QACLC,WAAW,EAAE;MACf,CAAC;MACDC,iBAAiB,EAAE,IAAI;MACvBC,SAAS,EAAE,CAAC;IACd,CAAC,CAAC;EACN;EAEA,IAAI,CAACnB,EAAE,IAAI,CAACC,OAAO,IAAIJ,qBAAqB,CAACuB,GAAG,CAACpB,EAAE,CAAC,EAAE;IACpD;EACF;EACAH,qBAAqB,CAACwB,GAAG,CAACrB,EAAE,CAAC;EAC7B,KAAK,MAAM,CAACsB,IAAI,EAAEH,SAAS,CAAC,IAAII,MAAM,CAACC,OAAO,CAACvB,OAAO,CAAC,EAAE;IACvDC,UAAI,CAACuB,iBAAiB,CAACH,IAAI,EAAEtB,EAAE,EAAEmB,SAAS,CAAC;EAC7C;AACF"}
1
+ {"version":3,"file":"init.js","names":["_i18n","require","_i18nextBrowserLanguagedetector","_interopRequireDefault","initialized","initializedNamespaces","Set","initializeI18n","NS","locales","i18n","use","process","env","NODE_ENV","LanguageDetector","default","init","fallbackLng","debug","supportedLngs","nonExplicitSupportedLngs","interpolation","escapeValue","react","useSuspense","compatibilityJSON","resources","has","add","lang","Object","entries","addResourceBundle"],"sources":["../../src/init.ts"],"sourcesContent":["import { i18n } from \"@next-core/i18n\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\n\nlet initialized = false;\nconst initializedNamespaces = new Set<string>();\n\nexport type Locales = Record<string, Record<string, string | undefined>>;\n\nexport function initializeI18n(): void;\nexport function initializeI18n(NS: string, locales: Locales): void;\nexport function initializeI18n(NS?: string, locales?: Locales) {\n if (!initialized) {\n initialized = true;\n i18n\n // learn more: https://github.com/i18next/i18next-xhr-backend\n // .use(Backend)\n // learn more: https://github.com/i18next/i18next-browser-languageDetector\n .use(\n process.env.NODE_ENV === \"test\"\n ? LanguageDetector\n : /* istanbul ignore next */ (\n LanguageDetector as unknown as { default: LanguageDetector }\n ).default\n )\n // for all options read: https://www.i18next.com/overview/configuration-options\n .init({\n fallbackLng: \"zh\",\n debug: process.env.NODE_ENV === \"development\",\n supportedLngs: [\"zh\", \"en\"],\n nonExplicitSupportedLngs: true,\n interpolation: {\n escapeValue: false, // not needed for react as it escapes by default\n },\n react: {\n useSuspense: false,\n },\n compatibilityJSON: \"v3\",\n resources: {},\n });\n }\n\n if (!NS || !locales || initializedNamespaces.has(NS)) {\n return;\n }\n initializedNamespaces.add(NS);\n for (const [lang, resources] of Object.entries(locales)) {\n i18n.addResourceBundle(lang, NS, resources);\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,+BAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAIG,WAAW,GAAG,KAAK;AACvB,MAAMC,qBAAqB,GAAG,IAAIC,GAAG,CAAS,CAAC;AAMxC,SAASC,cAAcA,CAACC,EAAW,EAAEC,OAAiB,EAAE;EAC7D,IAAI,CAACL,WAAW,EAAE;IAChBA,WAAW,GAAG,IAAI;IAClBM;IACE;IACA;IACA;IAAA,CACCC,GAAG,CACFC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,GAC3BC,uCAAgB,GAChB,0BACEA,uCAAgB,CAChBC,OACR;IACA;IAAA,CACCC,IAAI,CAAC;MACJC,WAAW,EAAE,IAAI;MACjBC,KAAK,EAAEP,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa;MAC7CM,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;MAC3BC,wBAAwB,EAAE,IAAI;MAC9BC,aAAa,EAAE;QACbC,WAAW,EAAE,KAAK,CAAE;MACtB,CAAC;MACDC,KAAK,EAAE;QACLC,WAAW,EAAE;MACf,CAAC;MACDC,iBAAiB,EAAE,IAAI;MACvBC,SAAS,EAAE,CAAC;IACd,CAAC,CAAC;EACN;EAEA,IAAI,CAACnB,EAAE,IAAI,CAACC,OAAO,IAAIJ,qBAAqB,CAACuB,GAAG,CAACpB,EAAE,CAAC,EAAE;IACpD;EACF;EACAH,qBAAqB,CAACwB,GAAG,CAACrB,EAAE,CAAC;EAC7B,KAAK,MAAM,CAACsB,IAAI,EAAEH,SAAS,CAAC,IAAII,MAAM,CAACC,OAAO,CAACvB,OAAO,CAAC,EAAE;IACvDC,UAAI,CAACuB,iBAAiB,CAACH,IAAI,EAAEtB,EAAE,EAAEmB,SAAS,CAAC;EAC7C;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","names":["_i18n","require","_reactI18next","initialized","initializeReactI18n","NS","locales","initializeI18n","initReactI18next","init","i18n"],"sources":["../../src/react.ts"],"sourcesContent":["import { i18n, initializeI18n, Locales } from \"@next-core/i18n\";\nimport { initReactI18next, useTranslation } from \"react-i18next\";\n\nlet initialized = false;\n\nexport function initializeReactI18n(): void;\nexport function initializeReactI18n(NS: string, locales: Locales): void;\nexport function initializeReactI18n(NS?: string, locales?: Locales) {\n initializeI18n(NS as string, locales as Locales);\n if (!initialized) {\n initialized = true;\n initReactI18next.init(i18n);\n }\n}\n\nexport { useTranslation };\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAIE,WAAW,GAAG,KAAK;AAIhB,SAASC,mBAAmBA,CAACC,EAAW,EAAEC,OAAiB,EAAE;EAClE,IAAAC,oBAAc,EAACF,EAAE,EAAYC,OAAkB,CAAC;EAChD,IAAI,CAACH,WAAW,EAAE;IAChBA,WAAW,GAAG,IAAI;IAClBK,8BAAgB,CAACC,IAAI,CAACC,UAAI,CAAC;EAC7B;AACF"}
1
+ {"version":3,"file":"react.js","names":["_i18n","require","_reactI18next","initialized","initializeReactI18n","NS","locales","initializeI18n","initReactI18next","init","i18n"],"sources":["../../src/react.ts"],"sourcesContent":["import { i18n, initializeI18n, Locales } from \"@next-core/i18n\";\nimport { initReactI18next, useTranslation } from \"react-i18next\";\n\nlet initialized = false;\n\nexport function initializeReactI18n(): void;\nexport function initializeReactI18n(NS: string, locales: Locales): void;\nexport function initializeReactI18n(NS?: string, locales?: Locales) {\n initializeI18n(NS as string, locales as Locales);\n if (!initialized) {\n initialized = true;\n initReactI18next.init(i18n);\n }\n}\n\nexport { useTranslation };\n"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEA,IAAIE,WAAW,GAAG,KAAK;AAIhB,SAASC,mBAAmBA,CAACC,EAAW,EAAEC,OAAiB,EAAE;EAClE,IAAAC,oBAAc,EAACF,EAAE,EAAYC,OAAkB,CAAC;EAChD,IAAI,CAACH,WAAW,EAAE;IAChBA,WAAW,GAAG,IAAI;IAClBK,8BAAgB,CAACC,IAAI,CAACC,UAAI,CAAC;EAC7B;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","names":["_i18n","require","_general","i18nText","data","_i18n$language","language","i18n","hasOwnProperty","primaryLanguage","split","undefined","prefix","key","Object","keys","startsWith"],"sources":["../../src/text.ts"],"sourcesContent":["import { i18n } from \"@next-core/i18n\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { I18nData } from \"@next-core/types\";\n\nexport function i18nText(\n data: I18nData | null | undefined\n): string | undefined {\n if (!data) {\n return;\n }\n const language = i18n.language ?? \"zh-CN\";\n // First, make a perfect match.\n if (hasOwnProperty(data, language)) {\n return data[language];\n }\n // https://en.wikipedia.org/wiki/IETF_language_tag\n const primaryLanguage = language.split(\"-\")[0];\n if (primaryLanguage !== language) {\n // Then, match the primary language (which omits other subtags).\n // E.g., match `zh` if the current language is `zh-CN`.\n return hasOwnProperty(data, primaryLanguage)\n ? data[primaryLanguage]\n : undefined;\n }\n // At last, match the first key which starts with the primary language,\n // if the current language contains primary subtag only.\n // E.g., match `zh-CN` if the current language is `zh`.\n const prefix = `${primaryLanguage}-`;\n for (const key of Object.keys(data)) {\n if (key.startsWith(prefix)) {\n return data[key];\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAGO,SAASE,QAAQA,CACtBC,IAAiC,EACb;EAAA,IAAAC,cAAA;EACpB,IAAI,CAACD,IAAI,EAAE;IACT;EACF;EACA,MAAME,QAAQ,IAAAD,cAAA,GAAGE,UAAI,CAACD,QAAQ,cAAAD,cAAA,cAAAA,cAAA,GAAI,OAAO;EACzC;EACA,IAAI,IAAAG,uBAAc,EAACJ,IAAI,EAAEE,QAAQ,CAAC,EAAE;IAClC,OAAOF,IAAI,CAACE,QAAQ,CAAC;EACvB;EACA;EACA,MAAMG,eAAe,GAAGH,QAAQ,CAACI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EAC9C,IAAID,eAAe,KAAKH,QAAQ,EAAE;IAChC;IACA;IACA,OAAO,IAAAE,uBAAc,EAACJ,IAAI,EAAEK,eAAe,CAAC,GACxCL,IAAI,CAACK,eAAe,CAAC,GACrBE,SAAS;EACf;EACA;EACA;EACA;EACA,MAAMC,MAAM,GAAI,GAAEH,eAAgB,GAAE;EACpC,KAAK,MAAMI,GAAG,IAAIC,MAAM,CAACC,IAAI,CAACX,IAAI,CAAC,EAAE;IACnC,IAAIS,GAAG,CAACG,UAAU,CAACJ,MAAM,CAAC,EAAE;MAC1B,OAAOR,IAAI,CAACS,GAAG,CAAC;IAClB;EACF;AACF"}
1
+ {"version":3,"file":"text.js","names":["_i18n","require","_general","i18nText","data","_i18n$language","language","i18n","hasOwnProperty","primaryLanguage","split","undefined","prefix","key","Object","keys","startsWith"],"sources":["../../src/text.ts"],"sourcesContent":["import { i18n } from \"@next-core/i18n\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { I18nData } from \"@next-core/types\";\n\nexport function i18nText(\n data: I18nData | null | undefined\n): string | undefined {\n if (!data) {\n return;\n }\n const language = i18n.language ?? \"zh-CN\";\n // First, make a perfect match.\n if (hasOwnProperty(data, language)) {\n return data[language];\n }\n // https://en.wikipedia.org/wiki/IETF_language_tag\n const primaryLanguage = language.split(\"-\")[0];\n if (primaryLanguage !== language) {\n // Then, match the primary language (which omits other subtags).\n // E.g., match `zh` if the current language is `zh-CN`.\n return hasOwnProperty(data, primaryLanguage)\n ? data[primaryLanguage]\n : undefined;\n }\n // At last, match the first key which starts with the primary language,\n // if the current language contains primary subtag only.\n // E.g., match `zh-CN` if the current language is `zh`.\n const prefix = `${primaryLanguage}-`;\n for (const key of Object.keys(data)) {\n if (key.startsWith(prefix)) {\n return data[key];\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAGO,SAASE,QAAQA,CACtBC,IAAiC,EACb;EAAA,IAAAC,cAAA;EACpB,IAAI,CAACD,IAAI,EAAE;IACT;EACF;EACA,MAAME,QAAQ,IAAAD,cAAA,GAAGE,UAAI,CAACD,QAAQ,cAAAD,cAAA,cAAAA,cAAA,GAAI,OAAO;EACzC;EACA,IAAI,IAAAG,uBAAc,EAACJ,IAAI,EAAEE,QAAQ,CAAC,EAAE;IAClC,OAAOF,IAAI,CAACE,QAAQ,CAAC;EACvB;EACA;EACA,MAAMG,eAAe,GAAGH,QAAQ,CAACI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EAC9C,IAAID,eAAe,KAAKH,QAAQ,EAAE;IAChC;IACA;IACA,OAAO,IAAAE,uBAAc,EAACJ,IAAI,EAAEK,eAAe,CAAC,GACxCL,IAAI,CAACK,eAAe,CAAC,GACrBE,SAAS;EACf;EACA;EACA;EACA;EACA,MAAMC,MAAM,GAAI,GAAEH,eAAgB,GAAE;EACpC,KAAK,MAAMI,GAAG,IAAIC,MAAM,CAACC,IAAI,CAACX,IAAI,CAAC,EAAE;IACnC,IAAIS,GAAG,CAACG,UAAU,CAACJ,MAAM,CAAC,EAAE;MAC1B,OAAOR,IAAI,CAACS,GAAG,CAAC;IAClB;EACF;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["i18next","i18n","process","env","NODE_ENV","default"],"sources":["../../src/index.ts"],"sourcesContent":["import i18next from \"i18next\";\n\nexport const i18n =\n process.env.NODE_ENV === \"test\"\n ? (i18next as unknown as typeof i18next.default)\n : /* istanbul ignore next */ i18next.default;\n\nexport * from \"./init.js\";\nexport * from \"./text.js\";\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,SAAS;AAE7B,OAAO,IAAMC,IAAI,GACfC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,GAC1BJ,OAAO,GACR,0BAA2BA,OAAO,CAACK,OAAO;AAEhD,cAAc,WAAW;AACzB,cAAc,WAAW"}
1
+ {"version":3,"file":"index.js","names":["i18next","i18n","process","env","NODE_ENV","default"],"sources":["../../src/index.ts"],"sourcesContent":["import i18next from \"i18next\";\n\nexport const i18n =\n process.env.NODE_ENV === \"test\"\n ? (i18next as unknown as typeof i18next.default)\n : /* istanbul ignore next */ i18next.default;\n\nexport * from \"./init.js\";\nexport * from \"./text.js\";\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,SAAS;AAE7B,OAAO,IAAMC,IAAI,GACfC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,GAC1BJ,OAAO,GACR,0BAA2BA,OAAO,CAACK,OAAO;AAEhD,cAAc,WAAW;AACzB,cAAc,WAAW","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","names":["i18n","LanguageDetector","initialized","initializedNamespaces","Set","initializeI18n","NS","locales","use","process","env","NODE_ENV","default","init","fallbackLng","debug","supportedLngs","nonExplicitSupportedLngs","interpolation","escapeValue","react","useSuspense","compatibilityJSON","resources","has","add","lang","Object","entries","addResourceBundle"],"sources":["../../src/init.ts"],"sourcesContent":["import { i18n } from \"@next-core/i18n\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\n\nlet initialized = false;\nconst initializedNamespaces = new Set<string>();\n\nexport type Locales = Record<string, Record<string, string | undefined>>;\n\nexport function initializeI18n(): void;\nexport function initializeI18n(NS: string, locales: Locales): void;\nexport function initializeI18n(NS?: string, locales?: Locales) {\n if (!initialized) {\n initialized = true;\n i18n\n // learn more: https://github.com/i18next/i18next-xhr-backend\n // .use(Backend)\n // learn more: https://github.com/i18next/i18next-browser-languageDetector\n .use(\n process.env.NODE_ENV === \"test\"\n ? LanguageDetector\n : /* istanbul ignore next */ (\n LanguageDetector as unknown as { default: LanguageDetector }\n ).default\n )\n // for all options read: https://www.i18next.com/overview/configuration-options\n .init({\n fallbackLng: \"zh\",\n debug: process.env.NODE_ENV === \"development\",\n supportedLngs: [\"zh\", \"en\"],\n nonExplicitSupportedLngs: true,\n interpolation: {\n escapeValue: false, // not needed for react as it escapes by default\n },\n react: {\n useSuspense: false,\n },\n compatibilityJSON: \"v3\",\n resources: {},\n });\n }\n\n if (!NS || !locales || initializedNamespaces.has(NS)) {\n return;\n }\n initializedNamespaces.add(NS);\n for (const [lang, resources] of Object.entries(locales)) {\n i18n.addResourceBundle(lang, NS, resources);\n }\n}\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,iBAAiB;AACtC,OAAOC,gBAAgB,MAAM,kCAAkC;AAE/D,IAAIC,WAAW,GAAG,KAAK;AACvB,IAAMC,qBAAqB,GAAG,IAAIC,GAAG,CAAS,CAAC;AAM/C,OAAO,SAASC,cAAcA,CAACC,EAAW,EAAEC,OAAiB,EAAE;EAC7D,IAAI,CAACL,WAAW,EAAE;IAChBA,WAAW,GAAG,IAAI;IAClBF;IACE;IACA;IACA;IAAA,CACCQ,GAAG,CACFC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,GAC3BV,gBAAgB,GAChB,0BACEA,gBAAgB,CAChBW,OACR;IACA;IAAA,CACCC,IAAI,CAAC;MACJC,WAAW,EAAE,IAAI;MACjBC,KAAK,EAAEN,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa;MAC7CK,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;MAC3BC,wBAAwB,EAAE,IAAI;MAC9BC,aAAa,EAAE;QACbC,WAAW,EAAE,KAAK,CAAE;MACtB,CAAC;MACDC,KAAK,EAAE;QACLC,WAAW,EAAE;MACf,CAAC;MACDC,iBAAiB,EAAE,IAAI;MACvBC,SAAS,EAAE,CAAC;IACd,CAAC,CAAC;EACN;EAEA,IAAI,CAACjB,EAAE,IAAI,CAACC,OAAO,IAAIJ,qBAAqB,CAACqB,GAAG,CAAClB,EAAE,CAAC,EAAE;IACpD;EACF;EACAH,qBAAqB,CAACsB,GAAG,CAACnB,EAAE,CAAC;EAC7B,KAAK,IAAM,CAACoB,IAAI,EAAEH,SAAS,CAAC,IAAII,MAAM,CAACC,OAAO,CAACrB,OAAO,CAAC,EAAE;IACvDP,IAAI,CAAC6B,iBAAiB,CAACH,IAAI,EAAEpB,EAAE,EAAEiB,SAAS,CAAC;EAC7C;AACF"}
1
+ {"version":3,"file":"init.js","names":["i18n","LanguageDetector","initialized","initializedNamespaces","Set","initializeI18n","NS","locales","use","process","env","NODE_ENV","default","init","fallbackLng","debug","supportedLngs","nonExplicitSupportedLngs","interpolation","escapeValue","react","useSuspense","compatibilityJSON","resources","has","add","lang","Object","entries","addResourceBundle"],"sources":["../../src/init.ts"],"sourcesContent":["import { i18n } from \"@next-core/i18n\";\nimport LanguageDetector from \"i18next-browser-languagedetector\";\n\nlet initialized = false;\nconst initializedNamespaces = new Set<string>();\n\nexport type Locales = Record<string, Record<string, string | undefined>>;\n\nexport function initializeI18n(): void;\nexport function initializeI18n(NS: string, locales: Locales): void;\nexport function initializeI18n(NS?: string, locales?: Locales) {\n if (!initialized) {\n initialized = true;\n i18n\n // learn more: https://github.com/i18next/i18next-xhr-backend\n // .use(Backend)\n // learn more: https://github.com/i18next/i18next-browser-languageDetector\n .use(\n process.env.NODE_ENV === \"test\"\n ? LanguageDetector\n : /* istanbul ignore next */ (\n LanguageDetector as unknown as { default: LanguageDetector }\n ).default\n )\n // for all options read: https://www.i18next.com/overview/configuration-options\n .init({\n fallbackLng: \"zh\",\n debug: process.env.NODE_ENV === \"development\",\n supportedLngs: [\"zh\", \"en\"],\n nonExplicitSupportedLngs: true,\n interpolation: {\n escapeValue: false, // not needed for react as it escapes by default\n },\n react: {\n useSuspense: false,\n },\n compatibilityJSON: \"v3\",\n resources: {},\n });\n }\n\n if (!NS || !locales || initializedNamespaces.has(NS)) {\n return;\n }\n initializedNamespaces.add(NS);\n for (const [lang, resources] of Object.entries(locales)) {\n i18n.addResourceBundle(lang, NS, resources);\n }\n}\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,iBAAiB;AACtC,OAAOC,gBAAgB,MAAM,kCAAkC;AAE/D,IAAIC,WAAW,GAAG,KAAK;AACvB,IAAMC,qBAAqB,GAAG,IAAIC,GAAG,CAAS,CAAC;AAM/C,OAAO,SAASC,cAAcA,CAACC,EAAW,EAAEC,OAAiB,EAAE;EAC7D,IAAI,CAACL,WAAW,EAAE;IAChBA,WAAW,GAAG,IAAI;IAClBF;IACE;IACA;IACA;IAAA,CACCQ,GAAG,CACFC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,MAAM,GAC3BV,gBAAgB,GAChB,0BACEA,gBAAgB,CAChBW,OACR;IACA;IAAA,CACCC,IAAI,CAAC;MACJC,WAAW,EAAE,IAAI;MACjBC,KAAK,EAAEN,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,aAAa;MAC7CK,aAAa,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;MAC3BC,wBAAwB,EAAE,IAAI;MAC9BC,aAAa,EAAE;QACbC,WAAW,EAAE,KAAK,CAAE;MACtB,CAAC;MACDC,KAAK,EAAE;QACLC,WAAW,EAAE;MACf,CAAC;MACDC,iBAAiB,EAAE,IAAI;MACvBC,SAAS,EAAE,CAAC;IACd,CAAC,CAAC;EACN;EAEA,IAAI,CAACjB,EAAE,IAAI,CAACC,OAAO,IAAIJ,qBAAqB,CAACqB,GAAG,CAAClB,EAAE,CAAC,EAAE;IACpD;EACF;EACAH,qBAAqB,CAACsB,GAAG,CAACnB,EAAE,CAAC;EAC7B,KAAK,IAAM,CAACoB,IAAI,EAAEH,SAAS,CAAC,IAAII,MAAM,CAACC,OAAO,CAACrB,OAAO,CAAC,EAAE;IACvDP,IAAI,CAAC6B,iBAAiB,CAACH,IAAI,EAAEpB,EAAE,EAAEiB,SAAS,CAAC;EAC7C;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","names":["i18n","initializeI18n","initReactI18next","useTranslation","initialized","initializeReactI18n","NS","locales","init"],"sources":["../../src/react.ts"],"sourcesContent":["import { i18n, initializeI18n, Locales } from \"@next-core/i18n\";\nimport { initReactI18next, useTranslation } from \"react-i18next\";\n\nlet initialized = false;\n\nexport function initializeReactI18n(): void;\nexport function initializeReactI18n(NS: string, locales: Locales): void;\nexport function initializeReactI18n(NS?: string, locales?: Locales) {\n initializeI18n(NS as string, locales as Locales);\n if (!initialized) {\n initialized = true;\n initReactI18next.init(i18n);\n }\n}\n\nexport { useTranslation };\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,cAAc,QAAiB,iBAAiB;AAC/D,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,eAAe;AAEhE,IAAIC,WAAW,GAAG,KAAK;AAIvB,OAAO,SAASC,mBAAmBA,CAACC,EAAW,EAAEC,OAAiB,EAAE;EAClEN,cAAc,CAACK,EAAE,EAAYC,OAAkB,CAAC;EAChD,IAAI,CAACH,WAAW,EAAE;IAChBA,WAAW,GAAG,IAAI;IAClBF,gBAAgB,CAACM,IAAI,CAACR,IAAI,CAAC;EAC7B;AACF;AAEA,SAASG,cAAc"}
1
+ {"version":3,"file":"react.js","names":["i18n","initializeI18n","initReactI18next","useTranslation","initialized","initializeReactI18n","NS","locales","init"],"sources":["../../src/react.ts"],"sourcesContent":["import { i18n, initializeI18n, Locales } from \"@next-core/i18n\";\nimport { initReactI18next, useTranslation } from \"react-i18next\";\n\nlet initialized = false;\n\nexport function initializeReactI18n(): void;\nexport function initializeReactI18n(NS: string, locales: Locales): void;\nexport function initializeReactI18n(NS?: string, locales?: Locales) {\n initializeI18n(NS as string, locales as Locales);\n if (!initialized) {\n initialized = true;\n initReactI18next.init(i18n);\n }\n}\n\nexport { useTranslation };\n"],"mappings":"AAAA,SAASA,IAAI,EAAEC,cAAc,QAAiB,iBAAiB;AAC/D,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,eAAe;AAEhE,IAAIC,WAAW,GAAG,KAAK;AAIvB,OAAO,SAASC,mBAAmBA,CAACC,EAAW,EAAEC,OAAiB,EAAE;EAClEN,cAAc,CAACK,EAAE,EAAYC,OAAkB,CAAC;EAChD,IAAI,CAACH,WAAW,EAAE;IAChBA,WAAW,GAAG,IAAI;IAClBF,gBAAgB,CAACM,IAAI,CAACR,IAAI,CAAC;EAC7B;AACF;AAEA,SAASG,cAAc","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","names":["i18n","hasOwnProperty","i18nText","data","_i18n$language","language","primaryLanguage","split","undefined","prefix","concat","key","Object","keys","startsWith"],"sources":["../../src/text.ts"],"sourcesContent":["import { i18n } from \"@next-core/i18n\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { I18nData } from \"@next-core/types\";\n\nexport function i18nText(\n data: I18nData | null | undefined\n): string | undefined {\n if (!data) {\n return;\n }\n const language = i18n.language ?? \"zh-CN\";\n // First, make a perfect match.\n if (hasOwnProperty(data, language)) {\n return data[language];\n }\n // https://en.wikipedia.org/wiki/IETF_language_tag\n const primaryLanguage = language.split(\"-\")[0];\n if (primaryLanguage !== language) {\n // Then, match the primary language (which omits other subtags).\n // E.g., match `zh` if the current language is `zh-CN`.\n return hasOwnProperty(data, primaryLanguage)\n ? data[primaryLanguage]\n : undefined;\n }\n // At last, match the first key which starts with the primary language,\n // if the current language contains primary subtag only.\n // E.g., match `zh-CN` if the current language is `zh`.\n const prefix = `${primaryLanguage}-`;\n for (const key of Object.keys(data)) {\n if (key.startsWith(prefix)) {\n return data[key];\n }\n }\n}\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,iBAAiB;AACtC,SAASC,cAAc,QAAQ,0BAA0B;AAGzD,OAAO,SAASC,QAAQA,CACtBC,IAAiC,EACb;EAAA,IAAAC,cAAA;EACpB,IAAI,CAACD,IAAI,EAAE;IACT;EACF;EACA,IAAME,QAAQ,IAAAD,cAAA,GAAGJ,IAAI,CAACK,QAAQ,cAAAD,cAAA,cAAAA,cAAA,GAAI,OAAO;EACzC;EACA,IAAIH,cAAc,CAACE,IAAI,EAAEE,QAAQ,CAAC,EAAE;IAClC,OAAOF,IAAI,CAACE,QAAQ,CAAC;EACvB;EACA;EACA,IAAMC,eAAe,GAAGD,QAAQ,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EAC9C,IAAID,eAAe,KAAKD,QAAQ,EAAE;IAChC;IACA;IACA,OAAOJ,cAAc,CAACE,IAAI,EAAEG,eAAe,CAAC,GACxCH,IAAI,CAACG,eAAe,CAAC,GACrBE,SAAS;EACf;EACA;EACA;EACA;EACA,IAAMC,MAAM,MAAAC,MAAA,CAAMJ,eAAe,MAAG;EACpC,KAAK,IAAMK,GAAG,IAAIC,MAAM,CAACC,IAAI,CAACV,IAAI,CAAC,EAAE;IACnC,IAAIQ,GAAG,CAACG,UAAU,CAACL,MAAM,CAAC,EAAE;MAC1B,OAAON,IAAI,CAACQ,GAAG,CAAC;IAClB;EACF;AACF"}
1
+ {"version":3,"file":"text.js","names":["i18n","hasOwnProperty","i18nText","data","_i18n$language","language","primaryLanguage","split","undefined","prefix","concat","key","Object","keys","startsWith"],"sources":["../../src/text.ts"],"sourcesContent":["import { i18n } from \"@next-core/i18n\";\nimport { hasOwnProperty } from \"@next-core/utils/general\";\nimport { I18nData } from \"@next-core/types\";\n\nexport function i18nText(\n data: I18nData | null | undefined\n): string | undefined {\n if (!data) {\n return;\n }\n const language = i18n.language ?? \"zh-CN\";\n // First, make a perfect match.\n if (hasOwnProperty(data, language)) {\n return data[language];\n }\n // https://en.wikipedia.org/wiki/IETF_language_tag\n const primaryLanguage = language.split(\"-\")[0];\n if (primaryLanguage !== language) {\n // Then, match the primary language (which omits other subtags).\n // E.g., match `zh` if the current language is `zh-CN`.\n return hasOwnProperty(data, primaryLanguage)\n ? data[primaryLanguage]\n : undefined;\n }\n // At last, match the first key which starts with the primary language,\n // if the current language contains primary subtag only.\n // E.g., match `zh-CN` if the current language is `zh`.\n const prefix = `${primaryLanguage}-`;\n for (const key of Object.keys(data)) {\n if (key.startsWith(prefix)) {\n return data[key];\n }\n }\n}\n"],"mappings":"AAAA,SAASA,IAAI,QAAQ,iBAAiB;AACtC,SAASC,cAAc,QAAQ,0BAA0B;AAGzD,OAAO,SAASC,QAAQA,CACtBC,IAAiC,EACb;EAAA,IAAAC,cAAA;EACpB,IAAI,CAACD,IAAI,EAAE;IACT;EACF;EACA,IAAME,QAAQ,IAAAD,cAAA,GAAGJ,IAAI,CAACK,QAAQ,cAAAD,cAAA,cAAAA,cAAA,GAAI,OAAO;EACzC;EACA,IAAIH,cAAc,CAACE,IAAI,EAAEE,QAAQ,CAAC,EAAE;IAClC,OAAOF,IAAI,CAACE,QAAQ,CAAC;EACvB;EACA;EACA,IAAMC,eAAe,GAAGD,QAAQ,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EAC9C,IAAID,eAAe,KAAKD,QAAQ,EAAE;IAChC;IACA;IACA,OAAOJ,cAAc,CAACE,IAAI,EAAEG,eAAe,CAAC,GACxCH,IAAI,CAACG,eAAe,CAAC,GACrBE,SAAS;EACf;EACA;EACA;EACA;EACA,IAAMC,MAAM,MAAAC,MAAA,CAAMJ,eAAe,MAAG;EACpC,KAAK,IAAMK,GAAG,IAAIC,MAAM,CAACC,IAAI,CAACV,IAAI,CAAC,EAAE;IACnC,IAAIQ,GAAG,CAACG,UAAU,CAACL,MAAM,CAAC,EAAE;MAC1B,OAAON,IAAI,CAACQ,GAAG,CAAC;IAClB;EACF;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/i18n",
3
- "version": "1.0.40",
3
+ "version": "1.0.42",
4
4
  "homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/i18n",
5
5
  "license": "GPL-3.0",
6
6
  "repository": {
@@ -39,15 +39,15 @@
39
39
  "test:ci": "cross-env NODE_ENV='test' CI=true test-next"
40
40
  },
41
41
  "dependencies": {
42
- "@next-core/types": "^1.9.0",
43
- "@next-core/utils": "^1.6.12",
42
+ "@next-core/types": "^1.10.0",
43
+ "@next-core/utils": "^1.7.0",
44
44
  "i18next": "^22.5.1",
45
- "i18next-browser-languagedetector": "^7.2.0",
45
+ "i18next-browser-languagedetector": "^7.2.1",
46
46
  "react-i18next": "^12.3.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@next-core/build-next-libs": "^1.0.13",
50
- "@next-core/test-next": "^1.0.16"
49
+ "@next-core/build-next-libs": "^1.0.14",
50
+ "@next-core/test-next": "^1.0.17"
51
51
  },
52
- "gitHead": "8ec671fcea94d95fc87661fe9b4268f5a746ba61"
52
+ "gitHead": "8255acda4ad909cc07087dd99755325e3f31fb70"
53
53
  }