@koine/i18n 2.0.0-beta.169 → 2.0.0-beta.170

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 (62) hide show
  1. package/adapter-next/generators/router-app/I18nLayout.cjs.js +2 -2
  2. package/adapter-next/generators/router-app/I18nLayout.esm.js +2 -2
  3. package/adapter-next/generators/router-pages/I18nDocument.cjs.js +2 -2
  4. package/adapter-next/generators/router-pages/I18nDocument.esm.js +2 -2
  5. package/adapter-next/plugin/redirects.cjs.js +2 -2
  6. package/adapter-next/plugin/redirects.esm.js +2 -2
  7. package/adapter-next/plugin/rewrites.cjs.js +3 -3
  8. package/adapter-next/plugin/rewrites.esm.js +3 -3
  9. package/compiler/code/data-routes.cjs.js +6 -6
  10. package/compiler/code/data-routes.esm.js +6 -6
  11. package/i18nDefaultMetadata.cjs.d.ts +1 -0
  12. package/i18nDefaultMetadata.cjs.js +3 -0
  13. package/i18nDefaultMetadata.d.ts +1 -0
  14. package/i18nDefaultMetadata.esm.d.ts +1 -0
  15. package/i18nDefaultMetadata.esm.js +1 -1
  16. package/i18nFormatRoutePathname.cjs.d.ts +2 -0
  17. package/i18nFormatRoutePathname.cjs.default.js +1 -0
  18. package/{formatRoutePathname.cjs.js → i18nFormatRoutePathname.cjs.js} +3 -3
  19. package/i18nFormatRoutePathname.cjs.mjs +2 -0
  20. package/i18nFormatRoutePathname.d.ts +4 -0
  21. package/i18nFormatRoutePathname.esm.d.ts +2 -0
  22. package/{formatRoutePathname.esm.js → i18nFormatRoutePathname.esm.js} +2 -2
  23. package/i18nInterpolateRouteParams.cjs.d.ts +2 -0
  24. package/i18nInterpolateRouteParams.cjs.default.js +1 -0
  25. package/i18nInterpolateRouteParams.cjs.js +21 -0
  26. package/i18nInterpolateRouteParams.cjs.mjs +2 -0
  27. package/{interpolateTo.d.ts → i18nInterpolateRouteParams.d.ts} +3 -3
  28. package/i18nInterpolateRouteParams.esm.d.ts +2 -0
  29. package/i18nInterpolateRouteParams.esm.js +16 -0
  30. package/i18nRtlLocales.cjs.d.ts +2 -0
  31. package/i18nRtlLocales.cjs.default.js +1 -0
  32. package/{rtlLocales.cjs.js → i18nRtlLocales.cjs.js} +3 -3
  33. package/i18nRtlLocales.cjs.mjs +2 -0
  34. package/{rtlLocales.d.ts → i18nRtlLocales.d.ts} +2 -2
  35. package/i18nRtlLocales.esm.d.ts +2 -0
  36. package/{rtlLocales.esm.js → i18nRtlLocales.esm.js} +2 -2
  37. package/index.cjs.js +6 -8
  38. package/index.d.ts +3 -4
  39. package/index.esm.js +3 -4
  40. package/package.json +20 -26
  41. package/formatRoutePathname.cjs.d.ts +0 -2
  42. package/formatRoutePathname.cjs.default.js +0 -1
  43. package/formatRoutePathname.cjs.mjs +0 -2
  44. package/formatRoutePathname.d.ts +0 -4
  45. package/formatRoutePathname.esm.d.ts +0 -2
  46. package/interpolateTo.cjs.d.ts +0 -2
  47. package/interpolateTo.cjs.default.js +0 -1
  48. package/interpolateTo.cjs.js +0 -21
  49. package/interpolateTo.cjs.mjs +0 -2
  50. package/interpolateTo.esm.d.ts +0 -2
  51. package/interpolateTo.esm.js +0 -16
  52. package/routeHasDynamicPortion.cjs.d.ts +0 -2
  53. package/routeHasDynamicPortion.cjs.default.js +0 -1
  54. package/routeHasDynamicPortion.cjs.js +0 -8
  55. package/routeHasDynamicPortion.cjs.mjs +0 -2
  56. package/routeHasDynamicPortion.d.ts +0 -2
  57. package/routeHasDynamicPortion.esm.d.ts +0 -2
  58. package/routeHasDynamicPortion.esm.js +0 -3
  59. package/rtlLocales.cjs.d.ts +0 -2
  60. package/rtlLocales.cjs.default.js +0 -1
  61. package/rtlLocales.cjs.mjs +0 -2
  62. package/rtlLocales.esm.d.ts +0 -2
@@ -14,7 +14,7 @@ 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 { rtlLocales } from "@koine/i18n";
17
+ import { i18nRtlLocales } from "@koine/i18n";
18
18
  import { getI18nDictionaries } from "../internal/getI18nDictionaries";
19
19
  import { I18nTranslateProvider } from "../internal/I18nTranslateProvider";
20
20
  import { defaultLocale } from "../defaultLocale";
