@koine/i18n 2.0.0-beta.173 → 2.0.0-beta.174

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.
@@ -33,7 +33,7 @@ export function createT<TDictionary extends I18nUtils.TranslationsDictionaryLoos
33
33
  query?: I18nUtils.TranslateQuery,
34
34
  fallback?: TFallback
35
35
  ): TReturn => {
36
- let [namespaceOrPath, maybePath] = trace.split("${l}");
36
+ const [namespaceOrPath, maybePath] = trace.split("${l}");
37
37
  // namespace is optional, so in case there is no delimiter we just have the path
38
38
  const namespace = namespaceOrPath && maybePath ? namespaceOrPath : "";
39
39
  const path = namespaceOrPath && maybePath ? maybePath : namespaceOrPath;
@@ -31,7 +31,7 @@ export function createT<TDictionary extends I18nUtils.TranslationsDictionaryLoos
31
31
  query?: I18nUtils.TranslateQuery,
32
32
  fallback?: TFallback
33
33
  ): TReturn => {
34
- let [namespaceOrPath, maybePath] = trace.split("${l}");
34
+ const [namespaceOrPath, maybePath] = trace.split("${l}");
35
35
  // namespace is optional, so in case there is no delimiter we just have the path
36
36
  const namespace = namespaceOrPath && maybePath ? namespaceOrPath : "";
37
37
  const path = namespaceOrPath && maybePath ? maybePath : namespaceOrPath;
@@ -17,9 +17,8 @@ export async function getT<TNamespace extends I18n.TranslationsNamespace>(
17
17
  namespace: TNamespace,
18
18
  ) {
19
19
  const translations = await loadTranslations(locale, namespace);
20
- const pluralRules = new Intl.PluralRules(locale);
20
+ const t = createT({ [namespace]: translations }, locale);
21
21
 
22
- const t = createT({ [namespace]: translations }, pluralRules, locale);
23
22
  return ((path: string, ...args: any[]) =>
24
23
  (t as any)(
25
24
  \`\${namespace}:\${path}\`,
@@ -15,9 +15,8 @@ export async function getT<TNamespace extends I18n.TranslationsNamespace>(
15
15
  namespace: TNamespace,
16
16
  ) {
17
17
  const translations = await loadTranslations(locale, namespace);
18
- const pluralRules = new Intl.PluralRules(locale);
18
+ const t = createT({ [namespace]: translations }, locale);
19
19
 
20
- const t = createT({ [namespace]: translations }, pluralRules, locale);
21
20
  return ((path: string, ...args: any[]) =>
22
21
  (t as any)(
23
22
  \`\${namespace}:\${path}\`,
@@ -17,9 +17,6 @@ import { getLocale } from "./getLocale";
17
17
  /**
18
18
  * **For React RSC only**
19
19
  *
20
- * It grabs the current locale from NodeJS' \`AsyncLocalStorage\` implementation
21
- * used in \`I18nLocaleContext\`.
22
- *
23
20
  * For compatibility with the vanilla _js_ implementation of this function and
24
21
  * for further customization it allows passing as first argument a custom _locale_
25
22
  * code.
@@ -39,9 +36,8 @@ export async function getT<TNamespace extends I18n.TranslationsNamespace>(
39
36
  const locale = args.length === 1 ? getLocale() : (args[0] as I18n.Locale);
40
37
  const namespace = args[1] || (args[0] as TNamespace);
41
38
  const translations = await loadTranslations(locale, namespace);
42
- const pluralRules = new Intl.PluralRules(locale);
39
+ const t = createT({ [namespace]: translations }, locale);
43
40
 
44
- const t = createT({ [namespace]: translations }, pluralRules, locale);
45
41
  return ((path: string, ...args: any[]) =>
46
42
  (t as any)(
47
43
  \`\${namespace}:\${path}\`,
@@ -15,9 +15,6 @@ import { getLocale } from "./getLocale";
15
15
  /**
16
16
  * **For React RSC only**
17
17
  *
18
- * It grabs the current locale from NodeJS' \`AsyncLocalStorage\` implementation
19
- * used in \`I18nLocaleContext\`.
20
- *
21
18
  * For compatibility with the vanilla _js_ implementation of this function and
22
19
  * for further customization it allows passing as first argument a custom _locale_
23
20
  * code.
@@ -37,9 +34,8 @@ export async function getT<TNamespace extends I18n.TranslationsNamespace>(
37
34
  const locale = args.length === 1 ? getLocale() : (args[0] as I18n.Locale);
38
35
  const namespace = args[1] || (args[0] as TNamespace);
39
36
  const translations = await loadTranslations(locale, namespace);
40
- const pluralRules = new Intl.PluralRules(locale);
37
+ const t = createT({ [namespace]: translations }, locale);
41
38
 
42
- const t = createT({ [namespace]: translations }, pluralRules, locale);
43
39
  return ((path: string, ...args: any[]) =>
44
40
  (t as any)(
45
41
  \`\${namespace}:\${path}\`,
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let i18nInterpolateParams = (e, t)=>t ? (e + "").replace(/\{\{(.*?)\}\}/g, (e, a)=>(t[a.trim()] || "{{" + a + "}}") + "") : e;
5
+ let i18nInterpolateParams = (e, t)=>t ? (e + "").replace(/\{\{(.*?)\}\}/g, (e, a)=>(t[a.trim()] ?? "{{" + a + "}}") + "") : e;
6
6
 
7
7
  exports.default = i18nInterpolateParams;
8
8
  exports.i18nInterpolateParams = i18nInterpolateParams;
@@ -1,3 +1,3 @@
1
- let i18nInterpolateParams = (e, t)=>t ? (e + "").replace(/\{\{(.*?)\}\}/g, (e, a)=>(t[a.trim()] || "{{" + a + "}}") + "") : e;
1
+ let i18nInterpolateParams = (e, t)=>t ? (e + "").replace(/\{\{(.*?)\}\}/g, (e, a)=>(t[a.trim()] ?? "{{" + a + "}}") + "") : e;
2
2
 
3
3
  export { i18nInterpolateParams as default, i18nInterpolateParams };
package/package.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "node": "^14.18.0 || >=16.0.0"
6
6
  },
7
7
  "dependencies": {
8
- "@koine/node": "2.0.0-beta.173",
9
- "@koine/utils": "2.0.0-beta.173",
8
+ "@koine/node": "2.0.0-beta.174",
9
+ "@koine/utils": "2.0.0-beta.174",
10
10
  "comment-json": "^4.2.4",
11
11
  "consola": "^3.2.3",
12
12
  "glob": "^11.0.0",
@@ -110,5 +110,5 @@
110
110
  "module": "./index.esm.js",
111
111
  "main": "./index.cjs.js",
112
112
  "types": "./index.esm.d.ts",
113
- "version": "2.0.0-beta.173"
113
+ "version": "2.0.0-beta.174"
114
114
  }