@koine/i18n 2.0.0-beta.128 → 2.0.0-beta.129

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 (48) hide show
  1. package/adapter-js/generators/getI18nDictionaries_inline.cjs.js +0 -1
  2. package/adapter-js/generators/getI18nDictionaries_inline.esm.js +0 -1
  3. package/adapter-js/generators/loadTranslations_inline.cjs.js +0 -1
  4. package/adapter-js/generators/loadTranslations_inline.esm.js +0 -1
  5. package/adapter-next/generators/I18nLayout.cjs.js +57 -31
  6. package/adapter-next/generators/I18nLayout.esm.js +57 -31
  7. package/adapter-next/generators/I18nPage.cjs.js +72 -30
  8. package/adapter-next/generators/I18nPage.esm.js +72 -30
  9. package/adapter-next/redirects.cjs.js +11 -11
  10. package/adapter-next/redirects.esm.js +11 -11
  11. package/adapter-next/rewrites.cjs.js +23 -23
  12. package/adapter-next/rewrites.esm.js +23 -23
  13. package/compiler/code/data-routes.cjs.js +1 -1
  14. package/compiler/code/data-routes.esm.js +1 -1
  15. package/formatRoutePathname.cjs.d.ts +2 -0
  16. package/formatRoutePathname.cjs.default.js +1 -0
  17. package/formatRoutePathname.cjs.mjs +2 -0
  18. package/formatRoutePathname.esm.d.ts +2 -0
  19. package/index.cjs.js +5 -3
  20. package/index.d.ts +4 -1
  21. package/index.esm.js +4 -3
  22. package/interpolateTo.cjs.d.ts +2 -0
  23. package/interpolateTo.cjs.default.js +1 -0
  24. package/interpolateTo.cjs.mjs +2 -0
  25. package/{client/interpolateTo.d.ts → interpolateTo.d.ts} +1 -1
  26. package/interpolateTo.esm.d.ts +2 -0
  27. package/package.json +27 -3
  28. package/routeHasDynamicPortion.cjs.d.ts +2 -0
  29. package/routeHasDynamicPortion.cjs.default.js +1 -0
  30. package/routeHasDynamicPortion.cjs.mjs +2 -0
  31. package/routeHasDynamicPortion.esm.d.ts +2 -0
  32. package/rtlLocales.cjs.d.ts +2 -0
  33. package/rtlLocales.cjs.default.js +1 -0
  34. package/rtlLocales.cjs.js +55 -0
  35. package/rtlLocales.cjs.mjs +2 -0
  36. package/rtlLocales.d.ts +2 -0
  37. package/rtlLocales.esm.d.ts +2 -0
  38. package/rtlLocales.esm.js +50 -0
  39. package/adapter-next/generators/__________I18nLayoutLang.d.ts +0 -10
  40. package/client/index.d.ts +0 -3
  41. /package/{client/formatRoutePathname.cjs.js → formatRoutePathname.cjs.js} +0 -0
  42. /package/{client/formatRoutePathname.d.ts → formatRoutePathname.d.ts} +0 -0
  43. /package/{client/formatRoutePathname.esm.js → formatRoutePathname.esm.js} +0 -0
  44. /package/{client/interpolateTo.cjs.js → interpolateTo.cjs.js} +0 -0
  45. /package/{client/interpolateTo.esm.js → interpolateTo.esm.js} +0 -0
  46. /package/{client/routeHasDynamicPortion.cjs.js → routeHasDynamicPortion.cjs.js} +0 -0
  47. /package/{client/routeHasDynamicPortion.d.ts → routeHasDynamicPortion.d.ts} +0 -0
  48. /package/{client/routeHasDynamicPortion.esm.js → routeHasDynamicPortion.esm.js} +0 -0
@@ -2,7 +2,6 @@
2
2
 
3
3
  var loadTranslations_inline = require('./loadTranslations_inline.cjs.js');
4
4
 
5
- // import type { I18nCompiler } from "../../compiler/types";
6
5
  /**
7
6
  * @requires {defaultLocale, I18n}
8
7
  */ const getI18nDictionaries_inline = (n, i)=>`
@@ -1,6 +1,5 @@
1
1
  import { loadTranslations_inline } from './loadTranslations_inline.esm.js';
2
2
 
3
- // import type { I18nCompiler } from "../../compiler/types";
4
3
  /**
5
4
  * @requires {defaultLocale, I18n}
6
5
  */ const getI18nDictionaries_inline = (n, i)=>`
@@ -2,7 +2,6 @@
2
2
 
3
3
  var helpers = require('../../compiler/helpers.cjs.js');
4
4
 
