@prosopo/locale 3.2.7 → 3.2.9

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.
Files changed (101) hide show
  1. package/.turbo/turbo-build$colon$cjs.log +20 -20
  2. package/.turbo/turbo-build$colon$tsc.log +5 -5
  3. package/.turbo/turbo-build.log +27 -24
  4. package/CHANGELOG.md +18 -0
  5. package/dist/_virtual/_rolldown/runtime.js +3 -0
  6. package/dist/cjs/_virtual/_rolldown/runtime.cjs +23 -0
  7. package/dist/cjs/i18SharedOptions.cjs +8 -10
  8. package/dist/cjs/i18nBackend.cjs +29 -29
  9. package/dist/cjs/i18nFrontend.cjs +54 -61
  10. package/dist/cjs/i18nMiddleware.cjs +7 -6
  11. package/dist/cjs/index.cjs +13 -14
  12. package/dist/cjs/loadI18next.cjs +23 -33
  13. package/dist/cjs/locales/en/translation.cjs +488 -0
  14. package/dist/cjs/translationKey.cjs +14 -22
  15. package/dist/cjs/translations.cjs +39 -39
  16. package/dist/cjs/useTranslation.cjs +10 -6
  17. package/dist/cjs/util.cjs +6 -6
  18. package/dist/i18SharedOptions.js +9 -11
  19. package/dist/i18nBackend.js +25 -28
  20. package/dist/i18nFrontend.js +45 -57
  21. package/dist/i18nMiddleware.d.ts +2 -1
  22. package/dist/i18nMiddleware.d.ts.map +1 -1
  23. package/dist/i18nMiddleware.js +5 -6
  24. package/dist/i18nMiddleware.js.map +1 -1
  25. package/dist/index.js +5 -12
  26. package/dist/loadI18next.js +23 -34
  27. package/dist/locales/ar/translation.json +1 -0
  28. package/dist/locales/az/translation.json +1 -0
  29. package/dist/locales/cs/translation.json +1 -0
  30. package/dist/locales/de/translation.json +1 -0
  31. package/dist/locales/el/translation.json +1 -0
  32. package/dist/locales/en/translation.js +474 -0
  33. package/dist/locales/en/translation.json +1 -0
  34. package/dist/locales/es/translation.json +1 -0
  35. package/dist/locales/fi/translation.json +1 -0
  36. package/dist/locales/fr/translation.json +1 -0
  37. package/dist/locales/hi/translation.json +1 -0
  38. package/dist/locales/hu/translation.json +1 -0
  39. package/dist/locales/id/translation.json +1 -0
  40. package/dist/locales/it/translation.json +1 -0
  41. package/dist/locales/ja/translation.json +1 -0
  42. package/dist/locales/jv/translation.json +1 -0
  43. package/dist/locales/ko/translation.json +1 -0
  44. package/dist/locales/ml/translation.json +1 -0
  45. package/dist/locales/ms/translation.json +1 -0
  46. package/dist/locales/nl/translation.json +1 -0
  47. package/dist/locales/no/translation.json +1 -0
  48. package/dist/locales/pl/translation.json +1 -0
  49. package/dist/locales/pt/translation.json +1 -0
  50. package/dist/locales/pt-BR/translation.json +1 -0
  51. package/dist/locales/ro/translation.json +1 -0
  52. package/dist/locales/ru/translation.json +1 -0
  53. package/dist/locales/sr/translation.json +1 -0
  54. package/dist/locales/sv/translation.json +1 -0
  55. package/dist/locales/th/translation.json +1 -0
  56. package/dist/locales/tr/translation.json +1 -0
  57. package/dist/locales/uk/translation.json +1 -0
  58. package/dist/locales/vi/translation.json +1 -0
  59. package/dist/locales/zh-CN/translation.json +1 -0
  60. package/dist/translationKey.js +15 -23
  61. package/dist/translations.js +37 -40
  62. package/dist/useTranslation.js +10 -8
  63. package/dist/util.js +7 -8
  64. package/package.json +6 -6
  65. package/src/i18nMiddleware.ts +6 -1
  66. package/src/locales/ar/translation.json +1 -0
  67. package/src/locales/az/translation.json +1 -0
  68. package/src/locales/cs/translation.json +1 -0
  69. package/src/locales/de/translation.json +1 -0
  70. package/src/locales/el/translation.json +1 -0
  71. package/src/locales/en/translation.json +1 -0
  72. package/src/locales/es/translation.json +1 -0
  73. package/src/locales/fi/translation.json +1 -0
  74. package/src/locales/fr/translation.json +1 -0
  75. package/src/locales/hi/translation.json +1 -0
  76. package/src/locales/hu/translation.json +1 -0
  77. package/src/locales/id/translation.json +1 -0
  78. package/src/locales/it/translation.json +1 -0
  79. package/src/locales/ja/translation.json +1 -0
  80. package/src/locales/jv/translation.json +1 -0
  81. package/src/locales/ko/translation.json +1 -0
  82. package/src/locales/ml/translation.json +1 -0
  83. package/src/locales/ms/translation.json +1 -0
  84. package/src/locales/nl/translation.json +1 -0
  85. package/src/locales/no/translation.json +1 -0
  86. package/src/locales/pl/translation.json +1 -0
  87. package/src/locales/pt/translation.json +1 -0
  88. package/src/locales/pt-BR/translation.json +1 -0
  89. package/src/locales/ro/translation.json +1 -0
  90. package/src/locales/ru/translation.json +1 -0
  91. package/src/locales/sr/translation.json +1 -0
  92. package/src/locales/sv/translation.json +1 -0
  93. package/src/locales/th/translation.json +1 -0
  94. package/src/locales/tr/translation.json +1 -0
  95. package/src/locales/uk/translation.json +1 -0
  96. package/src/locales/vi/translation.json +1 -0
  97. package/src/locales/zh-CN/translation.json +1 -0
  98. package/tsconfig.tsbuildinfo +1 -1
  99. package/.turbo/turbo-typecheck.log +0 -4
  100. package/dist/cjs/locales/en/translation.json.cjs +0 -47
  101. package/dist/locales/en/translation.json.js +0 -47
