@koine/i18n 2.0.0-beta.185 → 2.0.0-beta.187

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 (57) hide show
  1. package/adapter-js/generators/dictionary.cjs.js +1 -1
  2. package/adapter-js/generators/dictionary.esm.js +1 -1
  3. package/adapter-js/generators/t.cjs.js +5 -2
  4. package/adapter-js/generators/t.esm.js +5 -2
  5. package/adapter-js/generators/to.cjs.js +5 -2
  6. package/adapter-js/generators/to.esm.js +5 -2
  7. package/adapter-next/generators/router-app/I18nLayout.cjs.js +13 -15
  8. package/adapter-next/generators/router-app/I18nLayout.esm.js +13 -15
  9. package/adapter-next/generators/router-app/I18nPage.cjs.js +10 -15
  10. package/adapter-next/generators/router-app/I18nPage.esm.js +10 -15
  11. package/adapter-react/generators/I18nMetadata.cjs.js +2 -2
  12. package/adapter-react/generators/I18nMetadata.esm.js +2 -2
  13. package/adapter-react/generators/I18nRoute.cjs.js +2 -2
  14. package/adapter-react/generators/I18nRoute.esm.js +2 -2
  15. package/adapter-react/generators/I18nTranslate.cjs.js +2 -1
  16. package/adapter-react/generators/I18nTranslate.esm.js +2 -1
  17. package/adapter-react/generators/getT.cjs.js +4 -3
  18. package/adapter-react/generators/getT.esm.js +4 -3
  19. package/adapter-react/generators/getTo.cjs.js +3 -4
  20. package/adapter-react/generators/getTo.esm.js +3 -4
  21. package/adapter-react/generators/locale.cjs.js +91 -0
  22. package/adapter-react/generators/locale.d.ts +30 -0
  23. package/adapter-react/generators/locale.esm.js +89 -0
  24. package/adapter-react/generators/useRouteId.cjs.js +2 -2
  25. package/adapter-react/generators/useRouteId.esm.js +2 -2
  26. package/adapter-react/generators/useTo.cjs.js +2 -2
  27. package/adapter-react/generators/useTo.esm.js +2 -2
  28. package/adapter-react/generators/useToSpa.cjs.js +2 -2
  29. package/adapter-react/generators/useToSpa.esm.js +2 -2
  30. package/adapter-react/index.cjs.js +2 -4
  31. package/adapter-react/index.d.ts +22 -16
  32. package/adapter-react/index.esm.js +10 -12
  33. package/compiler/config.d.ts +2 -2
  34. package/compiler/createAdapter.cjs.js +1 -1
  35. package/compiler/createAdapter.d.ts +3 -0
  36. package/compiler/createAdapter.esm.js +1 -1
  37. package/compiler/functions.cjs.js +2 -2
  38. package/compiler/functions.esm.js +2 -2
  39. package/compiler/summary/generate.cjs.js +11 -8
  40. package/compiler/summary/generate.esm.js +11 -8
  41. package/i18nConsole.cjs.d.ts +2 -0
  42. package/i18nConsole.cjs.default.js +1 -0
  43. package/i18nConsole.cjs.js +10 -0
  44. package/i18nConsole.cjs.mjs +2 -0
  45. package/i18nConsole.d.ts +28 -0
  46. package/i18nConsole.esm.d.ts +2 -0
  47. package/i18nConsole.esm.js +5 -0
  48. package/index.cjs.js +2 -0
  49. package/index.d.ts +1 -0
  50. package/index.esm.js +1 -0
  51. package/package.json +9 -3
  52. package/adapter-react/generators/I18nLocaleContext.cjs.js +0 -69
  53. package/adapter-react/generators/I18nLocaleContext.d.ts +0 -10
  54. package/adapter-react/generators/I18nLocaleContext.esm.js +0 -67
  55. package/adapter-react/generators/getLocale.cjs.js +0 -35
  56. package/adapter-react/generators/getLocale.d.ts +0 -10
  57. package/adapter-react/generators/getLocale.esm.js +0 -33