5
- // import type { I18nCompiler } from "../../compiler/types";
6
5
  const loadTranslations_inline = (e)=>/* js */ `const loadTranslations = (
7
6
  locale: I18n.Locale,
8
7
  namespace: I18n.TranslateNamespace,
@@ -1,6 +1,5 @@
1
1
  import { getTranslationsDir } from '../../compiler/helpers.esm.js';
2
2
 
3
- // import type { I18nCompiler } from "../../compiler/types";
4
3
  const loadTranslations_inline = (e)=>/* js */ `const loadTranslations = (
5
4
  locale: I18n.Locale,
6
5
  namespace: I18n.TranslateNamespace,
@@ -13,6 +13,8 @@ var m = createAdapter.createGenerator("next", (t)=>{
13
13
  // index: true,
14
14
  content: ()=>/* js */ `
15
15
  import React from "react";
16
+ import type { Metadata } from "next/types";
17
+ import { rtlLocales } from "@koine/i18n";
16
18
  // import { getI18nDictionaries } from "../getI18nDictionaries";
17
19
  import { defaultLocale } from "../defaultLocale";
18
20
  import { I18nTranslateProvider } from "../I18nTranslateProvider";
@@ -20,7 +22,6 @@ import { locales } from "../locales";
20
22
  import type { I18n } from "../types";
21
23
  import { getLocale } from "./getLocale";
22
24
  import { I18nLayoutRoot } from "./I18nLayoutRoot";
23
- // import { I18nNotFound } from "./I18nNotFound";
24
25
  import { I18nLocaleContext } from "./I18nLocaleContext";
25
26
  ${getI18nDictionaries_inline.getI18nDictionaries_inline(1)}
26
27
 
@@ -79,50 +80,75 @@ type Configurator = {
79
80
  * @example
80
81
  *
81
82
  * \`\`\`
82
- * type Props = {
83
- * params: {
84
- * slug: string;
85
- * };
86
- * };
83
+ * const layout = i18nServer.layout({
84
+ * namespaces: ["dashboard"],
85
+ * });
87
86
  *
88
- * const i18nLayout = i18nServer.layout<Props>(async (_props, _locale) => {
87
+ * // or as a function (async supported):
88
+ * type Props = { params: { slug: string; }; };
89
+ *
90
+ * const layout = i18nServer.layout((props: Props, locale) => {
89
91
  * return {
90
92
  * namespaces: ["dashboard"],
91
93
  * };
92
94
  * });
93
95
  * \`\`\`
94
96
  */
95
- export const createI18nLayout = <TProps extends {}>(
96
- configurator?: (props: I18n.Props & TProps, locale: I18n.Locale) => Configurator | Promise<Configurator>
97
+ export const createI18nLayout = <
98
+ TProps extends {},
99
+ >(
100
+ configurator?:
101
+ | ((
102
+ props: I18n.Props<TProps>,
103
+ locale: I18n.Locale,
104
+ ) => Configurator | Promise<Configurator>)
105
+ | Configurator,
97
106
  ) => {
107
+ const resolveConfigurator = async (props: I18n.Props<TProps>) => {
108
+ const localeParam = props.params?.${e};
109
+ const config = configurator
110
+ ? typeof configurator === "function"
111
+ ? await configurator(props, localeParam)
112
+ : configurator
113
+ : null;
114
+ const { locale: localeConfig, ...restConfig } = config || {};
115
+ const locale = localeConfig || getLocale();
116
+ return { ...restConfig, locale };
117
+ };
118
+
98
119
  return {
99
- notFound: () => {
100
- // <I18nNotFound />
101
- },
102
- generateStaticParams: () => {
103
- return locales.map((l) => ({ ${e}: l }));
120
+ generateStaticParams: () => locales.map((l) => ({ ${e}: l })),
121
+ generateMetadata: (
122
+ impl: (
123
+ props: TProps & { locale: I18n.Locale },
124
+ ) => Metadata | Promise<Metadata>,
125
+ ) => {
126
+ return async (props: I18n.Props<TProps>): Promise<Metadata> => {
127
+ const { locale } = await resolveConfigurator(props);
128
+ const metadata = await impl({ locale, ...props });
129
+ return metadata;
130
+ };
104
131
  },
105
132
  default: (
106
133
  impl: (
107
- props: I18n.Props<
108
- TProps & React.PropsWithChildren<{
109
- i18nHtmlAttrs: Pick<React.ComponentPropsWithoutRef<"html">, "lang" | "dir">
110
- }>
111
- >,
112
- locale: I18n.Locale
113
- ) => React.ReactNode | Promise<React.ReactNode>
134
+ props: TProps & { locale: I18n.Locale } & React.PropsWithChildren<{
135
+ i18nHtmlAttrs: Pick<
136
+ React.ComponentPropsWithoutRef<"html">,
137
+ "lang" | "dir"
138
+ >;
139
+ }>,
140
+ ) => React.ReactNode | Promise<React.ReactNode>,
114
141
  ) => {
115
142
  return async (props: I18n.Props<TProps>) => {
116
- // const locale = props.params.${e};
117
- const locale = getLocale();
118
- // TODO: determine "dir" dynamically
119
- const i18nHtmlAttrs = { lang: locale, dir: "ltr" };
120
- const options = configurator ? await configurator(props, locale) : {};
121
- const inner = await impl({ ...props, i18nHtmlAttrs }, locale);
122
- return (<I18nLayout {...options}>{inner}</I18nLayout>);
123
- }
124
- }
125
- }
143
+ const config = await resolveConfigurator(props);
144
+ const { locale } = config;
145
+ const dir = rtlLocales.includes(locale) ? "rtl" : "ltr";
146
+ const i18nHtmlAttrs = { lang: locale, dir };
147
+ const render = await impl({ locale, i18nHtmlAttrs, ...props });
148
+ return <I18nLayout {...config}>{render}</I18nLayout>;
149
+ };
150
+ },
151
+ };
126
152
  };
127
153
 
128
154
  createI18nLayout.Root = I18nLayoutRoot;
@@ -11,6 +11,8 @@ var m = createGenerator("next", (t)=>{
11
11
  // index: true,
12
12
  content: ()=>/* js */ `
13
13
  import React from "react";
14
+ import type { Metadata } from "next/types";
15
+ import { rtlLocales } from "@koine/i18n";
14
16
  // import { getI18nDictionaries } from "../getI18nDictionaries";
15
17
  import { defaultLocale } from "../defaultLocale";
16
18
  import { I18nTranslateProvider } from "../I18nTranslateProvider";
@@ -18,7 +20,6 @@ import { locales } from "../locales";
18
20
  import type { I18n } from "../types";
19
21
  import { getLocale } from "./getLocale";
20
22
  import { I18nLayoutRoot } from "./I18nLayoutRoot";
21
- // import { I18nNotFound } from "./I18nNotFound";
22
23
  import { I18nLocaleContext } from "./I18nLocaleContext";
23
24
  ${getI18nDictionaries_inline(1)}
24
25
 
@@ -77,50 +78,75 @@ type Configurator = {
77
78
  * @example
78
79
  *
79
80
  * \`\`\`
80
- * type Props = {
81
- * params: {
82
- * slug: string;
83
- * };
84
- * };
81
+ * const layout = i18nServer.layout({
82
+ * namespaces: ["dashboard"],
83
+ * });
85
84
  *
86
- * const i18nLayout = i18nServer.layout<Props>(async (_props, _locale) => {
85
+ * // or as a function (async supported):
86
+ * type Props = { params: { slug: string; }; };
87
+ *
88
+ * const layout = i18nServer.layout((props: Props, locale) => {
87
89
  * return {
88
90
  * namespaces: ["dashboard"],
89
91
  * };
90
92
  * });
91
93
  * \`\`\`
92
94
  */
93
- export const createI18nLayout = <TProps extends {}>(
94
- configurator?: (props: I18n.Props & TProps, locale: I18n.Locale) => Configurator | Promise<Configurator>
95
+ export const createI18nLayout = <
96
+ TProps extends {},
97
+ >(
98
+ configurator?:
99
+ | ((
100
+ props: I18n.Props<TProps>,
101
+ locale: I18n.Locale,
102
+ ) => Configurator | Promise<Configurator>)
103
+ | Configurator,
95
104
  ) => {
105
+ const resolveConfigurator = async (props: I18n.Props<TProps>) => {
106
+ const localeParam = props.params?.${e};
107
+ const config = configurator
108
+ ? typeof configurator === "function"
109
+ ? await configurator(props, localeParam)
110
+ : configurator
111
+ : null;
112
+ const { locale: localeConfig, ...restConfig } = config || {};
113
+ const locale = localeConfig || getLocale();
114
+ return { ...restConfig, locale };
115
+ };
116
+
96
117
  return {
97
- notFound: () => {
98
- // <I18nNotFound />
99
- },
100
- generateStaticParams: () => {
101
- return locales.map((l) => ({ ${e}: l }));
118
+ generateStaticParams: () => locales.map((l) => ({ ${e}: l })),
119
+ generateMetadata: (
120
+ impl: (
121
+ props: TProps & { locale: I18n.Locale },
122
+ ) => Metadata | Promise<Metadata>,
123
+ ) => {
124
+ return async (props: I18n.Props<TProps>): Promise<Metadata> => {
125
+ const { locale } = await resolveConfigurator(props);
126
+ const metadata = await impl({ locale, ...props });
127
+ return metadata;
128
+ };
102
129
  },
103
130
  default: (
104
131
  impl: (
105
- props: I18n.Props<
106
- TProps & React.PropsWithChildren<{
107
- i18nHtmlAttrs: Pick<React.ComponentPropsWithoutRef<"html">, "lang" | "dir">
108
- }>
109
- >,
110
- locale: I18n.Locale
111
- ) => React.ReactNode | Promise<React.ReactNode>
132
+ props: TProps & { locale: I18n.Locale } & React.PropsWithChildren<{
133
+ i18nHtmlAttrs: Pick<
134
+ React.ComponentPropsWithoutRef<"html">,
135
+ "lang" | "dir"
136
+ >;
137
+ }>,
138
+ ) => React.ReactNode | Promise<React.ReactNode>,
112
139
  ) => {
113
140
  return async (props: I18n.Props<TProps>) => {
114
- // const locale = props.params.${e};
115
- const locale = getLocale();
116
- // TODO: determine "dir" dynamically
117
- const i18nHtmlAttrs = { lang: locale, dir: "ltr" };
118
- const options = configurator ? await configurator(props, locale) : {};
119
- const inner = await impl({ ...props, i18nHtmlAttrs }, locale);
120
- return (<I18nLayout {...options}>{inner}</I18nLayout>);
121
- }
122
- }
123
- }
141
+ const config = await resolveConfigurator(props);
142
+ const { locale } = config;
143
+ const dir = rtlLocales.includes(locale) ? "rtl" : "ltr";
144
+ const i18nHtmlAttrs = { lang: locale, dir };
145
+ const render = await impl({ locale, i18nHtmlAttrs, ...props });
146
+ return <I18nLayout {...config}>{render}</I18nLayout>;
147
+ };
148
+ },
149
+ };
124
150
  };
125
151
 
126
152
  createI18nLayout.Root = I18nLayoutRoot;
@@ -3,8 +3,8 @@
3
3
  var getI18nDictionaries_inline = require('../../adapter-js/generators/getI18nDictionaries_inline.cjs.js');
4
4
  var createAdapter = require('../../compiler/createAdapter.cjs.js');
5
5
 
6
- var p = createAdapter.createGenerator("next", (t)=>{
7
- let { config: { single: a }, options: { routes: { localeParamName: o } } } = t;
6
+ var p = createAdapter.createGenerator("next", (a)=>{
7
+ let { config: { single: t }, options: { routes: { localeParamName: o } } } = a;
8
8
  return {
9
9
  I18nPage: {
10
10
  dir: "server",
@@ -31,7 +31,7 @@ ${getI18nDictionaries_inline.getI18nDictionaries_inline(1)}
31
31
  export type I18nPageProps<TRouteId extends I18n.RouteId> =
32
32
  React.PropsWithChildren<
33
33
  {
34
- ${a ? "" : `/**
34
+ ${t ? "" : `/**
35
35
  * Optionally set this manually to override the current locale
36
36
  */
37
37
  locale?: I18n.Locale;
@@ -119,7 +119,7 @@ function pageInit(paramsOrProps: I18n.Props["params"] | I18n.Props) {
119
119
  const locale = (params as any).${o};
120
120
 
121
121
  if (isLocale(locale)) {
122
- ${a ? "" : `
122
+ ${t ? "" : `
123
123
  // set the server context based locale as early as possible, usually this
124
124
  // function is called as first thing in the page components. Setting the
125
125
  // locale here might help reducing the cases where a 't' function needed
@@ -127,7 +127,6 @@ function pageInit(paramsOrProps: I18n.Props["params"] | I18n.Props) {
127
127
  // passing a 'locale' argument. Passing the 'locale' should not be needed
128
128
  // actually, but...
129
129
  I18nLocaleContext.set(locale);
130
- global.__i18n_locale = locale;
131
130
  `}return locale;
132
131
  }
133
132
  }
@@ -184,42 +183,85 @@ type Configurator<TRouteId extends I18n.RouteId> = {
184
183
  * @example
185
184
  *
186
185
  * \`\`\`
187
- * type Props = {
188
- * params: {
189
- * slug: string;
190
- * };
191
- * };
192
- *
193
- * const i18nPage = i18nServer.page<Props>(async (_props, _locale) => {
186
+ * type Props = { params: { slug: string; }; };
187
+ *
188
+ * const page = i18nServer.page((props: Props) => {
194
189
  * return {
195
- * route: { id: "home" },
196
- * namespaces: ["~home"],
190
+ * route: { id: "collection.[slug]", params: { slug: props.params.slug } },
191
+ * namespaces: ["~collection-single"],
197
192
  * };
198
193
  * });
194
+ *
195
+ * export const generateMetadata = page.generateMetadata((props) => {
196
+ * return {};
197
+ * });
198
+ *
199
+ * // or async:
200
+ * export const generateMetadata = page.generateMetadata(async (props) => {
201
+ * return {};
202
+ * });
203
+ *
204
+ * export default page.default((props) => {
205
+ * return <>{props.route.id} {props.locale}</>;
206
+ * });
207
+ *
208
+ * // or async:
209
+ * export default page.default(async (props) => {
210
+ * const data = await fetch(...);
211
+ * return <>{props.route.id} {props.locale}</>;
212
+ * });
199
213
  * \`\`\`
200
- * @returns
201
214
  */
202
- export const createI18nPage = <TProps extends {}, TRouteId extends I18n.RouteId = I18n.RouteId>(
203
- configurator: (props: I18n.Props & TProps, locale: I18n.Locale) => Configurator<TRouteId> | Promise<Configurator<TRouteId>>
215
+ export const createI18nPage = <
216
+ TProps extends {},
217
+ TRouteId extends I18n.RouteId,
218
+ TConfig extends Configurator<TRouteId>,
219
+ >(
220
+ configurator: (
221
+ props: I18n.Props<TProps>,
222
+ locale: I18n.Locale,
223
+ ) => TConfig | Promise<TConfig>,
204
224
  ) => {
205
225
  return {
206
- generateMetadata: (impl: (props: I18n.Props & TProps, locale: I18n.Locale) => Promise<Metadata>) => {
207
- return async (props: I18n.Props & TProps): Promise<Metadata> => {
226
+ generateMetadata: (
227
+ impl: (
228
+ props: TProps &
229
+ Omit<TConfig, "namespaces"> & {
230
+ locale: I18n.Locale;
231
+ },
232
+ ) => Metadata | Promise<Metadata>,
233
+ ) => {
234
+ return async (props: I18n.Props<TProps>): Promise<Metadata> => {
208
235
  const locale = pageInit(props);
209
- const { route } = await configurator(props, locale);
210
- const custom = await impl(props, locale)
211
- return getMetadata({ ...route, locale }, custom)
236
+ const { namespaces, ...config } = await configurator(props, locale);
237
+ const metadata = await impl({ locale, ...config, ...props });
238
+ return getMetadata({ ...config.route, locale }, metadata);
212
239
  };
213
240
  },
214
- default: (impl: (props: I18n.Props & TProps, locale: I18n.Locale) => React.ReactNode | Promise<React.ReactNode>) => {
215
- return async (props: I18n.Props & TProps) => {
241
+ default: (
242
+ impl: (
243
+ props: TProps &
244
+ Omit<TConfig, "namespaces"> & {
245
+ locale: I18n.Locale;
246
+ },
247
+ ) => React.ReactNode | Promise<React.ReactNode>,
248
+ ) => {
249
+ return async (props: I18n.Props<TProps>) => {
216
250
  const locale = pageInit(props);
217
- const { route, ...options } = await configurator(props, locale);
218
- const render = await impl(props, locale);
219
- return (<I18nPage route={route} {...options}>{render}</I18nPage>);
220
- }
221
- }
222
- }
251
+ const { namespaces, ...config } = await configurator(props, locale);
252
+ const render = await impl({ locale, ...config, ...props });
253
+ return (
254
+ <I18nPage
255
+ locale={locale}
256
+ namespaces={namespaces}
257
+ route={config.route}
258
+ >
259
+ {render}
260
+ </I18nPage>
261
+ );
262
+ };
263
+ },
264
+ };
223
265
  };
224
266
 
225
267
  export default I18nPage;
@@ -1,8 +1,8 @@
1
1
  import { getI18nDictionaries_inline } from '../../adapter-js/generators/getI18nDictionaries_inline.esm.js';
2
2
  import { createGenerator } from '../../compiler/createAdapter.esm.js';
3
3
 
4
- var p = createGenerator("next", (t)=>{
5
- let { config: { single: a }, options: { routes: { localeParamName: o } } } = t;
4
+ var p = createGenerator("next", (a)=>{
5
+ let { config: { single: t }, options: { routes: { localeParamName: o } } } = a;
6
6
  return {
7
7
  I18nPage: {
8
8
  dir: "server",
@@ -29,7 +29,7 @@ ${getI18nDictionaries_inline(1)}
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;
@@ -117,7 +117,7 @@ function pageInit(paramsOrProps: I18n.Props["params"] | I18n.Props) {
117
117
  const locale = (params as any).${o};
118
118
 
119
119
  if (isLocale(locale)) {
120
- ${a ? "" : `
120
+ ${t ? "" : `
121
121
  // set the server context based locale as early as possible, usually this
122
122
  // function is called as first thing in the page components. Setting the
123
123
  // locale here might help reducing the cases where a 't' function needed
@@ -125,7 +125,6 @@ function pageInit(paramsOrProps: I18n.Props["params"] | I18n.Props) {
125
125
  // passing a 'locale' argument. Passing the 'locale' should not be needed
126
126
  // actually, but...
127
127
  I18nLocaleContext.set(locale);
128
- global.__i18n_locale = locale;
129
128
  `}return locale;
130
129
  }
131
130
  }
@@ -182,42 +181,85 @@ type Configurator<TRouteId extends I18n.RouteId> = {
182
181
  * @example
183
182
  *
184
183
  * \`\`\`
185
- * type Props = {
186
- * params: {
187
- * slug: string;
188
- * };
189
- * };
190
- *
191
- * const i18nPage = i18nServer.page<Props>(async (_props, _locale) => {
184
+ * type Props = { params: { slug: string; }; };
185
+ *
186
+ * const page = i18nServer.page((props: Props) => {
192
187
  * return {
193
- * route: { id: "home" },
194
- * namespaces: ["~home"],
188
+ * route: { id: "collection.[slug]", params: { slug: props.params.slug } },
189
+ * namespaces: ["~collection-single"],
195
190
  * };
196
191
  * });
192
+ *
193
+ * export const generateMetadata = page.generateMetadata((props) => {
194
+ * return {};
195
+ * });
196
+ *
197
+ * // or async:
198
+ * export const generateMetadata = page.generateMetadata(async (props) => {
199
+ * return {};
200
+ * });
201
+ *
202
+ * export default page.default((props) => {
203
+ * return <>{props.route.id} {props.locale}</>;
204
+ * });
205
+ *
206
+ * // or async:
207
+ * export default page.default(async (props) => {
208
+ * const data = await fetch(...);
209
+ * return <>{props.route.id} {props.locale}</>;
210
+ * });
197
211
  * \`\`\`
198
- * @returns
199
212
  */
200
- export const createI18nPage = <TProps extends {}, TRouteId extends I18n.RouteId = I18n.RouteId>(
201
- configurator: (props: I18n.Props & TProps, locale: I18n.Locale) => Configurator<TRouteId> | Promise<Configurator<TRouteId>>
213
+ export const createI18nPage = <
214
+ TProps extends {},
215
+ TRouteId extends I18n.RouteId,
216
+ TConfig extends Configurator<TRouteId>,
217
+ >(
218
+ configurator: (
219
+ props: I18n.Props<TProps>,
220
+ locale: I18n.Locale,
221
+ ) => TConfig | Promise<TConfig>,
202
222
  ) => {
203
223
  return {
204
- generateMetadata: (impl: (props: I18n.Props & TProps, locale: I18n.Locale) => Promise<Metadata>) => {
205
- return async (props: I18n.Props & TProps): Promise<Metadata> => {
224
+ generateMetadata: (
225
+ impl: (
226
+ props: TProps &
227
+ Omit<TConfig, "namespaces"> & {
228
+ locale: I18n.Locale;
229
+ },
230
+ ) => Metadata | Promise<Metadata>,
231
+ ) => {
232
+ return async (props: I18n.Props<TProps>): Promise<Metadata> => {
206
233
  const locale = pageInit(props);
207
- const { route } = await configurator(props, locale);
208
- const custom = await impl(props, locale)
209
- return getMetadata({ ...route, locale }, custom)
234
+ const { namespaces, ...config } = await configurator(props, locale);
235
+ const metadata = await impl({ locale, ...config, ...props });
236
+ return getMetadata({ ...config.route, locale }, metadata);
210
237
  };
211
238
  },
212
- default: (impl: (props: I18n.Props & TProps, locale: I18n.Locale) => React.ReactNode | Promise<React.ReactNode>) => {
213
- return async (props: I18n.Props & TProps) => {
239
+ default: (
240
+ impl: (
241
+ props: TProps &
242
+ Omit<TConfig, "namespaces"> & {
243
+ locale: I18n.Locale;
244
+ },
245
+ ) => React.ReactNode | Promise<React.ReactNode>,
246
+ ) => {
247
+ return async (props: I18n.Props<TProps>) => {
214
248
  const locale = pageInit(props);
215
- const { route, ...options } = await configurator(props, locale);
216
- const render = await impl(props, locale);
217
- return (<I18nPage route={route} {...options}>{render}</I18nPage>);
218
- }
219
- }
220
- }
249
+ const { namespaces, ...config } = await configurator(props, locale);
250
+ const render = await impl({ locale, ...config, ...props });
251
+ return (
252
+ <I18nPage
253
+ locale={locale}
254
+ namespaces={namespaces}
255
+ route={config.route}
256
+ >
257
+ {render}
258
+ </I18nPage>
259
+ );
260
+ };
261
+ },
262
+ };
221
263
  };
222
264
 
223
265
  export default I18nPage;
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var utils = require('@koine/utils');
4
- var formatRoutePathname = require('../client/formatRoutePathname.cjs.js');
4
+ var formatRoutePathname = require('../formatRoutePathname.cjs.js');
5
5
  var transformPathname = require('./transformPathname.cjs.js');
6
6
 
7
7
  function a(e) {
8
- let { localeSource: t, localeDestination: o, template: a, pathname: l, permanent: n } = e, i = formatRoutePathname.formatRoutePathname((t ? `${t}/` : "") + a), c = formatRoutePathname.formatRoutePathname((o ? `${o}/` : "") + l);
8
+ let { localeSource: t, localeDestination: r, template: a, pathname: l, permanent: n } = e, i = formatRoutePathname.formatRoutePathname((t ? `${t}/` : "") + a), c = formatRoutePathname.formatRoutePathname((r ? `${r}/` : "") + l);
9
9
  // console.log(`redirect template "${source}" to pathname "${destination}"`);
10
10
  if (i !== c) return {
11
11
  source: i,
@@ -13,10 +13,10 @@ function a(e) {
13
13
  permanent: !!n
14
14
  };
15
15
  }
16
- function generateRedirectForPathname(e, t, r, o, l) {
16
+ function generateRedirectForPathname(e, t, o, r, l) {
17
17
  let { defaultLocale: n, hideDefaultLocaleInUrl: i, localeParamName: c, permanentRedirects: s } = e, p = t === n, u = p && !i, m = {
18
- template: r,
19
- pathname: o,
18
+ template: o,
19
+ pathname: r,
20
20
  permanent: s
21
21
  };
22
22
  c ? // app router:
@@ -31,7 +31,7 @@ function generateRedirectForPathname(e, t, r, o, l) {
31
31
  localeSource: t,
32
32
  localeDestination: t
33
33
  })) : // pages router:
34
- o !== r && (u ? l.push(a({
34
+ r !== o && (u ? l.push(a({
35
35
  ...m,
36
36
  localeDestination: t
37
37
  })) : p ? l.push(a(m)) : l.push(a({
@@ -46,16 +46,16 @@ function generateRedirectForPathname(e, t, r, o, l) {
46
46
  * @see
47
47
  * - https://nextjs.org/docs/pages/api-reference/next-config-js/redirects
48
48
  * - https://vercel.com/docs/projects/project-configuration#redirects
49
- */ let generateRedirects = (r, { localeParamName: a, permanentRedirects: l, tokens: n }, i)=>{
49
+ */ let generateRedirects = (o, { localeParamName: a, permanentRedirects: l, tokens: n }, i)=>{
50
50
  let c = {
51
- ...r,
51
+ ...o,
52
52
  localeParamName: a,
53
53
  permanentRedirects: l
54
54
  }, s = RegExp(utils.escapeRegExp(n.idDelimiter), "g"), p = [];
55
55
  for(let e in i){
56
- let t = i[e], r = i[e].pathnames;
57
- for(let a in r){
58
- let l = r[a], // prettier-ignore
56
+ let t = i[e], o = i[e].pathnames;
57
+ for(let a in o){
58
+ let l = o[a], // prettier-ignore
59
59
  n = transformPathname.transformPathname(e.replace(s, "/"), t.wildcard), i = transformPathname.transformPathname(l, t.wildcard);
60
60
  // we do not redirect urls children of wildcard urls
61
61
  if (t.inWildcard) break;
@@ -1,9 +1,9 @@
1
1
  import { escapeRegExp, arrayUniqueByProperties } from '@koine/utils';
2
- import { formatRoutePathname } from '../client/formatRoutePathname.esm.js';
2
+ import { formatRoutePathname } from '../formatRoutePathname.esm.js';
3
3
  import { transformPathname } from './transformPathname.esm.js';
4
4
 
5
5
  function a(e) {
6
- let { localeSource: t, localeDestination: o, template: a, pathname: l, permanent: n } = e, i = formatRoutePathname((t ? `${t}/` : "") + a), c = formatRoutePathname((o ? `${o}/` : "") + l);
6
+ let { localeSource: t, localeDestination: r, template: a, pathname: l, permanent: n } = e, i = formatRoutePathname((t ? `${t}/` : "") + a), c = formatRoutePathname((r ? `${r}/` : "") + l);
7
7
  // console.log(`redirect template "${source}" to pathname "${destination}"`);
8
8
  if (i !== c) return {
9
9
  source: i,
@@ -11,10 +11,10 @@ function a(e) {
11
11
  permanent: !!n
12
12
  };
13
13
  }
14
- function generateRedirectForPathname(e, t, r, o, l) {
14
+ function generateRedirectForPathname(e, t, o, r, l) {
15
15
  let { defaultLocale: n, hideDefaultLocaleInUrl: i, localeParamName: c, permanentRedirects: s } = e, p = t === n, u = p && !i, m = {
16
- template: r,
17
- pathname: o,
16
+ template: o,
17
+ pathname: r,
18
18
  permanent: s
19
19
  };
20
20
  c ? // app router:
@@ -29,7 +29,7 @@ function generateRedirectForPathname(e, t, r, o, l) {
29
29
  localeSource: t,
30
30
  localeDestination: t
31
31
  })) : // pages router:
32
- o !== r && (u ? l.push(a({
32
+ r !== o && (u ? l.push(a({
33
33
  ...m,
34
34
  localeDestination: t
35
35
  })) : p ? l.push(a(m)) : l.push(a({
@@ -44,16 +44,16 @@ function generateRedirectForPathname(e, t, r, o, l) {
44
44
  * @see
45
45
  * - https://nextjs.org/docs/pages/api-reference/next-config-js/redirects
46
46
  * - https://vercel.com/docs/projects/project-configuration#redirects
47
- */ let generateRedirects = (r, { localeParamName: a, permanentRedirects: l, tokens: n }, i)=>{
47
+ */ let generateRedirects = (o, { localeParamName: a, permanentRedirects: l, tokens: n }, i)=>{
48
48
  let c = {
49
- ...r,
49
+ ...o,
50
50
  localeParamName: a,
51
51
  permanentRedirects: l
52
52
  }, s = RegExp(escapeRegExp(n.idDelimiter), "g"), p = [];
53
53
  for(let e in i){
54
- let t = i[e], r = i[e].pathnames;
55
- for(let a in r){
56
- let l = r[a], // prettier-ignore
54
+ let t = i[e], o = i[e].pathnames;
55
+ for(let a in o){
56
+ let l = o[a], // prettier-ignore
57
57
  n = transformPathname(e.replace(s, "/"), t.wildcard), i = transformPathname(l, t.wildcard);
58
58
  // we do not redirect urls children of wildcard urls
59
59
  if (t.inWildcard) break;
@@ -1,37 +1,37 @@
1
1
  'use strict';
2
2
 
3
3
  var utils = require('@koine/utils');
4
- var formatRoutePathname = require('../client/formatRoutePathname.cjs.js');
4
+ var formatRoutePathname = require('../formatRoutePathname.cjs.js');
5
5
  var transformPathname = require('./transformPathname.cjs.js');
6
6
 
7
7
  function o(e) {
8
8
  let { localeSource: t, localeDestination: a, template: o, pathname: l, passLocale: i } = e, n = "";
9
9
  t && (n = `/${t}`);
10
- let c = formatRoutePathname.formatRoutePathname(n + l), s = "";
11
- a && (s = `/${a}`);
12
- let p = formatRoutePathname.formatRoutePathname(s + o);
10
+ let s = formatRoutePathname.formatRoutePathname(n + l), c = "";
11
+ a && (c = `/${a}`);
12
+ let m = formatRoutePathname.formatRoutePathname(c + o);
13
13
  // console.log(`rewrite pathname "${source}" to template "${destination}"`);
14
- if (c === p) return;
15
- let m = {
16
- source: c,
17
- destination: p
14
+ if (s === m) return;
15
+ let p = {
16
+ source: s,
17
+ destination: m
18
18
  };
19
- return !1 === i && (m.locale = !1), m;
19
+ return !1 === i && (p.locale = !1), p;
20
20
  }
21
21
  const generateRewriteForPathname = (e, t, r, a, l)=>{
22
- let { defaultLocale: i, hideDefaultLocaleInUrl: n, localeParamName: c } = e, s = t === i && n, // TODO: maybe support other locales to be hidden in the URL other than the default?
23
- p = {
22
+ let { defaultLocale: i, hideDefaultLocaleInUrl: n, localeParamName: s } = e, c = t === i && n, // TODO: maybe support other locales to be hidden in the URL other than the default?
23
+ m = {
24
24
  template: r,
25
25
  pathname: a
26
26
  };
27
- c ? // app router:
28
- s ? l.push(o({
29
- ...p,
27
+ s ? // app router:
28
+ c ? l.push(o({
29
+ ...m,
30
30
  localeDestination: t,
31
31
  passLocale: !1
32
32
  })) : l.push(// prettier-ignore
33
33
  o({
34
- ...p,
34
+ ...m,
35
35
  localeSource: t,
36
36
  localeDestination: t,
37
37
  passLocale: !1
@@ -39,13 +39,13 @@ const generateRewriteForPathname = (e, t, r, a, l)=>{
39
39
  // this condition only applies to the pages router as with the app one
40
40
  // even if the template matches the pathname we always need to rewrite
41
41
  // as the localeParam is always needed in the rewrite destination
42
- a !== r && (s ? l.push(o(p)) : l.push(// `passLocale` must be `false` or the locale prefixed rewrite won't
42
+ a !== r && (c ? l.push(o(m)) : l.push(// `passLocale` must be `false` or the locale prefixed rewrite won't
43
43
  // be applied and does not forward the locale to the route context
44
44
  // when the locale is included in the URL. In fact we explicitly
45
45
  // add the locale to the rewrite rule in order to get the least
46
46
  // amount of existing URLs which is a good SEO practice
47
47
  o({
48
- ...p,
48
+ ...m,
49
49
  localeSource: t,
50
50
  passLocale: !1
51
51
  })));
@@ -57,27 +57,27 @@ const generateRewriteForPathname = (e, t, r, a, l)=>{
57
57
  * - https://nextjs.org/docs/pages/api-reference/next-config-js/rewrites
58
58
  * - https://vercel.com/docs/projects/project-configuration#rewrites
59
59
  */ let generateRewrites = (r, { tokens: o, localeParamName: l, permanentRedirects: i }, n)=>{
60
- let c = {
60
+ let s = {
61
61
  ...r,
62
62
  localeParamName: l,
63
63
  permanentRedirects: i
64
- }, s = RegExp(utils.escapeRegExp(o.idDelimiter), "g"), p = [];
64
+ }, c = RegExp(utils.escapeRegExp(o.idDelimiter), "g"), m = [];
65
65
  for(let e in n){
66
66
  let t = n[e], r = n[e].pathnames;
67
67
  for(let o in r){
68
- let l = r[o], i = e.replace(s, "/");
68
+ let l = r[o], i = e.replace(c, "/");
69
69
  // we do not rewrite urls children of wildcard urls
70
70
  if (t.inWildcard) break;
71
71
  // we need to rewrite both the root path...
72
- generateRewriteForPathname(c, o, transformPathname.transformPathname(i), transformPathname.transformPathname(l), p), t.wildcard && // and for wildcard routes the ones with the `/:segment*` portion
73
- generateRewriteForPathname(c, o, transformPathname.transformPathname(i, t.wildcard), transformPathname.transformPathname(l, t.wildcard), p);
72
+ generateRewriteForPathname(s, o, transformPathname.transformPathname(i), transformPathname.transformPathname(l), m), t.wildcard && // and for wildcard routes the ones with the `/:segment*` portion
73
+ generateRewriteForPathname(s, o, transformPathname.transformPathname(i, t.wildcard), transformPathname.transformPathname(l, t.wildcard), m);
74
74
  }
75
75
  }
76
76
  // simple sort by destination:
77
77
  // return a.destination.localeCompare(b.destination);
78
78
  // sort by locale
79
79
  // return a.
80
- return utils.arrayUniqueByProperties(p.filter(Boolean), [
80
+ return utils.arrayUniqueByProperties(m.filter(Boolean), [
81
81
  "source",
82
82
  "destination"
83
83
  ]).sort((e, t)=>// simple sort by source:
@@ -1,35 +1,35 @@
1
1
  import { escapeRegExp, arrayUniqueByProperties } from '@koine/utils';
2
- import { formatRoutePathname } from '../client/formatRoutePathname.esm.js';
2
+ import { formatRoutePathname } from '../formatRoutePathname.esm.js';
3
3
  import { transformPathname } from './transformPathname.esm.js';
4
4
 
5
5
  function o(e) {
6
6
  let { localeSource: t, localeDestination: a, template: o, pathname: l, passLocale: i } = e, n = "";
7
7
  t && (n = `/${t}`);
8
- let c = formatRoutePathname(n + l), s = "";
9
- a && (s = `/${a}`);
10
- let p = formatRoutePathname(s + o);
8
+ let s = formatRoutePathname(n + l), c = "";
9
+ a && (c = `/${a}`);
10
+ let m = formatRoutePathname(c + o);
11
11
  // console.log(`rewrite pathname "${source}" to template "${destination}"`);
12
- if (c === p) return;
13
- let m = {
14
- source: c,
15
- destination: p
12
+ if (s === m) return;
13
+ let p = {
14
+ source: s,
15
+ destination: m
16
16
  };
17
- return !1 === i && (m.locale = !1), m;
17
+ return !1 === i && (p.locale = !1), p;
18
18
  }
19
19
  const generateRewriteForPathname = (e, t, r, a, l)=>{
20
- let { defaultLocale: i, hideDefaultLocaleInUrl: n, localeParamName: c } = e, s = t === i && n, // TODO: maybe support other locales to be hidden in the URL other than the default?
21
- p = {
20
+ let { defaultLocale: i, hideDefaultLocaleInUrl: n, localeParamName: s } = e, c = t === i && n, // TODO: maybe support other locales to be hidden in the URL other than the default?
21
+ m = {
22
22
  template: r,
23
23
  pathname: a
24
24
  };
25
- c ? // app router:
26
- s ? l.push(o({
27
- ...p,
25
+ s ? // app router:
26
+ c ? l.push(o({
27
+ ...m,
28
28
  localeDestination: t,
29
29
  passLocale: !1
30
30
  })) : l.push(// prettier-ignore
31
31
  o({
32
- ...p,
32
+ ...m,
33
33
  localeSource: t,
34
34
  localeDestination: t,
35
35
  passLocale: !1
@@ -37,13 +37,13 @@ const generateRewriteForPathname = (e, t, r, a, l)=>{
37
37
  // this condition only applies to the pages router as with the app one
38
38
  // even if the template matches the pathname we always need to rewrite
39
39
  // as the localeParam is always needed in the rewrite destination
40
- a !== r && (s ? l.push(o(p)) : l.push(// `passLocale` must be `false` or the locale prefixed rewrite won't
40
+ a !== r && (c ? l.push(o(m)) : l.push(// `passLocale` must be `false` or the locale prefixed rewrite won't
41
41
  // be applied and does not forward the locale to the route context
42
42
  // when the locale is included in the URL. In fact we explicitly
43
43
  // add the locale to the rewrite rule in order to get the least
44
44
  // amount of existing URLs which is a good SEO practice
45
45
  o({
46
- ...p,
46
+ ...m,
47
47
  localeSource: t,
48
48
  passLocale: !1
49
49
  })));
@@ -55,27 +55,27 @@ const generateRewriteForPathname = (e, t, r, a, l)=>{
55
55
  * - https://nextjs.org/docs/pages/api-reference/next-config-js/rewrites
56
56
  * - https://vercel.com/docs/projects/project-configuration#rewrites
57
57
  */ let generateRewrites = (r, { tokens: o, localeParamName: l, permanentRedirects: i }, n)=>{
58
- let c = {
58
+ let s = {
59
59
  ...r,
60
60
  localeParamName: l,
61
61
  permanentRedirects: i
62
- }, s = RegExp(escapeRegExp(o.idDelimiter), "g"), p = [];
62
+ }, c = RegExp(escapeRegExp(o.idDelimiter), "g"), m = [];
63
63
  for(let e in n){
64
64
  let t = n[e], r = n[e].pathnames;
65
65
  for(let o in r){
66
- let l = r[o], i = e.replace(s, "/");
66
+ let l = r[o], i = e.replace(c, "/");
67
67
  // we do not rewrite urls children of wildcard urls
68
68
  if (t.inWildcard) break;
69
69
  // we need to rewrite both the root path...
70
- generateRewriteForPathname(c, o, transformPathname(i), transformPathname(l), p), t.wildcard && // and for wildcard routes the ones with the `/:segment*` portion
71
- generateRewriteForPathname(c, o, transformPathname(i, t.wildcard), transformPathname(l, t.wildcard), p);
70
+ generateRewriteForPathname(s, o, transformPathname(i), transformPathname(l), m), t.wildcard && // and for wildcard routes the ones with the `/:segment*` portion
71
+ generateRewriteForPathname(s, o, transformPathname(i, t.wildcard), transformPathname(l, t.wildcard), m);
72
72
  }
73
73
  }
74
74
  // simple sort by destination:
75
75
  // return a.destination.localeCompare(b.destination);
76
76
  // sort by locale
77
77
  // return a.
78
- return arrayUniqueByProperties(p.filter(Boolean), [
78
+ return arrayUniqueByProperties(m.filter(Boolean), [
79
79
  "source",
80
80
  "destination"
81
81
  ]).sort((e, t)=>// simple sort by source:
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var utils = require('@koine/utils');
4
- var formatRoutePathname = require('../../client/formatRoutePathname.cjs.js');
4
+ var formatRoutePathname = require('../../formatRoutePathname.cjs.js');
5
5
 
6
6
  const codeDataRoutesOptions = {
7
7
  /**
@@ -1,5 +1,5 @@
1
1
  import { escapeRegExp, objectSortByKeysMatching, objectFlat, objectSort } from '@koine/utils';
2
- import { formatRoutePathname } from '../../client/formatRoutePathname.esm.js';
2
+ import { formatRoutePathname } from '../../formatRoutePathname.esm.js';
3
3
 
4
4
  const codeDataRoutesOptions = {
5
5
  /**
@@ -0,0 +1,2 @@
1
+ export * from "./formatRoutePathname";
2
+ export { default } from "./formatRoutePathname";
@@ -0,0 +1 @@
1
+ exports._default = require('./formatRoutePathname.cjs.js').default;
@@ -0,0 +1,2 @@
1
+ export * from './formatRoutePathname.cjs.js';
2
+ export { _default as default } from './formatRoutePathname.cjs.default.js';
@@ -0,0 +1,2 @@
1
+ export * from "./formatRoutePathname";
2
+ export { default } from "./formatRoutePathname";
package/index.cjs.js CHANGED
@@ -1,11 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var formatRoutePathname = require('./client/formatRoutePathname.cjs.js');
4
- var interpolateTo = require('./client/interpolateTo.cjs.js');
5
- var routeHasDynamicPortion = require('./client/routeHasDynamicPortion.cjs.js');
3
+ var formatRoutePathname = require('./formatRoutePathname.cjs.js');
4
+ var interpolateTo = require('./interpolateTo.cjs.js');
5
+ var rtlLocales = require('./rtlLocales.cjs.js');
6
+ var routeHasDynamicPortion = require('./routeHasDynamicPortion.cjs.js');
6
7
 
7
8
 
8
9
 
9
10
  exports.formatRoutePathname = formatRoutePathname.formatRoutePathname;
10
11
  exports.interpolateTo = interpolateTo.interpolateTo;
12
+ exports.rtlLocales = rtlLocales.rtlLocales;
11
13
  exports.routeHasDynamicPortion = routeHasDynamicPortion.routeHasDynamicPortion;
package/index.d.ts CHANGED
@@ -1,2 +1,5 @@
1
- export * from "./client";
1
+ export { formatRoutePathname } from "./formatRoutePathname";
2
+ export { interpolateTo } from "./interpolateTo";
3
+ export { rtlLocales } from "./rtlLocales";
4
+ export { routeHasDynamicPortion } from "./routeHasDynamicPortion";
2
5
  export * from "./types";
package/index.esm.js CHANGED
@@ -1,3 +1,4 @@
1
- export { formatRoutePathname } from './client/formatRoutePathname.esm.js';
2
- export { interpolateTo } from './client/interpolateTo.esm.js';
3
- export { routeHasDynamicPortion } from './client/routeHasDynamicPortion.esm.js';
1
+ export { formatRoutePathname } from './formatRoutePathname.esm.js';
2
+ export { interpolateTo } from './interpolateTo.esm.js';
3
+ export { rtlLocales } from './rtlLocales.esm.js';
4
+ export { routeHasDynamicPortion } from './routeHasDynamicPortion.esm.js';
@@ -0,0 +1,2 @@
1
+ export * from "./interpolateTo";
2
+ export { default } from "./interpolateTo";
@@ -0,0 +1 @@
1
+ exports._default = require('./interpolateTo.cjs.js').default;
@@ -0,0 +1,2 @@
1
+ export * from './interpolateTo.cjs.js';
2
+ export { _default as default } from './interpolateTo.cjs.default.js';
@@ -1,4 +1,4 @@
1
- import type { I18nUtils } from "../types";
1
+ import type { I18nUtils } from "./types";
2
2
  export declare function interpolateTo<TRouteId extends string>(value: TRouteId): string;
3
3
  export declare function interpolateTo<TRouteId extends string>(value: TRouteId, params: I18nUtils.DynamicParams<TRouteId>): string;
4
4
  export default interpolateTo;
@@ -0,0 +1,2 @@
1
+ export * from "./interpolateTo";
2
+ export { default } from "./interpolateTo";
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "name": "@koine/i18n",
3
3
  "sideEffects": false,
4
4
  "dependencies": {
5
- "@koine/node": "2.0.0-beta.128",
6
- "@koine/utils": "2.0.0-beta.128",
5
+ "@koine/node": "2.0.0-beta.129",
6
+ "@koine/utils": "2.0.0-beta.129",
7
7
  "glob": "^10.3.10",
8
8
  "minimatch": "^9.0.3",
9
9
  "negotiator": "^0.6.3",
@@ -37,6 +37,30 @@
37
37
  "import": "./index.cjs.mjs",
38
38
  "default": "./index.cjs.js"
39
39
  },
40
+ "./formatRoutePathname": {
41
+ "module": "./formatRoutePathname.esm.js",
42
+ "types": "./formatRoutePathname.esm.d.ts",
43
+ "import": "./formatRoutePathname.cjs.mjs",
44
+ "default": "./formatRoutePathname.cjs.js"
45
+ },
46
+ "./interpolateTo": {
47
+ "module": "./interpolateTo.esm.js",
48
+ "types": "./interpolateTo.esm.d.ts",
49
+ "import": "./interpolateTo.cjs.mjs",
50
+ "default": "./interpolateTo.cjs.js"
51
+ },
52
+ "./routeHasDynamicPortion": {
53
+ "module": "./routeHasDynamicPortion.esm.js",
54
+ "types": "./routeHasDynamicPortion.esm.d.ts",
55
+ "import": "./routeHasDynamicPortion.cjs.mjs",
56
+ "default": "./routeHasDynamicPortion.cjs.js"
57
+ },
58
+ "./rtlLocales": {
59
+ "module": "./rtlLocales.esm.js",
60
+ "types": "./rtlLocales.esm.d.ts",
61
+ "import": "./rtlLocales.cjs.mjs",
62
+ "default": "./rtlLocales.cjs.js"
63
+ },
40
64
  "./compiler": {
41
65
  "module": "./compiler.esm.js",
42
66
  "types": "./compiler.esm.d.ts",
@@ -65,5 +89,5 @@
65
89
  "module": "./index.esm.js",
66
90
  "main": "./index.cjs.js",
67
91
  "types": "./index.esm.d.ts",
68
- "version": "2.0.0-beta.128"
92
+ "version": "2.0.0-beta.129"
69
93
  }
@@ -0,0 +1,2 @@
1
+ export * from "./routeHasDynamicPortion";
2
+ export { default } from "./routeHasDynamicPortion";
@@ -0,0 +1 @@
1
+ exports._default = require('./routeHasDynamicPortion.cjs.js').default;
@@ -0,0 +1,2 @@
1
+ export * from './routeHasDynamicPortion.cjs.js';
2
+ export { _default as default } from './routeHasDynamicPortion.cjs.default.js';
@@ -0,0 +1,2 @@
1
+ export * from "./routeHasDynamicPortion";
2
+ export { default } from "./routeHasDynamicPortion";
@@ -0,0 +1,2 @@
1
+ export * from "./rtlLocales";
2
+ export { default } from "./rtlLocales";
@@ -0,0 +1 @@
1
+ exports._default = require('./rtlLocales.cjs.js').default;
@@ -0,0 +1,55 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * List of Right-to-left language codes
7
+ *
8
+ * @borrows [shadiabuhilal/rtl-detect](https://github.com/shadiabuhilal/rtl-detect)
9
+ * @see https://en.wikipedia.org/wiki/Right-to-left_script
10
+ * @see https://en.wikipedia.org/wiki/Script_(Unicode)
11
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
12
+ */ let rtlLocales = [
13
+ "ae",
14
+ // Avestan
15
+ "ar",
16
+ // 'العربية', Arabic
17
+ "arc",
18
+ // Aramaic
19
+ "bcc",
20
+ // 'بلوچی مکرانی', Southern Balochi
21
+ "bqi",
22
+ // 'بختياري', Bakthiari
23
+ "ckb",
24
+ // 'Soranî / کوردی', Sorani
25
+ "dv",
26
+ // Dhivehi
27
+ "fa",
28
+ // 'فارسی', Persian
29
+ "glk",
30
+ // 'گیلکی', Gilaki
31
+ "he",
32
+ // 'עברית', Hebrew
33
+ "ku",
34
+ // 'Kurdî / كوردی', Kurdish
35
+ "mzn",
36
+ // 'مازِرونی', Mazanderani
37
+ "nqo",
38
+ // N'Ko
39
+ "pnb",
40
+ // 'پنجابی', Western Punjabi
41
+ "prs",
42
+ // 'دری', Darī
43
+ "ps",
44
+ // 'پښتو', Pashto,
45
+ "sd",
46
+ // 'سنڌي', Sindhi
47
+ "ug",
48
+ // 'Uyghurche / ئۇيغۇرچە', Uyghur
49
+ "ur",
50
+ // 'اردو', Urdu
51
+ "yi"
52
+ ];
53
+
54
+ exports.default = rtlLocales;
55
+ exports.rtlLocales = rtlLocales;
@@ -0,0 +1,2 @@
1
+ export * from './rtlLocales.cjs.js';
2
+ export { _default as default } from './rtlLocales.cjs.default.js';
@@ -0,0 +1,2 @@
1
+ export declare let rtlLocales: string[];
2
+ export default rtlLocales;
@@ -0,0 +1,2 @@
1
+ export * from "./rtlLocales";
2
+ export { default } from "./rtlLocales";
@@ -0,0 +1,50 @@
1
+ /**
2
+ * List of Right-to-left language codes
3
+ *
4
+ * @borrows [shadiabuhilal/rtl-detect](https://github.com/shadiabuhilal/rtl-detect)
5
+ * @see https://en.wikipedia.org/wiki/Right-to-left_script
6
+ * @see https://en.wikipedia.org/wiki/Script_(Unicode)
7
+ * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
8
+ */ let rtlLocales = [
9
+ "ae",
10
+ // Avestan
11
+ "ar",
12
+ // 'العربية', Arabic
13
+ "arc",
14
+ // Aramaic
15
+ "bcc",
16
+ // 'بلوچی مکرانی', Southern Balochi
17
+ "bqi",
18
+ // 'بختياري', Bakthiari
19
+ "ckb",
20
+ // 'Soranî / کوردی', Sorani
21
+ "dv",
22
+ // Dhivehi
23
+ "fa",
24
+ // 'فارسی', Persian
25
+ "glk",
26
+ // 'گیلکی', Gilaki
27
+ "he",
28
+ // 'עברית', Hebrew
29
+ "ku",
30
+ // 'Kurdî / كوردی', Kurdish
31
+ "mzn",
32
+ // 'مازِرونی', Mazanderani
33
+ "nqo",
34
+ // N'Ko
35
+ "pnb",
36
+ // 'پنجابی', Western Punjabi
37
+ "prs",
38
+ // 'دری', Darī
39
+ "ps",
40
+ // 'پښتو', Pashto,
41
+ "sd",
42
+ // 'سنڌي', Sindhi
43
+ "ug",
44
+ // 'Uyghurche / ئۇيغۇرچە', Uyghur
45
+ "ur",
46
+ // 'اردو', Urdu
47
+ "yi"
48
+ ];
49
+
50
+ export { rtlLocales as default, rtlLocales };
@@ -1,10 +0,0 @@
1
- declare const _default: (data: import("../../compiler-sync").I18nCompiler.DataCode<"next">) => {
2
- I18nLayoutLang: {
3
- dir: string;
4
- name: string;
5
- ext: "tsx";
6
- index: true;
7
- content: () => string;
8
- };
9
- };
10
- export default _default;
package/client/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export { formatRoutePathname } from "./formatRoutePathname";
2
- export { interpolateTo } from "./interpolateTo";
3
- export { routeHasDynamicPortion } from "./routeHasDynamicPortion";