@@ -201,7 +201,7 @@ export const createI18nLayout = <
201
201
  return async (props: I18n.Props<TProps>) => {
202
202
  const config = await resolveConfigurator(props);
203
203
  const { locale } = config;
204
- const dir = rtlLocales.includes(locale) ? "rtl" : "ltr";
204
+ const dir = i18nRtlLocales.includes(locale) ? "rtl" : "ltr";
205
205
  const i18nHtmlAttrs = { lang: locale, dir };
206
206
  const I18nScript = (
207
207
  <script dangerouslySetInnerHTML={{ __html: \`window.global = window.global || {}; global.${helpers.GLOBAL_I18N_IDENTIFIER} = "\${locale}";\`}}></script>
@@ -12,7 +12,7 @@ var a = createGenerator("next", (e)=>{
12
12
  content: ()=>`
13
13
  import React from "react";
14
14
  import type { Metadata } from "next/types";
15
- import { rtlLocales } from "@koine/i18n";
15
+ import { i18nRtlLocales } from "@koine/i18n";
16
16
  import { getI18nDictionaries } from "../internal/getI18nDictionaries";
17
17
  import { I18nTranslateProvider } from "../internal/I18nTranslateProvider";
18
18
  import { defaultLocale } from "../defaultLocale";
@@ -199,7 +199,7 @@ export const createI18nLayout = <
199
199
  return async (props: I18n.Props<TProps>) => {
200
200
  const config = await resolveConfigurator(props);
201
201
  const { locale } = config;
202
- const dir = rtlLocales.includes(locale) ? "rtl" : "ltr";
202
+ const dir = i18nRtlLocales.includes(locale) ? "rtl" : "ltr";
203
203
  const i18nHtmlAttrs = { lang: locale, dir };
204
204
  const I18nScript = (
205
205
  <script dangerouslySetInnerHTML={{ __html: \`window.global = window.global || {}; global.${GLOBAL_I18N_IDENTIFIER} = "\${locale}";\`}}></script>
@@ -17,7 +17,7 @@ import NextDocument, {
17
17
  Main,
18
18
  NextScript,
19
19
  } from "next/document";
20
- import { rtlLocales } from "@koine/i18n";
20
+ import { i18nRtlLocales } from "@koine/i18n";
21
21
  import { defaultLocale } from "./defaultLocale";
22
22
  import type { I18n } from "./types";
23
23
 
@@ -61,7 +61,7 @@ export class I18nDocument extends NextDocument<I18nDocumentProps> {
61
61
  });
62
62
 
63
63
  const initialProps = await NextDocument.getInitialProps(ctx);
64
- const dir = rtlLocales.includes(locale) ? "rtl" : "ltr";
64
+ const dir = i18nRtlLocales.includes(locale) ? "rtl" : "ltr";
65
65
 
66
66
  return { ...initialProps, i18nHtmlAttrs: { lang, dir } };
67
67
  }
@@ -15,7 +15,7 @@ import NextDocument, {
15
15
  Main,
16
16
  NextScript,
17
17
  } from "next/document";
18
- import { rtlLocales } from "@koine/i18n";
18
+ import { i18nRtlLocales } from "@koine/i18n";
19
19
  import { defaultLocale } from "./defaultLocale";
20
20
  import type { I18n } from "./types";
21
21
 
@@ -59,7 +59,7 @@ export class I18nDocument extends NextDocument<I18nDocumentProps> {
59
59
  });
60
60
 
61
61
  const initialProps = await NextDocument.getInitialProps(ctx);
62
- const dir = rtlLocales.includes(locale) ? "rtl" : "ltr";
62
+ const dir = i18nRtlLocales.includes(locale) ? "rtl" : "ltr";
63
63
 
64
64
  return { ...initialProps, i18nHtmlAttrs: { lang, dir } };
65
65
  }
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
3
  var utils = require('@koine/utils');
4
- var formatRoutePathname = require('../../formatRoutePathname.cjs.js');
4
+ var i18nFormatRoutePathname = require('../../i18nFormatRoutePathname.cjs.js');
5
5
  var utils$1 = require('./utils.cjs.js');
6
6
 
7
7
  function a(e) {
8
- let { localeSource: t, localeDestination: r, template: a, pathname: l, permanent: i } = e, n = formatRoutePathname.formatRoutePathname((t ? `${t}/` : "") + a), c = formatRoutePathname.formatRoutePathname((r ? `${r}/` : "") + l);
8
+ let { localeSource: t, localeDestination: r, template: a, pathname: l, permanent: i } = e, n = i18nFormatRoutePathname.i18nFormatRoutePathname((t ? `${t}/` : "") + a), c = i18nFormatRoutePathname.i18nFormatRoutePathname((r ? `${r}/` : "") + l);
9
9
  if (n !== c) return {
10
10
  source: n,
11
11
  destination: c,
@@ -1,9 +1,9 @@
1
1
  import { escapeRegExp, arrayUniqueByProperties } from '@koine/utils';
2
- import { formatRoutePathname } from '../../formatRoutePathname.esm.js';
2
+ import { i18nFormatRoutePathname } from '../../i18nFormatRoutePathname.esm.js';
3
3
  import { transformPathname } from './utils.esm.js';
4
4
 
5
5
  function a(e) {
6
- let { localeSource: t, localeDestination: r, template: a, pathname: l, permanent: i } = e, n = formatRoutePathname((t ? `${t}/` : "") + a), c = formatRoutePathname((r ? `${r}/` : "") + l);
6
+ let { localeSource: t, localeDestination: r, template: a, pathname: l, permanent: i } = e, n = i18nFormatRoutePathname((t ? `${t}/` : "") + a), c = i18nFormatRoutePathname((r ? `${r}/` : "") + l);
7
7
  if (n !== c) return {
8
8
  source: n,
9
9
  destination: c,
@@ -1,15 +1,15 @@
1
1
  'use strict';
2
2
 
3
3
  var utils = require('@koine/utils');
4
- var formatRoutePathname = require('../../formatRoutePathname.cjs.js');
4
+ var i18nFormatRoutePathname = require('../../i18nFormatRoutePathname.cjs.js');
5
5
  var utils$1 = require('./utils.cjs.js');
6
6
 
7
7
  function a(e) {
8
8
  let { localeSource: t, localeDestination: o, template: a, pathname: l, passLocale: i } = e, n = "";
9
9
  t && (n = `/${t}`);
10
- let s = formatRoutePathname.formatRoutePathname(n + l), c = "";
10
+ let s = i18nFormatRoutePathname.i18nFormatRoutePathname(n + l), c = "";
11
11
  o && (c = `/${o}`);
12
- let p = formatRoutePathname.formatRoutePathname(c + a);
12
+ let p = i18nFormatRoutePathname.i18nFormatRoutePathname(c + a);
13
13
  if (s === p) return;
14
14
  let u = {
15
15
  source: s,
@@ -1,13 +1,13 @@
1
1
  import { escapeRegExp, arrayUniqueByProperties } from '@koine/utils';
2
- import { formatRoutePathname } from '../../formatRoutePathname.esm.js';
2
+ import { i18nFormatRoutePathname } from '../../i18nFormatRoutePathname.esm.js';
3
3
  import { transformPathname } from './utils.esm.js';
4
4
 
5
5
  function a(e) {
6
6
  let { localeSource: t, localeDestination: o, template: a, pathname: l, passLocale: i } = e, n = "";
7
7
  t && (n = `/${t}`);
8
- let s = formatRoutePathname(n + l), c = "";
8
+ let s = i18nFormatRoutePathname(n + l), c = "";
9
9
  o && (c = `/${o}`);
10
- let p = formatRoutePathname(c + a);
10
+ let p = i18nFormatRoutePathname(c + a);
11
11
  if (s === p) return;
12
12
  let u = {
13
13
  source: s,
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var utils = require('@koine/utils');
4
- var formatRoutePathname = require('../../formatRoutePathname.cjs.js');
4
+ var i18nFormatRoutePathname = require('../../i18nFormatRoutePathname.cjs.js');
5
5
 
6
6
  const codeDataRoutesOptions = {
7
7
  permanentRedirects: !1,
@@ -57,10 +57,10 @@ let getCodeDataRoutes = (d, s, { translationFiles: c })=>{
57
57
  optionalCatchAll: RegExp(`${utils.escapeRegExp(r.start)}(.+)${utils.escapeRegExp(r.end)}$`)
58
58
  }
59
59
  };
60
- }(d, s), f = 0;
60
+ }(d, s), m = 0;
61
61
  for(let e = 0; e < c.length; e++){
62
- let { path: a, locale: o, data: m } = c[e];
63
- if (a === s.translationJsonFileName && (f++, !function(e, a, o, d) {
62
+ let { path: a, locale: o, data: f } = c[e];
63
+ if (a === s.translationJsonFileName && (m++, !function(e, a, o, d) {
64
64
  let s = utils.objectFlat(o, a.tokens.idDelimiter);
65
65
  for(let n in s){
66
66
  let l = function(e, { reg: t }) {
@@ -73,7 +73,7 @@ let getCodeDataRoutes = (d, s, { translationFiles: c })=>{
73
73
  }(n, a), o = e.byId[l.routeId], c = function(e, { value: a, locale: n, routeId: l, isCatchAll: o, isOptionalCatchAll: d }, s) {
74
74
  let c = utils.objectSortByKeysMatching({
75
75
  ...s?.pathnames || {},
76
- [n]: formatRoutePathname.formatRoutePathname(a.replace(/\*/g, "").replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (e, t)=>`[${t.trim()}]`), e)
76
+ [n]: i18nFormatRoutePathname.i18nFormatRoutePathname(a.replace(/\*/g, "").replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (e, t)=>`[${t.trim()}]`), e)
77
77
  }, e.defaultLocale), p = {
78
78
  ...s || {},
79
79
  id: l,
@@ -99,7 +99,7 @@ let getCodeDataRoutes = (d, s, { translationFiles: c })=>{
99
99
  e.byId[c.id] = c, !o && (c.params ? (e.dynamicRoutes.push(c.id), e.onlyStaticRoutes = !1) : e.staticRoutes.push(c.id), c.wildcard && e.wildcardIds.push(c.id));
100
100
  }
101
101
  e.byId = utils.objectSort(e.byId);
102
- }(p, u, m, o), d.locales.length === f)) break;
102
+ }(p, u, f, o), d.locales.length === m)) break;
103
103
  }
104
104
  return !function(e) {
105
105
  if (e.wildcardIds.length) for(let t in e.byId)e.wildcardIds.some((e)=>t.startsWith(e) && e !== t) && (e.byId[t].inWildcard = !0);
@@ -1,5 +1,5 @@
1
1
  import { escapeRegExp, objectFlat, objectSortByKeysMatching, changeCaseSnake, objectSort, areEqual } from '@koine/utils';
2
- import { formatRoutePathname } from '../../formatRoutePathname.esm.js';
2
+ import { i18nFormatRoutePathname } from '../../i18nFormatRoutePathname.esm.js';
3
3
 
4
4
  const codeDataRoutesOptions = {
5
5
  permanentRedirects: !1,
@@ -55,10 +55,10 @@ let getCodeDataRoutes = (d, s, { translationFiles: c })=>{
55
55
  optionalCatchAll: RegExp(`${escapeRegExp(r.start)}(.+)${escapeRegExp(r.end)}$`)
56
56
  }
57
57
  };
58
- }(d, s), f = 0;
58
+ }(d, s), m = 0;
59
59
  for(let e = 0; e < c.length; e++){
60
- let { path: a, locale: o, data: m } = c[e];
61
- if (a === s.translationJsonFileName && (f++, !function(e, a, o, d) {
60
+ let { path: a, locale: o, data: f } = c[e];
61
+ if (a === s.translationJsonFileName && (m++, !function(e, a, o, d) {
62
62
  let s = objectFlat(o, a.tokens.idDelimiter);
63
63
  for(let n in s){
64
64
  let l = function(e, { reg: t }) {
@@ -71,7 +71,7 @@ let getCodeDataRoutes = (d, s, { translationFiles: c })=>{
71
71
  }(n, a), o = e.byId[l.routeId], c = function(e, { value: a, locale: n, routeId: l, isCatchAll: o, isOptionalCatchAll: d }, s) {
72
72
  let c = objectSortByKeysMatching({
73
73
  ...s?.pathnames || {},
74
- [n]: formatRoutePathname(a.replace(/\*/g, "").replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (e, t)=>`[${t.trim()}]`), e)
74
+ [n]: i18nFormatRoutePathname(a.replace(/\*/g, "").replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (e, t)=>`[${t.trim()}]`), e)
75
75
  }, e.defaultLocale), p = {
76
76
  ...s || {},
77
77
  id: l,
@@ -97,7 +97,7 @@ let getCodeDataRoutes = (d, s, { translationFiles: c })=>{
97
97
  e.byId[c.id] = c, !o && (c.params ? (e.dynamicRoutes.push(c.id), e.onlyStaticRoutes = !1) : e.staticRoutes.push(c.id), c.wildcard && e.wildcardIds.push(c.id));
98
98
  }
99
99
  e.byId = objectSort(e.byId);
100
- }(p, u, m, o), d.locales.length === f)) break;
100
+ }(p, u, f, o), d.locales.length === m)) break;
101
101
  }
102
102
  return !function(e) {
103
103
  if (e.wildcardIds.length) for(let t in e.byId)e.wildcardIds.some((e)=>t.startsWith(e) && e !== t) && (e.byId[t].inWildcard = !0);
@@ -1 +1,2 @@
1
1
  export * from "./i18nDefaultMetadata";
2
+ export { default } from "./i18nDefaultMetadata";
@@ -1,8 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
3
5
  const i18nDefaultMetadata = {
4
6
  canonical: "",
5
7
  alternates: {}
6
8
  };
7
9
 
10
+ exports.default = i18nDefaultMetadata;
8
11
  exports.i18nDefaultMetadata = i18nDefaultMetadata;
@@ -3,3 +3,4 @@ import type { I18nUtils } from "@koine/i18n";
3
3
  * Default metadata shape for I18n SEO
4
4
  */
5
5
  export declare const i18nDefaultMetadata: I18nUtils.Metadata;
6
+ export default i18nDefaultMetadata;
@@ -1 +1,2 @@
1
1
  export * from "./i18nDefaultMetadata";
2
+ export { default } from "./i18nDefaultMetadata";
@@ -3,4 +3,4 @@ const i18nDefaultMetadata = {
3
3
  alternates: {}
4
4
  };
5
5
 
6
- export { i18nDefaultMetadata };
6
+ export { i18nDefaultMetadata as default, i18nDefaultMetadata };
@@ -0,0 +1,2 @@
1
+ export * from "./i18nFormatRoutePathname";
2
+ export { default } from "./i18nFormatRoutePathname";
@@ -0,0 +1 @@
1
+ exports._default = require('./i18nFormatRoutePathname.cjs.js').default;
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let formatRoutePathname = (e = "", t)=>{
5
+ let i18nFormatRoutePathname = (e = "", t)=>{
6
6
  let { trailingSlash: a } = t || {};
7
7
  return e = ("/" + e + "/").replace(/\/+/g, "/"), a || (e = e.replace(/\/*$/, "")), e || "/";
8
8
  };
9
9
 
10
- exports.default = formatRoutePathname;
11
- exports.formatRoutePathname = formatRoutePathname;
10
+ exports.default = i18nFormatRoutePathname;
11
+ exports.i18nFormatRoutePathname = i18nFormatRoutePathname;
@@ -0,0 +1,2 @@
1
+ export * from './i18nFormatRoutePathname.cjs.js';
2
+ export { _default as default } from './i18nFormatRoutePathname.cjs.default.js';
@@ -0,0 +1,4 @@
1
+ export declare let i18nFormatRoutePathname: (pathname?: string, options?: {
2
+ trailingSlash?: boolean;
3
+ }) => string;
4
+ export default i18nFormatRoutePathname;
@@ -0,0 +1,2 @@
1
+ export * from "./i18nFormatRoutePathname";
2
+ export { default } from "./i18nFormatRoutePathname";
@@ -1,6 +1,6 @@
1
- let formatRoutePathname = (e = "", t)=>{
1
+ let i18nFormatRoutePathname = (e = "", t)=>{
2
2
  let { trailingSlash: a } = t || {};
3
3
  return e = ("/" + e + "/").replace(/\/+/g, "/"), a || (e = e.replace(/\/*$/, "")), e || "/";
4
4
  };
5
5
 
6
- export { formatRoutePathname as default, formatRoutePathname };
6
+ export { i18nFormatRoutePathname as default, i18nFormatRoutePathname };
@@ -0,0 +1,2 @@
1
+ export * from "./i18nInterpolateRouteParams";
2
+ export { default } from "./i18nInterpolateRouteParams";
@@ -0,0 +1 @@
1
+ exports._default = require('./i18nInterpolateRouteParams.cjs.js').default;
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var utils = require('@koine/utils');
6
+ var i18nFormatRoutePathname = require('./i18nFormatRoutePathname.cjs.js');
7
+
8
+ function i18nInterpolateRouteParams(t, n) {
9
+ let o = t.replace(/\./g, "/");
10
+ return "development" === process.env.NODE_ENV && n && o.replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (r, o)=>{
11
+ if (!(o in n)) throw Error("[@koine/i18n]:i18nInterpolateRouteParams, using '" + t + "' without param '" + o + "'");
12
+ if (![
13
+ "string",
14
+ "number"
15
+ ].includes(typeof n[o])) throw Error("[@koine/i18n]:i18nInterpolateRouteParams, using '" + t + "' with unserializable param '" + o + "' (type '" + utils.getType(n[o]) + "')");
16
+ return "";
17
+ }), i18nFormatRoutePathname.i18nFormatRoutePathname(o = o ? n ? o.replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (e, r)=>n[r.trim()] + "") : o : "/");
18
+ }
19
+
20
+ exports.default = i18nInterpolateRouteParams;
21
+ exports.i18nInterpolateRouteParams = i18nInterpolateRouteParams;
@@ -0,0 +1,2 @@
1
+ export * from './i18nInterpolateRouteParams.cjs.js';
2
+ export { _default as default } from './i18nInterpolateRouteParams.cjs.default.js';
@@ -19,7 +19,7 @@ import type { I18nUtils } from "./types";
19
19
  * - `/my/route/[id]`
20
20
  * - `//my/route/[id]`
21
21
  */
22
- export declare function interpolateTo<TRouteId extends string>(value: TRouteId): string;
23
- export declare function interpolateTo<TRouteId extends string>(value: TRouteId, // RouteStrictIdDynamic<TRouteId>,
22
+ export declare function i18nInterpolateRouteParams<TRouteId extends string>(value: TRouteId): string;
23
+ export declare function i18nInterpolateRouteParams<TRouteId extends string>(value: TRouteId, // RouteStrictIdDynamic<TRouteId>,
24
24
  params: I18nUtils.DynamicParams<TRouteId>): string;
25
- export default interpolateTo;
25
+ export default i18nInterpolateRouteParams;
@@ -0,0 +1,2 @@
1
+ export * from "./i18nInterpolateRouteParams";
2
+ export { default } from "./i18nInterpolateRouteParams";
@@ -0,0 +1,16 @@
1
+ import { getType } from '@koine/utils';
2
+ import { i18nFormatRoutePathname } from './i18nFormatRoutePathname.esm.js';
3
+
4
+ function i18nInterpolateRouteParams(t, n) {
5
+ let o = t.replace(/\./g, "/");
6
+ return "development" === process.env.NODE_ENV && n && o.replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (r, o)=>{
7
+ if (!(o in n)) throw Error("[@koine/i18n]:i18nInterpolateRouteParams, using '" + t + "' without param '" + o + "'");
8
+ if (![
9
+ "string",
10
+ "number"
11
+ ].includes(typeof n[o])) throw Error("[@koine/i18n]:i18nInterpolateRouteParams, using '" + t + "' with unserializable param '" + o + "' (type '" + getType(n[o]) + "')");
12
+ return "";
13
+ }), i18nFormatRoutePathname(o = o ? n ? o.replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (e, r)=>n[r.trim()] + "") : o : "/");
14
+ }
15
+
16
+ export { i18nInterpolateRouteParams as default, i18nInterpolateRouteParams };
@@ -0,0 +1,2 @@
1
+ export * from "./i18nRtlLocales";
2
+ export { default } from "./i18nRtlLocales";
@@ -0,0 +1 @@
1
+ exports._default = require('./i18nRtlLocales.cjs.js').default;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- let rtlLocales = [
5
+ let i18nRtlLocales = [
6
6
  "ae",
7
7
  "ar",
8
8
  "arc",
@@ -25,5 +25,5 @@ let rtlLocales = [
25
25
  "yi"
26
26
  ];
27
27
 
28
- exports.default = rtlLocales;
29
- exports.rtlLocales = rtlLocales;
28
+ exports.default = i18nRtlLocales;
29
+ exports.i18nRtlLocales = i18nRtlLocales;
@@ -0,0 +1,2 @@
1
+ export * from './i18nRtlLocales.cjs.js';
2
+ export { _default as default } from './i18nRtlLocales.cjs.default.js';
@@ -6,5 +6,5 @@
6
6
  * @see https://en.wikipedia.org/wiki/Script_(Unicode)
7
7
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo
8
8
  */
9
- export declare let rtlLocales: string[];
10
- export default rtlLocales;
9
+ export declare let i18nRtlLocales: string[];
10
+ export default i18nRtlLocales;
@@ -0,0 +1,2 @@
1
+ export * from "./i18nRtlLocales";
2
+ export { default } from "./i18nRtlLocales";
@@ -1,4 +1,4 @@
1
- let rtlLocales = [
1
+ let i18nRtlLocales = [
2
2
  "ae",
3
3
  "ar",
4
4
  "arc",
@@ -21,4 +21,4 @@ let rtlLocales = [
21
21
  "yi"
22
22
  ];
23
23
 
24
- export { rtlLocales as default, rtlLocales };
24
+ export { i18nRtlLocales as default, i18nRtlLocales };
package/index.cjs.js CHANGED
@@ -1,21 +1,19 @@
1
1
  'use strict';
2
2
 
3
- var formatRoutePathname = require('./formatRoutePathname.cjs.js');
4
3
  var i18nDefaultMetadata = require('./i18nDefaultMetadata.cjs.js');
4
+ var i18nFormatRoutePathname = require('./i18nFormatRoutePathname.cjs.js');
5
5
  var i18nInterpolateParams = require('./i18nInterpolateParams.cjs.js');
6
6
  var i18nInterpolateParamsDeep = require('./i18nInterpolateParamsDeep.cjs.js');
7
+ var i18nInterpolateRouteParams = require('./i18nInterpolateRouteParams.cjs.js');
7
8
  var i18nPluralise = require('./i18nPluralise.cjs.js');
8
- var interpolateTo = require('./interpolateTo.cjs.js');
9
- var rtlLocales = require('./rtlLocales.cjs.js');
10
- var routeHasDynamicPortion = require('./routeHasDynamicPortion.cjs.js');
9
+ var i18nRtlLocales = require('./i18nRtlLocales.cjs.js');
11
10
 
12
11
 
13
12
 
14
- exports.formatRoutePathname = formatRoutePathname.formatRoutePathname;
15
13
  exports.i18nDefaultMetadata = i18nDefaultMetadata.i18nDefaultMetadata;
14
+ exports.i18nFormatRoutePathname = i18nFormatRoutePathname.i18nFormatRoutePathname;
16
15
  exports.i18nInterpolateParams = i18nInterpolateParams.i18nInterpolateParams;
17
16
  exports.i18nInterpolateParamsDeep = i18nInterpolateParamsDeep.i18nInterpolateParamsDeep;
17
+ exports.i18nInterpolateRouteParams = i18nInterpolateRouteParams.i18nInterpolateRouteParams;
18
18
  exports.i18nPluralise = i18nPluralise.i18nPluralise;
19
- exports.interpolateTo = interpolateTo.interpolateTo;
20
- exports.rtlLocales = rtlLocales.rtlLocales;
21
- exports.routeHasDynamicPortion = routeHasDynamicPortion.routeHasDynamicPortion;
19
+ exports.i18nRtlLocales = i18nRtlLocales.i18nRtlLocales;
package/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- export { formatRoutePathname } from "./formatRoutePathname";
2
1
  export { i18nDefaultMetadata } from "./i18nDefaultMetadata";
2
+ export { i18nFormatRoutePathname } from "./i18nFormatRoutePathname";
3
3
  export { i18nInterpolateParams } from "./i18nInterpolateParams";
4
4
  export { i18nInterpolateParamsDeep } from "./i18nInterpolateParamsDeep";
5
+ export { i18nInterpolateRouteParams } from "./i18nInterpolateRouteParams";
5
6
  export { i18nPluralise } from "./i18nPluralise";
6
- export { interpolateTo } from "./interpolateTo";
7
- export { rtlLocales } from "./rtlLocales";
8
- export { routeHasDynamicPortion } from "./routeHasDynamicPortion";
7
+ export { i18nRtlLocales } from "./i18nRtlLocales";
9
8
  export * from "./types";
package/index.esm.js CHANGED
@@ -1,8 +1,7 @@
1
- export { formatRoutePathname } from './formatRoutePathname.esm.js';
2
1
  export { i18nDefaultMetadata } from './i18nDefaultMetadata.esm.js';
2
+ export { i18nFormatRoutePathname } from './i18nFormatRoutePathname.esm.js';
3
3
  export { i18nInterpolateParams } from './i18nInterpolateParams.esm.js';
4
4
  export { i18nInterpolateParamsDeep } from './i18nInterpolateParamsDeep.esm.js';
5
+ export { i18nInterpolateRouteParams } from './i18nInterpolateRouteParams.esm.js';
5
6
  export { i18nPluralise } from './i18nPluralise.esm.js';
6
- export { interpolateTo } from './interpolateTo.esm.js';
7
- export { rtlLocales } from './rtlLocales.esm.js';
8
- export { routeHasDynamicPortion } from './routeHasDynamicPortion.esm.js';
7
+ export { i18nRtlLocales } from './i18nRtlLocales.esm.js';
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.169",
9
- "@koine/utils": "2.0.0-beta.169",
8
+ "@koine/node": "2.0.0-beta.170",
9
+ "@koine/utils": "2.0.0-beta.170",
10
10
  "comment-json": "^4.2.4",
11
11
  "consola": "^3.2.3",
12
12
  "glob": "^11.0.0",
@@ -34,18 +34,18 @@
34
34
  "import": "./index.cjs.mjs",
35
35
  "default": "./index.cjs.js"
36
36
  },
37
- "./formatRoutePathname": {
38
- "module": "./formatRoutePathname.esm.js",
39
- "types": "./formatRoutePathname.esm.d.ts",
40
- "import": "./formatRoutePathname.cjs.mjs",
41
- "default": "./formatRoutePathname.cjs.js"
42
- },
43
37
  "./i18nDefaultMetadata": {
44
38
  "module": "./i18nDefaultMetadata.esm.js",
45
39
  "types": "./i18nDefaultMetadata.esm.d.ts",
46
40
  "import": "./i18nDefaultMetadata.cjs.mjs",
47
41
  "default": "./i18nDefaultMetadata.cjs.js"
48
42
  },
43
+ "./i18nFormatRoutePathname": {
44
+ "module": "./i18nFormatRoutePathname.esm.js",
45
+ "types": "./i18nFormatRoutePathname.esm.d.ts",
46
+ "import": "./i18nFormatRoutePathname.cjs.mjs",
47
+ "default": "./i18nFormatRoutePathname.cjs.js"
48
+ },
49
49
  "./i18nInterpolateParams": {
50
50
  "module": "./i18nInterpolateParams.esm.js",
51
51
  "types": "./i18nInterpolateParams.esm.d.ts",
@@ -58,29 +58,23 @@
58
58
  "import": "./i18nInterpolateParamsDeep.cjs.mjs",
59
59
  "default": "./i18nInterpolateParamsDeep.cjs.js"
60
60
  },
61
+ "./i18nInterpolateRouteParams": {
62
+ "module": "./i18nInterpolateRouteParams.esm.js",
63
+ "types": "./i18nInterpolateRouteParams.esm.d.ts",
64
+ "import": "./i18nInterpolateRouteParams.cjs.mjs",
65
+ "default": "./i18nInterpolateRouteParams.cjs.js"
66
+ },
61
67
  "./i18nPluralise": {
62
68
  "module": "./i18nPluralise.esm.js",
63
69
  "types": "./i18nPluralise.esm.d.ts",
64
70
  "import": "./i18nPluralise.cjs.mjs",
65
71
  "default": "./i18nPluralise.cjs.js"
66
72
  },
67
- "./interpolateTo": {
68
- "module": "./interpolateTo.esm.js",
69
- "types": "./interpolateTo.esm.d.ts",
70
- "import": "./interpolateTo.cjs.mjs",
71
- "default": "./interpolateTo.cjs.js"
72
- },
73
- "./routeHasDynamicPortion": {
74
- "module": "./routeHasDynamicPortion.esm.js",
75
- "types": "./routeHasDynamicPortion.esm.d.ts",
76
- "import": "./routeHasDynamicPortion.cjs.mjs",
77
- "default": "./routeHasDynamicPortion.cjs.js"
78
- },
79
- "./rtlLocales": {
80
- "module": "./rtlLocales.esm.js",
81
- "types": "./rtlLocales.esm.d.ts",
82
- "import": "./rtlLocales.cjs.mjs",
83
- "default": "./rtlLocales.cjs.js"
73
+ "./i18nRtlLocales": {
74
+ "module": "./i18nRtlLocales.esm.js",
75
+ "types": "./i18nRtlLocales.esm.d.ts",
76
+ "import": "./i18nRtlLocales.cjs.mjs",
77
+ "default": "./i18nRtlLocales.cjs.js"
84
78
  },
85
79
  "./compiler": {
86
80
  "module": "./compiler.esm.js",
@@ -116,5 +110,5 @@
116
110
  "module": "./index.esm.js",
117
111
  "main": "./index.cjs.js",
118
112
  "types": "./index.esm.d.ts",
119
- "version": "2.0.0-beta.169"
113
+ "version": "2.0.0-beta.170"
120
114
  }
@@ -1,2 +0,0 @@
1
- export * from "./formatRoutePathname";
2
- export { default } from "./formatRoutePathname";
@@ -1 +0,0 @@
1
- exports._default = require('./formatRoutePathname.cjs.js').default;
@@ -1,2 +0,0 @@
1
- export * from './formatRoutePathname.cjs.js';
2
- export { _default as default } from './formatRoutePathname.cjs.default.js';
@@ -1,4 +0,0 @@
1
- export declare let formatRoutePathname: (pathname?: string, options?: {
2
- trailingSlash?: boolean;
3
- }) => string;
4
- export default formatRoutePathname;
@@ -1,2 +0,0 @@
1
- export * from "./formatRoutePathname";
2
- export { default } from "./formatRoutePathname";
@@ -1,2 +0,0 @@
1
- export * from "./interpolateTo";
2
- export { default } from "./interpolateTo";
@@ -1 +0,0 @@
1
- exports._default = require('./interpolateTo.cjs.js').default;
@@ -1,21 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var utils = require('@koine/utils');
6
- var formatRoutePathname = require('./formatRoutePathname.cjs.js');
7
-
8
- function interpolateTo(t, o) {
9
- let i = t.replace(/\./g, "/");
10
- return "development" === process.env.NODE_ENV && o && i.replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (r, i)=>{
11
- if (!(i in o)) throw Error("[@koine/i18n]:interpolateTo, using '" + t + "' without param '" + i + "'");
12
- if (![
13
- "string",
14
- "number"
15
- ].includes(typeof o[i])) throw Error("[@koine/i18n]:interpolateTo, using '" + t + "' with unserializable param '" + i + "' (type '" + utils.getType(o[i]) + "')");
16
- return "";
17
- }), formatRoutePathname.formatRoutePathname(i = i ? o ? i.replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (e, r)=>o[r.trim()] + "") : i : "/");
18
- }
19
-
20
- exports.default = interpolateTo;
21
- exports.interpolateTo = interpolateTo;
@@ -1,2 +0,0 @@
1
- export * from './interpolateTo.cjs.js';
2
- export { _default as default } from './interpolateTo.cjs.default.js';
@@ -1,2 +0,0 @@
1
- export * from "./interpolateTo";
2
- export { default } from "./interpolateTo";
@@ -1,16 +0,0 @@
1
- import { getType } from '@koine/utils';
2
- import { formatRoutePathname } from './formatRoutePathname.esm.js';
3
-
4
- function interpolateTo(t, o) {
5
- let i = t.replace(/\./g, "/");
6
- return "development" === process.env.NODE_ENV && o && i.replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (r, i)=>{
7
- if (!(i in o)) throw Error("[@koine/i18n]:interpolateTo, using '" + t + "' without param '" + i + "'");
8
- if (![
9
- "string",
10
- "number"
11
- ].includes(typeof o[i])) throw Error("[@koine/i18n]:interpolateTo, using '" + t + "' with unserializable param '" + i + "' (type '" + getType(o[i]) + "')");
12
- return "";
13
- }), formatRoutePathname(i = i ? o ? i.replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (e, r)=>o[r.trim()] + "") : i : "/");
14
- }
15
-
16
- export { interpolateTo as default, interpolateTo };
@@ -1,2 +0,0 @@
1
- export * from "./routeHasDynamicPortion";
2
- export { default } from "./routeHasDynamicPortion";
@@ -1 +0,0 @@
1
- exports._default = require('./routeHasDynamicPortion.cjs.js').default;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- let routeHasDynamicPortion = (t)=>/\[/.test(t);
6
-
7
- exports.default = routeHasDynamicPortion;
8
- exports.routeHasDynamicPortion = routeHasDynamicPortion;
@@ -1,2 +0,0 @@
1
- export * from './routeHasDynamicPortion.cjs.js';
2
- export { _default as default } from './routeHasDynamicPortion.cjs.default.js';
@@ -1,2 +0,0 @@
1
- export declare let routeHasDynamicPortion: (routeIdOrPortion: string) => boolean;
2
- export default routeHasDynamicPortion;
@@ -1,2 +0,0 @@
1
- export * from "./routeHasDynamicPortion";
2
- export { default } from "./routeHasDynamicPortion";
@@ -1,3 +0,0 @@
1
- let routeHasDynamicPortion = (t)=>/\[/.test(t);
2
-
3
- export { routeHasDynamicPortion as default, routeHasDynamicPortion };
@@ -1,2 +0,0 @@
1
- export * from "./rtlLocales";
2
- export { default } from "./rtlLocales";
@@ -1 +0,0 @@
1
- exports._default = require('./rtlLocales.cjs.js').default;
@@ -1,2 +0,0 @@
1
- export * from './rtlLocales.cjs.js';
2
- export { _default as default } from './rtlLocales.cjs.default.js';
@@ -1,2 +0,0 @@
1
- export * from "./rtlLocales";
2
- export { default } from "./rtlLocales";