@@ -11,7 +11,7 @@ var e = createAdapter.createGenerator("js", (o)=>{
11
11
  return e[n] = e[n] || {}, e[n][o] = i, e;
12
12
  }, {}), l = (t)=>utils.changeCaseSnake(t);
13
13
  return Object.keys(c).reduce((e, r)=>{
14
- let o = c[r], n = `dictionary_${r}`, a = dataTranslations.normaliseTranslationTraceIdentifier(r, p);
14
+ let o = c[r], n = `$dictionary_${r}`, a = dataTranslations.normaliseTranslationTraceIdentifier(r, p);
15
15
  return e[n] = {
16
16
  dir: m,
17
17
  name: a,
@@ -9,7 +9,7 @@ var e = createGenerator("js", (o)=>{
9
9
  return e[n] = e[n] || {}, e[n][o] = i, e;
10
10
  }, {}), l = (t)=>changeCaseSnake(t);
11
11
  return Object.keys(c).reduce((e, r)=>{
12
- let o = c[r], n = `dictionary_${r}`, a = normaliseTranslationTraceIdentifier(r, p);
12
+ let o = c[r], n = `$dictionary_${r}`, a = normaliseTranslationTraceIdentifier(r, p);
13
13
  return e[n] = {
14
14
  dir: m,
15
15
  name: a,
@@ -129,13 +129,16 @@ var u = createAdapter.createGenerator("js", (e)=>{
129
129
  name: o,
130
130
  ext: "ts",
131
131
  index: !1,
132
- content: ()=>"" + (imports.ImportsCompiler.outMany("ts", s) + functions.FunctionsCompiler.outMany("ts", i, {
132
+ content: ()=>{
133
+ let e = "";
134
+ return e += imports.ImportsCompiler.outMany("ts", s), e += functions.FunctionsCompiler.outMany("ts", i, {
133
135
  imports: !1,
134
136
  exports: "named",
135
137
  style: "function",
136
138
  comments: !0,
137
139
  pure: !0
138
- }))
140
+ });
141
+ }
139
142
  }
140
143
  };
141
144
  });
@@ -125,13 +125,16 @@ var u = createGenerator("js", (e)=>{
125
125
  name: o,
126
126
  ext: "ts",
127
127
  index: !1,
128
- content: ()=>"" + (ImportsCompiler.outMany("ts", s) + FunctionsCompiler.outMany("ts", i, {
128
+ content: ()=>{
129
+ let e = "";
130
+ return e += ImportsCompiler.outMany("ts", s), e += FunctionsCompiler.outMany("ts", i, {
129
131
  imports: !1,
130
132
  exports: "named",
131
133
  style: "function",
132
134
  comments: !0,
133
135
  pure: !0
134
- }))
136
+ });
137
+ }
135
138
  }
136
139
  };
137
140
  });
@@ -103,13 +103,16 @@ var I = createAdapter.createGenerator("js", (t)=>{
103
103
  name: i,
104
104
  ext: "ts",
105
105
  index: !1,
106
- content: ()=>"" + (imports.ImportsCompiler.outMany("ts", d) + functions.FunctionsCompiler.outMany("ts", u, {
106
+ content: ()=>{
107
+ let t = "";
108
+ return t += imports.ImportsCompiler.outMany("ts", d), t += functions.FunctionsCompiler.outMany("ts", u, {
107
109
  imports: !1,
108
110
  exports: "named",
109
111
  style: "function",
110
112
  comments: !0,
111
113
  pure: !0
112
- }))
114
+ });
115
+ }
113
116
  }
114
117
  };
115
118
  }(t),
@@ -99,13 +99,16 @@ var I = createGenerator("js", (t)=>{
99
99
  name: i,
100
100
  ext: "ts",
101
101
  index: !1,
102
- content: ()=>"" + (ImportsCompiler.outMany("ts", d) + FunctionsCompiler.outMany("ts", u, {
102
+ content: ()=>{
103
+ let t = "";
104
+ return t += ImportsCompiler.outMany("ts", d), t += FunctionsCompiler.outMany("ts", u, {
103
105
  imports: !1,
104
106
  exports: "named",
105
107
  style: "function",
106
108
  comments: !0,
107
109
  pure: !0
108
- }))
110
+ });
111
+ }
109
112
  }
110
113
  };
111
114
  }(t),