@@ -1,32 +1,29 @@
1
- import path from "node:path";
1
+ import "./_virtual/_rolldown/runtime.js";
2
+ import { isServerSide } from "./util.js";
3
+ import { i18nSharedOptions } from "./i18SharedOptions.js";
4
+ import { LanguageDetector } from "i18next-http-middleware";
2
5
  import i18n from "i18next";
6
+ import path from "node:path";
3
7
  import FSBackend from "i18next-fs-backend/cjs";
4
- import { LanguageDetector } from "i18next-http-middleware";
5
- import { i18nSharedOptions } from "./i18SharedOptions.js";
6
- import { isServerSide } from "./util.js";
7
- const loadPath = `${path.dirname(import.meta.url)}/locales/{{lng}}/{{ns}}.json`.replace(
8
- "file://",
9
- ""
10
- );
8
+ //#region src/i18nBackend.ts
9
+ var loadPath = `${path.dirname(import.meta.url)}/locales/{{lng}}/{{ns}}.json`.replace("file://", "");
11
10
  function initializeI18n(i18nLoadedCallback) {
12
- if (!i18n.isInitialized && isServerSide()) {
13
- const lngDetector = new LanguageDetector(null, {
14
- order: ["header", "query", "cookie"]
15
- });
16
- i18n.use(FSBackend).use(lngDetector).init({
17
- ...i18nSharedOptions,
18
- ns: ["translation"],
19
- backend: {
20
- loadPath
21
- }
22
- });
23
- i18n.on("loaded", () => {
24
- i18nLoadedCallback?.(i18n);
25
- });
26
- }
27
- return i18n;
11
+ if (!i18n.isInitialized && isServerSide()) {
12
+ const lngDetector = new LanguageDetector(null, { order: [
13
+ "header",
14
+ "query",
15
+ "cookie"
16
+ ] });
17
+ i18n.use(FSBackend).use(lngDetector).init({
18
+ ...i18nSharedOptions,
19
+ ns: ["translation"],
20
+ backend: { loadPath }
21
+ });
22
+ i18n.on("loaded", () => {
23
+ i18nLoadedCallback?.(i18n);
24
+ });
25
+ }
26
+ return i18n;
28
27
  }