@@ -14,15 +14,14 @@ var a = createAdapter.createGenerator("next", (e)=>{
14
14
  content: ()=>`
15
15
  import React from "react";
16
16
  import type { Metadata } from "next/types";
17
- import { i18nRtlLocales } from "@koine/i18n";
17
+ import { i18nConsole, i18nRtlLocales } from "@koine/i18n";
18
18
  import { getI18nDictionaries } from "../internal/getI18nDictionaries";
19
19
  import { I18nTranslateProvider } from "../I18nTranslateProvider";
20
- import { defaultLocale } from "../defaultLocale";
21
20
  import { locales } from "../locales";
22
21
  import type { I18n } from "../types";
23
22
  import { getLocale } from "./getLocale";
24
23
  import { I18nLayoutRoot } from "./I18nLayoutRoot";
25
- import { I18nLocaleContext } from "./I18nLocaleContext";
24
+ import { setLocale } from "./setLocale";
26
25
 
27
26
  export type I18nLayoutProps = React.PropsWithChildren<Configurator>;
28
27
 
@@ -41,17 +40,13 @@ export const I18nLayout = async ({
41
40
  locale = locale || getLocale();
42
41
  const dictionaries = await getI18nDictionaries({ locale, namespaces });
43
42
 
44
- I18nLocaleContext.set(locale);
45
-
46
43
  return (
47
- <I18nLocaleContext.Provider value={locale}>
48
- <I18nTranslateProvider
49
- locale={locale}
50
- dictionaries={dictionaries}
51
- >
52
- {children}
53
- </I18nTranslateProvider>
54
- </I18nLocaleContext.Provider>
44
+ <I18nTranslateProvider
45
+ locale={locale}
46
+ dictionaries={dictionaries}
47
+ >
48
+ {children}
49
+ </I18nTranslateProvider>
55
50
  );
56
51
  };
57
52
 
@@ -153,7 +148,7 @@ export const createI18nLayout = <
153
148
  | Configurator,
154
149
  ) => {
155
150
  const resolveConfigurator = async (props: I18n.Props<TProps>) => {
156
- const localeParam = props.params?.${a};
151
+ const localeParam = props.params?.${a};${createAdapter.createGenerator.log(e, "createI18nLayout", "resolveConfigurator", "localeParam")}
157
152
  const config = configurator
158
153
  ? typeof configurator === "function"
159
154
  ? await configurator(props, localeParam)
@@ -161,6 +156,9 @@ export const createI18nLayout = <
161
156
  : null;
162
157
  const { locale: localeConfig, ...restConfig } = config || {};
163
158
  const locale = localeConfig || getLocale();
159
+
160
+ setLocale(locale);
161
+
164
162
  return { ...restConfig, locale };
165
163
  };
166
164
 
@@ -200,7 +198,7 @@ export const createI18nLayout = <
200
198
  ) => {
201
199
  return async (props: I18n.Props<TProps>) => {
202
200
  const config = await resolveConfigurator(props);
203
- const { locale } = config;
201
+ const { locale } = config;${createAdapter.createGenerator.log(e, "layout.default", "resolveConfigurator", "locale")}
204
202
  const dir = i18nRtlLocales.includes(locale) ? "rtl" : "ltr";
205
203
  const i18nHtmlAttrs = { lang: locale, dir };
206
204
  const I18nScript = (
@@ -12,15 +12,14 @@ var a = createGenerator("next", (e)=>{
12
12
  content: ()=>`
13
13
  import React from "react";
14
14
  import type { Metadata } from "next/types";
15
- import { i18nRtlLocales } from "@koine/i18n";
15
+ import { i18nConsole, i18nRtlLocales } from "@koine/i18n";
16
16
  import { getI18nDictionaries } from "../internal/getI18nDictionaries";
17
17
  import { I18nTranslateProvider } from "../I18nTranslateProvider";
18
- import { defaultLocale } from "../defaultLocale";
19
18
  import { locales } from "../locales";
20
19
  import type { I18n } from "../types";
21
20
  import { getLocale } from "./getLocale";
22
21
  import { I18nLayoutRoot } from "./I18nLayoutRoot";
23
- import { I18nLocaleContext } from "./I18nLocaleContext";
22
+ import { setLocale } from "./setLocale";
24
23
 
25
24
  export type I18nLayoutProps = React.PropsWithChildren<Configurator>;
26
25
 
@@ -39,17 +38,13 @@ export const I18nLayout = async ({
39
38
  locale = locale || getLocale();
40
39
  const dictionaries = await getI18nDictionaries({ locale, namespaces });
41
40
 
42
- I18nLocaleContext.set(locale);
43
-
44
41
  return (
45
- <I18nLocaleContext.Provider value={locale}>
46
- <I18nTranslateProvider
47
- locale={locale}
48
- dictionaries={dictionaries}
49
- >
50
- {children}
51
- </I18nTranslateProvider>
52
- </I18nLocaleContext.Provider>
42
+ <I18nTranslateProvider
43
+ locale={locale}
44
+ dictionaries={dictionaries}
45
+ >
46
+ {children}
47
+ </I18nTranslateProvider>
53
48
  );
54
49
  };
55
50
 
@@ -151,7 +146,7 @@ export const createI18nLayout = <
151
146
  | Configurator,
152
147
  ) => {
153
148
  const resolveConfigurator = async (props: I18n.Props<TProps>) => {
154
- const localeParam = props.params?.${a};
149
+ const localeParam = props.params?.${a};${createGenerator.log(e, "createI18nLayout", "resolveConfigurator", "localeParam")}
155
150
  const config = configurator
156
151
  ? typeof configurator === "function"
157
152
  ? await configurator(props, localeParam)
@@ -159,6 +154,9 @@ export const createI18nLayout = <
159
154
  : null;
160
155
  const { locale: localeConfig, ...restConfig } = config || {};
161
156
  const locale = localeConfig || getLocale();
157
+
158
+ setLocale(locale);
159
+
162
160
  return { ...restConfig, locale };
163
161
  };
164
162
 
@@ -198,7 +196,7 @@ export const createI18nLayout = <
198
196
  ) => {
199
197
  return async (props: I18n.Props<TProps>) => {
200
198
  const config = await resolveConfigurator(props);
201
- const { locale } = config;
199
+ const { locale } = config;${createGenerator.log(e, "layout.default", "resolveConfigurator", "locale")}
202
200
  const dir = i18nRtlLocales.includes(locale) ? "rtl" : "ltr";
203
201
  const i18nHtmlAttrs = { lang: locale, dir };
204
202
  const I18nScript = (
@@ -2,8 +2,8 @@
2
2
 
3
3
  var createAdapter = require('../../../compiler/createAdapter.cjs.js');
4
4
 
5
- var n = createAdapter.createGenerator("next", (t)=>{
6
- let { config: { single: a }, options: { routes: { localeParamName: o } } } = t;
5
+ var n = createAdapter.createGenerator("next", (a)=>{
6
+ let { config: { single: t }, options: { routes: { localeParamName: o } } } = a;
7
7
  return {
8
8
  I18nPage: {
9
9
  dir: createAdapter.createGenerator.dirs.server,
@@ -14,7 +14,7 @@ var n = createAdapter.createGenerator("next", (t)=>{
14
14
  import React from "react";
15
15
  import { notFound } from "next/navigation";
16
16
  import type { Metadata } from "next/types";
17
- import { defaultLocale } from "../defaultLocale";
17
+ import { i18nConsole } from "@koine/i18n";
18
18
  import { I18nTranslateProvider } from "../I18nTranslateProvider";
19
19
  import { isLocale } from "../isLocale";
20
20
  import { locales } from "../locales";
@@ -24,12 +24,12 @@ import { getI18nMetadata } from "../internal/getI18nMetadata";
24
24
  import { I18nMetadataSetter } from "../internal/I18nMetadataSetter";
25
25
  import { I18nRouteSetter } from "../internal/I18nRouteSetter";
26
26
  import { getLocale } from "./getLocale";
27
- import { I18nLocaleContext } from "./I18nLocaleContext";
27
+ import { setLocale } from "./setLocale";
28
28
 
29
29
  export type I18nPageProps<TRouteId extends I18n.RouteId> =
30
30
  React.PropsWithChildren<
31
31
  {
32
- ${a ? "" : `/**
32
+ ${t ? "" : `/**
33
33
  * Optionally set this manually to override the current locale
34
34
  */
35
35
  locale?: I18n.Locale;
@@ -112,14 +112,9 @@ function pageInit(paramsOrProps: I18n.Props["params"] | I18n.Props) {
112
112
  const locale = (params as any).${o};
113
113
 
114
114
  if (isLocale(locale)) {
115
- ${a ? "" : `
116
- // set the server context based locale as early as possible, usually this
117
- // function is called as first thing in the page components. Setting the
118
- // locale here might help reducing the cases where a 't' function needed
119
- // in those "root" page components is obtained by calling 'getT' without
120
- // passing a 'locale' argument. Passing the 'locale' should not be needed
121
- // actually, but...
122
- I18nLocaleContext.set(locale);
115
+ ${t ? "" : `
116
+ // set the server context based locale as early as possible
117
+ setLocale(locale);
123
118
  `}return locale;
124
119
  }
125
120
  }
@@ -238,7 +233,7 @@ export const createI18nPage = <
238
233
  | TConfig,
239
234
  ) => {
240
235
  const resolveConfigurator = async (props: I18n.Props<TProps>) => {
241
- const localeParam = pageInit(props);
236
+ const localeParam = pageInit(props);${createAdapter.createGenerator.log(a, "createI18nPage", "resolveConfigurator", "localeParam")}
242
237
  const config =
243
238
  typeof configurator === "function"
244
239
  ? await configurator(props, localeParam)
@@ -272,7 +267,7 @@ export const createI18nPage = <
272
267
  ) => React.ReactNode | Promise<React.ReactNode>,
273
268
  ) => {
274
269
  return async (props: I18n.Props<TProps>) => {
275
- const { locale, route, namespaces } = await resolveConfigurator(props);
270
+ const { locale, route, namespaces } = await resolveConfigurator(props);${createAdapter.createGenerator.log(a, "page.default", "resolveConfigurator", "locale")}
276
271
  const render = await impl({ locale, route, ...props });
277
272
  return (
278
273
  <I18nPage
@@ -1,7 +1,7 @@
1
1
  import { createGenerator } from '../../../compiler/createAdapter.esm.js';
2
2
 
3
- var n = createGenerator("next", (t)=>{
4
- let { config: { single: a }, options: { routes: { localeParamName: o } } } = t;
3
+ var n = createGenerator("next", (a)=>{
4
+ let { config: { single: t }, options: { routes: { localeParamName: o } } } = a;
5
5
  return {
6
6
  I18nPage: {
7
7
  dir: createGenerator.dirs.server,
@@ -12,7 +12,7 @@ var n = createGenerator("next", (t)=>{
12
12
  import React from "react";
13
13
  import { notFound } from "next/navigation";
14
14
  import type { Metadata } from "next/types";
15
- import { defaultLocale } from "../defaultLocale";
15
+ import { i18nConsole } from "@koine/i18n";
16
16
  import { I18nTranslateProvider } from "../I18nTranslateProvider";
17
17
  import { isLocale } from "../isLocale";
18
18
  import { locales } from "../locales";
@@ -22,12 +22,12 @@ import { getI18nMetadata } from "../internal/getI18nMetadata";
22
22
  import { I18nMetadataSetter } from "../internal/I18nMetadataSetter";
23
23
  import { I18nRouteSetter } from "../internal/I18nRouteSetter";
24
24
  import { getLocale } from "./getLocale";
25
- import { I18nLocaleContext } from "./I18nLocaleContext";
25
+ import { setLocale } from "./setLocale";
26
26
 
27
27
  export type I18nPageProps<TRouteId extends I18n.RouteId> =
28
28
  React.PropsWithChildren<
29
29
  {
30
- ${a ? "" : `/**
30
+ ${t ? "" : `/**
31
31
  * Optionally set this manually to override the current locale
32
32
  */
33
33
  locale?: I18n.Locale;
@@ -110,14 +110,9 @@ function pageInit(paramsOrProps: I18n.Props["params"] | I18n.Props) {
110
110
  const locale = (params as any).${o};
111
111
 
112
112
  if (isLocale(locale)) {
113
- ${a ? "" : `
114
- // set the server context based locale as early as possible, usually this
115
- // function is called as first thing in the page components. Setting the
116
- // locale here might help reducing the cases where a 't' function needed
117
- // in those "root" page components is obtained by calling 'getT' without
118
- // passing a 'locale' argument. Passing the 'locale' should not be needed
119
- // actually, but...
120
- I18nLocaleContext.set(locale);
113
+ ${t ? "" : `
114
+ // set the server context based locale as early as possible
115
+ setLocale(locale);
121
116
  `}return locale;
122
117
  }
123
118
  }
@@ -236,7 +231,7 @@ export const createI18nPage = <
236
231
  | TConfig,
237
232
  ) => {
238
233
  const resolveConfigurator = async (props: I18n.Props<TProps>) => {
239
- const localeParam = pageInit(props);
234
+ const localeParam = pageInit(props);${createGenerator.log(a, "createI18nPage", "resolveConfigurator", "localeParam")}
240
235
  const config =
241
236
  typeof configurator === "function"
242
237
  ? await configurator(props, localeParam)
@@ -270,7 +265,7 @@ export const createI18nPage = <
270
265
  ) => React.ReactNode | Promise<React.ReactNode>,
271
266
  ) => {
272
267
  return async (props: I18n.Props<TProps>) => {
273
- const { locale, route, namespaces } = await resolveConfigurator(props);
268
+ const { locale, route, namespaces } = await resolveConfigurator(props);${createGenerator.log(a, "page.default", "resolveConfigurator", "locale")}
274
269
  const render = await impl({ locale, route, ...props });
275
270
  return (
276
271
  <I18nPage
@@ -2,7 +2,7 @@
2
2
 
3
3
  var createAdapter = require('../../compiler/createAdapter.cjs.js');
4
4
 
5
- var m = createAdapter.createGenerator("react", (e)=>({
5
+ var a = createAdapter.createGenerator("react", (e)=>({
6
6
  I18nMetadataContext: {
7
7
  dir: createAdapter.createGenerator.dirs.internal,
8
8
  name: "I18nMetadataContext",
@@ -139,4 +139,4 @@ export default useI18nSwitch;
139
139
  }
140
140
  }));
141
141
 
142
- module.exports = m;
142
+ module.exports = a;
@@ -1,6 +1,6 @@
1
1
  import { createGenerator } from '../../compiler/createAdapter.esm.js';
2
2
 
3
- var m = createGenerator("react", (e)=>({
3
+ var a = createGenerator("react", (e)=>({
4
4
  I18nMetadataContext: {
5
5
  dir: createGenerator.dirs.internal,
6
6
  name: "I18nMetadataContext",
@@ -137,4 +137,4 @@ export default useI18nSwitch;
137
137
  }
138
138
  }));
139
139
 
140
- export { m as default };
140
+ export { a as default };
@@ -2,7 +2,7 @@
2
2
 
3
3
  var createAdapter = require('../../compiler/createAdapter.cjs.js');
4
4
 
5
- var n = createAdapter.createGenerator("react", (e)=>({
5
+ var m = createAdapter.createGenerator("react", (e)=>({
6
6
  I18nRouteContext: {
7
7
  dir: createAdapter.createGenerator.dirs.internal,
8
8
  name: "I18nRouteContext",
@@ -100,4 +100,4 @@ export const I18nRouteSetter = (props: I18nRouteSetterProps) => {
100
100
  }
101
101
  }));
102
102
 
103
- module.exports = n;
103
+ module.exports = m;
@@ -1,6 +1,6 @@
1
1
  import { createGenerator } from '../../compiler/createAdapter.esm.js';
2
2
 
3
- var n = createGenerator("react", (e)=>({
3
+ var m = createGenerator("react", (e)=>({
4
4
  I18nRouteContext: {
5
5
  dir: createGenerator.dirs.internal,
6
6
  name: "I18nRouteContext",
@@ -98,4 +98,4 @@ export const I18nRouteSetter = (props: I18nRouteSetterProps) => {
98
98
  }
99
99
  }));
100
100
 
101
- export { n as default };
101
+ export { m as default };
@@ -43,6 +43,7 @@ export const I18nTranslateContext = createContext<I18nTranslateContextValue>({
43
43
  "use client";
44
44
 
45
45
  import React, { useContext } from "react";
46
+ import { i18nConsole, type I18nUtils } from "@koine/i18n";
46
47
  import { I18nTranslateContext } from "./internal/I18nTranslateContext";
47
48
  import { setGlobalLocale } from "./internal/setGlobalLocale";
48
49
  import { createT } from "./createT";
@@ -68,7 +69,7 @@ export const I18nTranslateProvider = ({
68
69
  // (the "rsc" webpack layer), while here we set it in a client component (the
69
70
  // "ssr" webpack layer) making the locale available in all client components
70
71
  // and in the webpack-define implementation
71
- setGlobalLocale(locale);
72
+ setGlobalLocale(locale);${createAdapter.createGenerator.log(t, "I18nTranslateProvider", "setGlobalLocale", "locale")}
72
73
 
73
74
  const parentCtx = useContext(I18nTranslateContext);
74
75
  const _d = { ...parentCtx._d, ...dictionaries };
@@ -41,6 +41,7 @@ export const I18nTranslateContext = createContext<I18nTranslateContextValue>({
41
41
  "use client";
42
42
 
43
43
  import React, { useContext } from "react";
44
+ import { i18nConsole, type I18nUtils } from "@koine/i18n";
44
45
  import { I18nTranslateContext } from "./internal/I18nTranslateContext";
45
46
  import { setGlobalLocale } from "./internal/setGlobalLocale";
46
47
  import { createT } from "./createT";
@@ -66,7 +67,7 @@ export const I18nTranslateProvider = ({
66
67
  // (the "rsc" webpack layer), while here we set it in a client component (the
67
68
  // "ssr" webpack layer) making the locale available in all client components
68
69
  // and in the webpack-define implementation
69
- setGlobalLocale(locale);
70
+ setGlobalLocale(locale);${createGenerator.log(t, "I18nTranslateProvider", "setGlobalLocale", "locale")}
70
71
 
71
72
  const parentCtx = useContext(I18nTranslateContext);
72
73
  const _d = { ...parentCtx._d, ...dictionaries };
@@ -2,13 +2,14 @@
2
2
 
3
3
  var createAdapter = require('../../compiler/createAdapter.cjs.js');
4
4
 
5
- var g = createAdapter.createGenerator("react", (e)=>({
5
+ var f = createAdapter.createGenerator("react", (e)=>({
6
6
  getT: {
7
7
  dir: createAdapter.createGenerator.dirs.server,
8
8
  name: "getT",
9
9
  ext: "ts",
10
10
  index: !0,
11
11
  content: ()=>`
12
+ import { i18nConsole } from "@koine/i18n";
12
13
  import { loadTranslations } from "../internal/loadTranslations";
13
14
  import { createT } from "../createT";
14
15
  import type { I18n } from "../types";
@@ -34,7 +35,7 @@ export async function getT<TNamespace extends I18n.TranslationsNamespace>(
34
35
  // _namespace?: TNamespace,
35
36
  ) {
36
37
  const locale = args.length === 1 ? getLocale() : (args[0] as I18n.Locale);
37
- const namespace = args[1] || (args[0] as TNamespace);
38
+ const namespace = args[1] || (args[0] as TNamespace);${createAdapter.createGenerator.log(e, "getT", "", "{ locale, namespace }")}
38
39
  const translations = await loadTranslations(locale, namespace);
39
40
  const t = createT({ [namespace]: translations }, locale);
40
41
 
@@ -50,4 +51,4 @@ export default getT;
50
51
  }
51
52
  }));
52
53
 
53
- module.exports = g;
54
+ module.exports = f;
@@ -1,12 +1,13 @@
1
1
  import { createGenerator } from '../../compiler/createAdapter.esm.js';
2
2
 
3
- var g = createGenerator("react", (e)=>({
3
+ var f = createGenerator("react", (e)=>({
4
4
  getT: {
5
5
  dir: createGenerator.dirs.server,
6
6
  name: "getT",
7
7
  ext: "ts",
8
8
  index: !0,
9
9
  content: ()=>`
10
+ import { i18nConsole } from "@koine/i18n";
10
11
  import { loadTranslations } from "../internal/loadTranslations";
11
12
  import { createT } from "../createT";
12
13
  import type { I18n } from "../types";
@@ -32,7 +33,7 @@ export async function getT<TNamespace extends I18n.TranslationsNamespace>(
32
33
  // _namespace?: TNamespace,
33
34
  ) {
34
35
  const locale = args.length === 1 ? getLocale() : (args[0] as I18n.Locale);
35
- const namespace = args[1] || (args[0] as TNamespace);
36
+ const namespace = args[1] || (args[0] as TNamespace);${createGenerator.log(e, "getT", "", "{ locale, namespace }")}
36
37
  const translations = await loadTranslations(locale, namespace);
37
38
  const t = createT({ [namespace]: translations }, locale);
38
39
 
@@ -48,4 +49,4 @@ export default getT;
48
49
  }
49
50
  }));
50
51
 
51
- export { g as default };
52
+ export { f as default };
@@ -2,7 +2,7 @@
2
2
 
3
3
  var createAdapter = require('../../compiler/createAdapter.cjs.js');
4
4
 
5
- var i = createAdapter.createGenerator("react", (t)=>{
5
+ var g = createAdapter.createGenerator("react", (t)=>{
6
6
  let { routes: { dynamicRoutes: o } } = t;
7
7
  return {
8
8
  getTo: {
@@ -20,8 +20,7 @@ import { getLocale } from "./getLocale";
20
20
  /**
21
21
  * **For React RSC only**
22
22
  *
23
- * By default it grabs the current locale from NodeJS' \`AsyncLocalStorage\`
24
- * implementation used in \`I18nLocaleContext\`.
23
+ * @param {locale} By default it uses the current locale
25
24
  */
26
25
  export function getTo(locale = getLocale()) {
27
26
  return <Id extends I18n.RouteId>(
@@ -43,4 +42,4 @@ export default getTo;
43
42
  };
44
43
  });
45
44
 
46
- module.exports = i;
45
+ module.exports = g;
@@ -1,6 +1,6 @@
1
1
  import { createGenerator } from '../../compiler/createAdapter.esm.js';
2
2
 
3
- var i = createGenerator("react", (t)=>{
3
+ var g = createGenerator("react", (t)=>{
4
4
  let { routes: { dynamicRoutes: o } } = t;
5
5
  return {
6
6
  getTo: {
@@ -18,8 +18,7 @@ import { getLocale } from "./getLocale";
18
18
  /**
19
19
  * **For React RSC only**
20
20
  *
21
- * By default it grabs the current locale from NodeJS' \`AsyncLocalStorage\`
22
- * implementation used in \`I18nLocaleContext\`.
21
+ * @param {locale} By default it uses the current locale
23
22
  */
24
23
  export function getTo(locale = getLocale()) {
25
24
  return <Id extends I18n.RouteId>(
@@ -41,4 +40,4 @@ export default getTo;
41
40
  };
42
41
  });
43
42
 
44
- export { i as default };
43
+ export { g as default };