29
- export {
30
- initializeI18n as default,
31
- initializeI18n
32
- };
28
+ //#endregion
29
+ export { initializeI18n as default, initializeI18n };
@@ -1,66 +1,54 @@
1
+ import "./_virtual/_rolldown/runtime.js";
2
+ import { i18nSharedOptions } from "./i18SharedOptions.js";
3
+ import { initReactI18next } from "react-i18next";
1
4
  import i18n from "i18next";
2
5
  import I18nextBrowserLanguageDetector from "i18next-browser-languagedetector";
3
6
  import ChainedBackend from "i18next-chained-backend";
4
7
  import HttpBackend from "i18next-http-backend";
5
8
  import resourcesToBackend from "i18next-resources-to-backend";
6
- import { initReactI18next } from "react-i18next";
7
- import { i18nSharedOptions } from "./i18SharedOptions.js";
8
- const reactOptions = {
9
- react: {
10
- useSuspense: true
11
- },
12
- detection: {
13
- order: ["navigator", "htmlTag", "path", "subdomain"],
14
- caches: ["localStorage", "cookie"]
15
- }
9
+ //#region src/i18nFrontend.ts
10
+ var reactOptions = {
11
+ react: { useSuspense: true },
12
+ detection: {
13
+ order: [
14
+ "navigator",
15
+ "htmlTag",
16
+ "path",
17
+ "subdomain"
18
+ ],
19
+ caches: ["localStorage", "cookie"]
20
+ }
16
21
  };
17
- const getLoadPath = (language, namespace) => {
18
- const filename = import.meta.url.split("/").pop();
19
- return `${import.meta.url.replace(`/${filename}`, "")}/locales/${language}/${namespace}.json`;
22
+ var getLoadPath = (language, namespace) => {
23
+ const filename = import.meta.url.split("/").pop();
24
+ return `${import.meta.url.replace(`/${filename}`, "")}/locales/${language}/${namespace}.json`;
20
25
  };
21
26
  function initializeI18n(i18nLoadedCallback, lng) {
22
- if (!i18n.isInitialized) {
23
- i18n.use(ChainedBackend).use(
24
- new I18nextBrowserLanguageDetector(null, {
25
- order: ["cookie", "localStorage", "navigator"],
26
- lookupQuerystring: "lng",
27
- lookupCookie: "i18next",
28
- lookupLocalStorage: "i18nextLng",
29
- caches: ["localStorage", "cookie"]
30
- })
31
- ).use(initReactI18next).init({
32
- ...i18nSharedOptions,
33
- // When the site owner has resolved a language upfront (via widget
34
- // config or data-language) we set `lng` explicitly so i18next skips
35
- // browser detection. This is the single source of truth for the
36
- // widget language and prevents the flash-of-wrong-language race
37
- // where child components read the browser-detected language on
38
- // first render before an effect can call changeLanguage().
39
- ...lng ? { lng } : {},
40
- backend: {
41
- backends: [
42
- HttpBackend,
43
- // if a namespace can't be loaded via normal http-backend loadPath, then the inMemoryLocalBackend will try to return the correct resources
44
- // with dynamic import, you have to use the "default" key of the module ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#importing_defaults )
45
- resourcesToBackend(
46
- (language, namespace) => import(getLoadPath(language, namespace))
47
- )
48
- ],
49
- backendOptions: [
50
- {
51
- loadPath: getLoadPath("{{lng}}", "{{ns}}")
52
- }
53
- ]
54
- },
55
- ...reactOptions
56
- });
57
- i18n.on("loaded", () => {
58
- i18nLoadedCallback?.(i18n);
59
- });
60
- }
61
- return i18n;
27
+ if (!i18n.isInitialized) {
28
+ i18n.use(ChainedBackend).use(new I18nextBrowserLanguageDetector(null, {
29
+ order: [
30
+ "cookie",
31
+ "localStorage",
32
+ "navigator"
33
+ ],
34
+ lookupQuerystring: "lng",
35
+ lookupCookie: "i18next",
36
+ lookupLocalStorage: "i18nextLng",
37
+ caches: ["localStorage", "cookie"]
38
+ })).use(initReactI18next).init({
39
+ ...i18nSharedOptions,
40
+ ...lng ? { lng } : {},
41
+ backend: {
42
+ backends: [HttpBackend, resourcesToBackend((language, namespace) => import(getLoadPath(language, namespace)))],
43
+ backendOptions: [{ loadPath: getLoadPath("{{lng}}", "{{ns}}") }]
44
+ },
45
+ ...reactOptions
46
+ });
47
+ i18n.on("loaded", () => {
48
+ i18nLoadedCallback?.(i18n);
49
+ });
50
+ }
51
+ return i18n;
62
52
  }
63
- export {
64
- initializeI18n as default,
65
- initializeI18n
66
- };
53
+ //#endregion
54
+ export { initializeI18n as default, initializeI18n };
@@ -1,4 +1,5 @@
1
- import { type HandleOptions, handle } from "i18next-http-middleware";
1
+ import { handle } from "i18next-http-middleware";
2
+ type HandleOptions = NonNullable<Parameters<typeof handle>[1]>;
2
3
  declare function i18nMiddleware(options: HandleOptions): Promise<ReturnType<typeof handle>>;
3
4
  export default i18nMiddleware;
4
5
  //# sourceMappingURL=i18nMiddleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"i18nMiddleware.d.ts","sourceRoot":"","sources":["../src/i18nMiddleware.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGrE,iBAAe,cAAc,CAC5B,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAGpC;AAED,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"i18nMiddleware.d.ts","sourceRoot":"","sources":["../src/i18nMiddleware.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAMjD,KAAK,aAAa,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/D,iBAAe,cAAc,CAC5B,OAAO,EAAE,aAAa,GACpB,OAAO,CAAC,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAGpC;AAED,eAAe,cAAc,CAAC"}
@@ -1,9 +1,8 @@
1
- import { handle } from "i18next-http-middleware";
2
1
  import loadI18next from "./loadI18next.js";
2
+ import { handle } from "i18next-http-middleware";
3
+ //#region src/i18nMiddleware.ts
3
4
  async function i18nMiddleware(options) {
4
- const i18n = await loadI18next(true);
5
- return handle(i18n, { ...options });
5
+ return handle(await loadI18next(true), { ...options });
6
6
  }
7
- export {
8
- i18nMiddleware as default
9
- };
7
+ //#endregion
8
+ export { i18nMiddleware as default };
@@ -1 +1 @@
1
- {"version":3,"file":"i18nMiddleware.js","sourceRoot":"","sources":["../src/i18nMiddleware.ts"],"names":[],"mappings":"AAcA,OAAO,EAAsB,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAE3C,KAAK,UAAU,cAAc,CAC5B,OAAsB;IAEtB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"i18nMiddleware.js","sourceRoot":"","sources":["../src/i18nMiddleware.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAO3C,KAAK,UAAU,cAAc,CAC5B,OAAsB;IAEtB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,MAAM,CAAC,IAAI,EAAE,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,eAAe,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,15 +1,8 @@
1
- import { default as default2 } from "./i18nMiddleware.js";
2
- import { default as default3 } from "./loadI18next.js";
1
+ import "./_virtual/_rolldown/runtime.js";
2
+ import loadI18next from "./loadI18next.js";
3
+ import i18nMiddleware from "./i18nMiddleware.js";
3
4
  import { LanguageSchema, Languages } from "./translations.js";
4
5
  import { isClientSide } from "./util.js";
5
6
  import { TranslationKeysSchema } from "./translationKey.js";
6
- import { default as default4 } from "./useTranslation.js";
7
- export {
8
- LanguageSchema,
9
- Languages,
10
- TranslationKeysSchema,
11
- default2 as i18nMiddleware,
12
- isClientSide,
13
- default3 as loadI18next,
14
- default4 as useTranslation
15
- };
7
+ import useTranslation from "./useTranslation.js";
8
+ export { LanguageSchema, Languages, TranslationKeysSchema, i18nMiddleware, isClientSide, loadI18next, useTranslation };
@@ -1,37 +1,26 @@
1
- let i18nInstance;
2
- const reconcileLanguage = async (instance, lng) => {
3
- if (lng && instance.language !== lng) {
4
- await instance.changeLanguage(lng);
5
- }
6
- return instance;
1
+ //#region src/loadI18next.ts
2
+ var i18nInstance;
3
+ var reconcileLanguage = async (instance, lng) => {
4
+ if (lng && instance.language !== lng) await instance.changeLanguage(lng);
5
+ return instance;
7
6
  };
8
7
  async function loadI18next(backend, lng) {
9
- return new Promise((resolve, reject) => {
10
- try {
11
- if (backend) {
12
- import("./i18nBackend.js").then(({ default: initializeI18n }) => {
13
- if (!i18nInstance) {
14
- i18nInstance = initializeI18n(resolve);
15
- } else {
16
- resolve(i18nInstance);
17
- }
18
- });
19
- } else {
20
- import("./i18nFrontend.js").then(({ default: initializeI18n }) => {
21
- if (!i18nInstance) {
22
- i18nInstance = initializeI18n((instance) => {
23
- void reconcileLanguage(instance, lng).then(resolve);
24
- }, lng);
25
- } else {
26
- void reconcileLanguage(i18nInstance, lng).then(resolve);
27
- }
28
- });
29
- }
30
- } catch (e) {
31
- reject(e);
32
- }
33
- });
8
+ return new Promise((resolve, reject) => {
9
+ try {
10
+ if (backend) import("./i18nBackend.js").then(({ default: initializeI18n }) => {
11
+ if (!i18nInstance) i18nInstance = initializeI18n(resolve);
12
+ else resolve(i18nInstance);
13
+ });
14
+ else import("./i18nFrontend.js").then(({ default: initializeI18n }) => {
15
+ if (!i18nInstance) i18nInstance = initializeI18n((instance) => {
16
+ reconcileLanguage(instance, lng).then(resolve);
17
+ }, lng);
18
+ else reconcileLanguage(i18nInstance, lng).then(resolve);
19
+ });
20
+ } catch (e) {
21
+ reject(e);
22
+ }
23
+ });
34
24
  }
35
- export {
36
- loadI18next as default
37
- };
25
+ //#endregion
26
+ export { loadI18next as default };
@@ -43,6 +43,7 @@
43
43
  "INVALID_BODY": "بيانات غير صالحة",
44
44
  "PARSE_ERROR": "خطأ في تحليل الطلب",
45
45
  "SPAM_EMAIL_RULE": "عنوان البريد الإلكتروني محظور بواسطة قواعد مكافحة البريد العشوائي",
46
+ "SPAM_EMAIL_COUNT_EXCEEDED": "كثرة الطلبات من عنوان البريد الإلكتروني هذا",
46
47
  "VPN_BLOCKED": "لا يُسمح بالطلبات من اتصالات VPN لهذا الموقع",
47
48
  "PROXY_BLOCKED": "لا يُسمح بالطلبات من خوادم البروكسي لهذا الموقع",
48
49
  "TOR_BLOCKED": "لا يُسمح بالطلبات من عقد خروج Tor لهذا الموقع",
@@ -43,6 +43,7 @@
43
43
  "INVALID_BODY": "Yanlış bədən",
44
44
  "PARSE_ERROR": "Tələbi pars edərkən səhv baş verdi",
45
45
  "SPAM_EMAIL_RULE": "E-poçt ünvanı spam filtr qaydaları ilə bloklanıb",
46
+ "SPAM_EMAIL_COUNT_EXCEEDED": "Bu e-poçt ünvanından çox sayda göndəriş",
46
47
  "VPN_BLOCKED": "Bu sayt üçün VPN bağlantılarından sorğulara icazə verilmir",
47
48
  "PROXY_BLOCKED": "Bu sayt üçün proksi serverlərdən sorğulara icazə verilmir",
48
49
  "TOR_BLOCKED": "Bu sayt üçün Tor çıxış qovşaqlarından sorğulara icazə verilmir",
@@ -43,6 +43,7 @@
43
43
  "INVALID_BODY": "Neplatné tělo",
44
44
  "PARSE_ERROR": "Chyba při zpracování požadavku",
45
45
  "SPAM_EMAIL_RULE": "E-mailová adresa blokována pravidly spamového filtru",
46
+ "SPAM_EMAIL_COUNT_EXCEEDED": "Příliš mnoho odeslání z této e-mailové adresy",
46
47
  "VPN_BLOCKED": "Požadavky z VPN připojení nejsou pro tento web povoleny",
47
48
  "PROXY_BLOCKED": "Požadavky z proxy serverů nejsou pro tento web povoleny",
48
49
  "TOR_BLOCKED": "Požadavky z výstupních uzlů Tor nejsou pro tento web povoleny",
@@ -43,6 +43,7 @@
43
43
  "INVALID_BODY": "Ungültiger Körper",
44
44
  "PARSE_ERROR": "Fehler beim Parsen der Anfrage",
45
45
  "SPAM_EMAIL_RULE": "E-Mail-Adresse durch Spamfilter-Regeln blockiert",
46
+ "SPAM_EMAIL_COUNT_EXCEEDED": "Zu viele Einsendungen von dieser E-Mail-Adresse",
46
47
  "VPN_BLOCKED": "Anfragen über VPN-Verbindungen sind für diese Website nicht erlaubt",
47
48
  "PROXY_BLOCKED": "Anfragen über Proxy-Server sind für diese Website nicht erlaubt",
48
49
  "TOR_BLOCKED": "Anfragen über Tor-Exit-Knoten sind für diese Website nicht erlaubt",
@@ -30,6 +30,7 @@
30
30
  "INVALID_BODY": "Μη έγκυρο σώμα",
31
31
  "PARSE_ERROR": "Σφάλμα ανάλυσης αιτήματος",
32
32
  "SPAM_EMAIL_RULE": "Η διεύθυνση email αποκλείστηκε από κανόνες φίλτρου spam",
33
+ "SPAM_EMAIL_COUNT_EXCEEDED": "Πάρα πολλές υποβολές από αυτή τη διεύθυνση email",
33
34
  "VPN_BLOCKED": "Αιτήματα από συνδέσεις VPN δεν επιτρέπονται για αυτόν τον ιστότοπο",
34
35
  "PROXY_BLOCKED": "Αιτήματα από διακομιστές proxy δεν επιτρέπονται για αυτόν τον ιστότοπο",
35
36
  "TOR_BLOCKED": "Αιτήματα από κόμβους εξόδου Tor δεν επιτρέπονται για αυτόν τον ιστότοπο",