@koine/i18n 2.0.0-beta.76 → 2.0.0-beta.78

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 (260) hide show
  1. package/README.md +1 -0
  2. package/api.cjs.js +2203 -0
  3. package/api.esm.js +2179 -0
  4. package/compiler-sync.cjs.d.ts +1 -0
  5. package/compiler-sync.cjs.default.js +1 -0
  6. package/compiler-sync.cjs.js +20 -0
  7. package/compiler-sync.cjs.mjs +2 -0
  8. package/compiler-sync.esm.js +16 -0
  9. package/compiler-worker.cjs.d.ts +1 -0
  10. package/compiler-worker.cjs.default.js +1 -0
  11. package/compiler-worker.cjs.js +18 -0
  12. package/compiler-worker.cjs.mjs +2 -0
  13. package/compiler-worker.esm.js +16 -0
  14. package/compiler.cjs.d.ts +1 -0
  15. package/compiler.cjs.default.js +1 -0
  16. package/compiler.cjs.js +21 -0
  17. package/compiler.cjs.mjs +2 -0
  18. package/compiler.esm.js +13 -0
  19. package/formatRoutePathname.cjs.js +12 -0
  20. package/formatRoutePathname.esm.js +10 -0
  21. package/index.cjs.d.ts +1 -0
  22. package/index.cjs.default.js +1 -0
  23. package/index.cjs.js +47 -0
  24. package/index.cjs.mjs +2 -0
  25. package/index.esm.js +42 -0
  26. package/next.cjs.d.ts +1 -0
  27. package/next.cjs.default.js +1 -0
  28. package/next.cjs.js +377 -0
  29. package/next.cjs.mjs +2 -0
  30. package/next.esm.js +353 -0
  31. package/package.json +22 -305
  32. package/actions/helpers-git.js +0 -45
  33. package/actions/helpers-i18n.js +0 -27
  34. package/actions/i18n.js +0 -17
  35. package/adapter-js/code/config.cjs.js +0 -14
  36. package/adapter-js/code/config.js +0 -14
  37. package/adapter-js/code/defaultLocale.js +0 -7
  38. package/adapter-js/code/deriveLocalisedPathnames.js +0 -78
  39. package/adapter-js/code/index.js +0 -123
  40. package/adapter-js/code/isLocale.js +0 -9
  41. package/adapter-js/code/locales.js +0 -8
  42. package/adapter-js/code/pathnameToRouteId.js +0 -20
  43. package/adapter-js/code/routes.js +0 -11
  44. package/adapter-js/code/routesSlim.js +0 -11
  45. package/adapter-js/code/routesSpa.js +0 -11
  46. package/adapter-js/code/tFns.js +0 -34
  47. package/adapter-js/code/tInterpolateParams.js +0 -18
  48. package/adapter-js/code/tPluralise.js +0 -10
  49. package/adapter-js/code/to.js +0 -32
  50. package/adapter-js/code/toFns.js +0 -25
  51. package/adapter-js/code/toFormat.js +0 -56
  52. package/adapter-js/code/toSpa.js +0 -42
  53. package/adapter-js/code/types.js +0 -327
  54. package/adapter-next/code/index.js +0 -54
  55. package/adapter-next/code/next-redirects.js +0 -5
  56. package/adapter-next/code/next-rewrites.js +0 -5
  57. package/adapter-next/code/useCurrentLocalisedPathnames.js +0 -20
  58. package/adapter-next/code/useLocale.js +0 -8
  59. package/adapter-next/code/useRouteId.js +0 -10
  60. package/adapter-next/code/useTo.js +0 -26
  61. package/adapter-next/code/useToSpa.js +0 -34
  62. package/adapter-next/plugin-async.js +0 -11
  63. package/adapter-next/plugin-legacy.js +0 -187
  64. package/adapter-next/plugin-shared.js +0 -39
  65. package/adapter-next/plugin.js +0 -13
  66. package/adapter-next/redirects.js +0 -51
  67. package/adapter-next/rewrites.js +0 -50
  68. package/adapter-next/transformPathname.js +0 -3
  69. package/adapter-next/webpackPluginI18n.js +0 -11
  70. package/adapter-next-translate/code/DynamicNamespaces.js +0 -9
  71. package/adapter-next-translate/code/T.js +0 -31
  72. package/adapter-next-translate/code/TransText.js +0 -9
  73. package/adapter-next-translate/code/getT.js +0 -15
  74. package/adapter-next-translate/code/index.js +0 -49
  75. package/adapter-next-translate/code/nextTranslateI18n.js +0 -19
  76. package/adapter-next-translate/code/useT.js +0 -43
  77. package/cjs/adapter-js/code/config.cjs.d.ts +0 -3
  78. package/cjs/adapter-js/code/config.d.ts +0 -3
  79. package/cjs/adapter-js/code/defaultLocale.d.ts +0 -3
  80. package/cjs/adapter-js/code/deriveLocalisedPathnames.d.ts +0 -2
  81. package/cjs/adapter-js/code/index.d.ts +0 -3
  82. package/cjs/adapter-js/code/isLocale.d.ts +0 -2
  83. package/cjs/adapter-js/code/locales.d.ts +0 -3
  84. package/cjs/adapter-js/code/pathnameToRouteId.d.ts +0 -3
  85. package/cjs/adapter-js/code/routes.d.ts +0 -3
  86. package/cjs/adapter-js/code/routesSlim.d.ts +0 -3
  87. package/cjs/adapter-js/code/routesSpa.d.ts +0 -3
  88. package/cjs/adapter-js/code/tFns.d.ts +0 -3
  89. package/cjs/adapter-js/code/tInterpolateParams.d.ts +0 -3
  90. package/cjs/adapter-js/code/tPluralise.d.ts +0 -2
  91. package/cjs/adapter-js/code/to.d.ts +0 -3
  92. package/cjs/adapter-js/code/toFns.d.ts +0 -3
  93. package/cjs/adapter-js/code/toFormat.d.ts +0 -3
  94. package/cjs/adapter-js/code/toSpa.d.ts +0 -3
  95. package/cjs/adapter-js/code/types.d.ts +0 -3
  96. package/cjs/adapter-next/code/index.d.ts +0 -3
  97. package/cjs/adapter-next/code/next-redirects.d.ts +0 -3
  98. package/cjs/adapter-next/code/next-rewrites.d.ts +0 -3
  99. package/cjs/adapter-next/code/useCurrentLocalisedPathnames.d.ts +0 -2
  100. package/cjs/adapter-next/code/useLocale.d.ts +0 -3
  101. package/cjs/adapter-next/code/useRouteId.d.ts +0 -2
  102. package/cjs/adapter-next/code/useTo.d.ts +0 -2
  103. package/cjs/adapter-next/code/useToSpa.d.ts +0 -2
  104. package/cjs/adapter-next/plugin-async.d.ts +0 -9
  105. package/cjs/adapter-next/plugin-legacy.d.ts +0 -22
  106. package/cjs/adapter-next/plugin-shared.d.ts +0 -13
  107. package/cjs/adapter-next/plugin.d.ts +0 -7
  108. package/cjs/adapter-next/redirects.d.ts +0 -4
  109. package/cjs/adapter-next/rewrites.d.ts +0 -4
  110. package/cjs/adapter-next/transformPathname.d.ts +0 -1
  111. package/cjs/adapter-next/webpackPluginI18n.d.ts +0 -7
  112. package/cjs/adapter-next-translate/code/DynamicNamespaces.d.ts +0 -2
  113. package/cjs/adapter-next-translate/code/T.d.ts +0 -2
  114. package/cjs/adapter-next-translate/code/TransText.d.ts +0 -2
  115. package/cjs/adapter-next-translate/code/getT.d.ts +0 -2
  116. package/cjs/adapter-next-translate/code/index.d.ts +0 -3
  117. package/cjs/adapter-next-translate/code/nextTranslateI18n.d.ts +0 -3
  118. package/cjs/adapter-next-translate/code/useT.d.ts +0 -2
  119. package/cjs/client/formatRoutePathname.d.ts +0 -4
  120. package/cjs/client/index.d.ts +0 -3
  121. package/cjs/client/interpolateTo.d.ts +0 -4
  122. package/cjs/client/routeHasDynamicPortion.d.ts +0 -2
  123. package/cjs/compiler/api.d.ts +0 -30
  124. package/cjs/compiler/code/data-routes.d.ts +0 -19
  125. package/cjs/compiler/code/data-translations.d.ts +0 -13
  126. package/cjs/compiler/code/data.d.ts +0 -33
  127. package/cjs/compiler/code/generate.d.ts +0 -14
  128. package/cjs/compiler/code/index.d.ts +0 -3
  129. package/cjs/compiler/code/tsCompile.d.ts +0 -2
  130. package/cjs/compiler/code/write.d.ts +0 -11
  131. package/cjs/compiler/config.d.ts +0 -12
  132. package/cjs/compiler/helpers.d.ts +0 -2
  133. package/cjs/compiler/input/data-local.d.ts +0 -4
  134. package/cjs/compiler/input/data-remote.d.ts +0 -7
  135. package/cjs/compiler/input/data.d.ts +0 -4
  136. package/cjs/compiler/input/index.d.ts +0 -4
  137. package/cjs/compiler/input/types.d.ts +0 -14
  138. package/cjs/compiler/input/write.d.ts +0 -8
  139. package/cjs/compiler/pluralisation.d.ts +0 -37
  140. package/cjs/compiler/summary/data.d.ts +0 -6
  141. package/cjs/compiler/summary/generate.d.ts +0 -4
  142. package/cjs/compiler/summary/index.d.ts +0 -3
  143. package/cjs/compiler/summary/write.d.ts +0 -10
  144. package/cjs/compiler/types.d.ts +0 -82
  145. package/cjs/compiler-sync.d.ts +0 -4
  146. package/cjs/compiler-worker.d.ts +0 -1
  147. package/cjs/compiler.d.ts +0 -2
  148. package/cjs/i18n/actions/helpers-git.js +0 -45
  149. package/cjs/i18n/actions/helpers-i18n.js +0 -27
  150. package/cjs/i18n/actions/i18n.js +0 -17
  151. package/cjs/i18n/adapter-js/code/config.cjs.js +0 -14
  152. package/cjs/i18n/adapter-js/code/config.js +0 -14
  153. package/cjs/i18n/adapter-js/code/defaultLocale.js +0 -7
  154. package/cjs/i18n/adapter-js/code/deriveLocalisedPathnames.js +0 -78
  155. package/cjs/i18n/adapter-js/code/index.js +0 -123
  156. package/cjs/i18n/adapter-js/code/isLocale.js +0 -9
  157. package/cjs/i18n/adapter-js/code/locales.js +0 -8
  158. package/cjs/i18n/adapter-js/code/pathnameToRouteId.js +0 -20
  159. package/cjs/i18n/adapter-js/code/routes.js +0 -11
  160. package/cjs/i18n/adapter-js/code/routesSlim.js +0 -11
  161. package/cjs/i18n/adapter-js/code/routesSpa.js +0 -11
  162. package/cjs/i18n/adapter-js/code/tFns.js +0 -34
  163. package/cjs/i18n/adapter-js/code/tInterpolateParams.js +0 -18
  164. package/cjs/i18n/adapter-js/code/tPluralise.js +0 -10
  165. package/cjs/i18n/adapter-js/code/to.js +0 -32
  166. package/cjs/i18n/adapter-js/code/toFns.js +0 -25
  167. package/cjs/i18n/adapter-js/code/toFormat.js +0 -56
  168. package/cjs/i18n/adapter-js/code/toSpa.js +0 -42
  169. package/cjs/i18n/adapter-js/code/types.js +0 -327
  170. package/cjs/i18n/adapter-next/code/index.js +0 -54
  171. package/cjs/i18n/adapter-next/code/next-redirects.js +0 -5
  172. package/cjs/i18n/adapter-next/code/next-rewrites.js +0 -5
  173. package/cjs/i18n/adapter-next/code/useCurrentLocalisedPathnames.js +0 -20
  174. package/cjs/i18n/adapter-next/code/useLocale.js +0 -8
  175. package/cjs/i18n/adapter-next/code/useRouteId.js +0 -10
  176. package/cjs/i18n/adapter-next/code/useTo.js +0 -26
  177. package/cjs/i18n/adapter-next/code/useToSpa.js +0 -34
  178. package/cjs/i18n/adapter-next/plugin-async.js +0 -11
  179. package/cjs/i18n/adapter-next/plugin-legacy.js +0 -187
  180. package/cjs/i18n/adapter-next/plugin-shared.js +0 -39
  181. package/cjs/i18n/adapter-next/plugin.js +0 -13
  182. package/cjs/i18n/adapter-next/redirects.js +0 -51
  183. package/cjs/i18n/adapter-next/rewrites.js +0 -50
  184. package/cjs/i18n/adapter-next/transformPathname.js +0 -3
  185. package/cjs/i18n/adapter-next/webpackPluginI18n.js +0 -11
  186. package/cjs/i18n/adapter-next-translate/code/DynamicNamespaces.js +0 -9
  187. package/cjs/i18n/adapter-next-translate/code/T.js +0 -31
  188. package/cjs/i18n/adapter-next-translate/code/TransText.js +0 -9
  189. package/cjs/i18n/adapter-next-translate/code/getT.js +0 -15
  190. package/cjs/i18n/adapter-next-translate/code/index.js +0 -49
  191. package/cjs/i18n/adapter-next-translate/code/nextTranslateI18n.js +0 -19
  192. package/cjs/i18n/adapter-next-translate/code/useT.js +0 -43
  193. package/cjs/i18n/client/formatRoutePathname.js +0 -5
  194. package/cjs/i18n/client/index.js +0 -3
  195. package/cjs/i18n/client/interpolateTo.js +0 -14
  196. package/cjs/i18n/client/routeHasDynamicPortion.js +0 -2
  197. package/cjs/i18n/compiler/api.js +0 -18
  198. package/cjs/i18n/compiler/code/data-routes.js +0 -99
  199. package/cjs/i18n/compiler/code/data-translations.js +0 -86
  200. package/cjs/i18n/compiler/code/data.js +0 -20
  201. package/cjs/i18n/compiler/code/generate.js +0 -46
  202. package/cjs/i18n/compiler/code/index.js +0 -2
  203. package/cjs/i18n/compiler/code/tsCompile.js +0 -27
  204. package/cjs/i18n/compiler/code/write.js +0 -39
  205. package/cjs/i18n/compiler/config.js +0 -13
  206. package/cjs/i18n/compiler/helpers.js +0 -14
  207. package/cjs/i18n/compiler/input/data-local.js +0 -60
  208. package/cjs/i18n/compiler/input/data-remote.js +0 -41
  209. package/cjs/i18n/compiler/input/data.js +0 -11
  210. package/cjs/i18n/compiler/input/index.js +0 -3
  211. package/cjs/i18n/compiler/input/types.js +0 -1
  212. package/cjs/i18n/compiler/input/write.js +0 -15
  213. package/cjs/i18n/compiler/pluralisation.js +0 -59
  214. package/cjs/i18n/compiler/summary/data.js +0 -28
  215. package/cjs/i18n/compiler/summary/generate.js +0 -27
  216. package/cjs/i18n/compiler/summary/index.js +0 -2
  217. package/cjs/i18n/compiler/summary/write.js +0 -18
  218. package/cjs/i18n/compiler/types.js +0 -1
  219. package/cjs/i18n/compiler-sync.js +0 -2
  220. package/cjs/i18n/compiler-worker.js +0 -3
  221. package/cjs/i18n/compiler.js +0 -1
  222. package/cjs/i18n/index.js +0 -2
  223. package/cjs/i18n/next.js +0 -3
  224. package/cjs/i18n/types.js +0 -1
  225. package/cjs/index.d.ts +0 -2
  226. package/cjs/next.d.ts +0 -3
  227. package/cjs/package.json +0 -34
  228. package/cjs/types.d.ts +0 -48
  229. package/client/formatRoutePathname.js +0 -5
  230. package/client/index.js +0 -3
  231. package/client/interpolateTo.js +0 -14
  232. package/client/routeHasDynamicPortion.js +0 -2
  233. package/compiler/api.js +0 -18
  234. package/compiler/code/data-routes.js +0 -99
  235. package/compiler/code/data-translations.js +0 -86
  236. package/compiler/code/data.js +0 -20
  237. package/compiler/code/generate.js +0 -46
  238. package/compiler/code/index.js +0 -2
  239. package/compiler/code/tsCompile.js +0 -27
  240. package/compiler/code/write.js +0 -39
  241. package/compiler/config.js +0 -13
  242. package/compiler/helpers.js +0 -14
  243. package/compiler/input/data-local.js +0 -60
  244. package/compiler/input/data-remote.js +0 -41
  245. package/compiler/input/data.js +0 -11
  246. package/compiler/input/index.js +0 -3
  247. package/compiler/input/types.js +0 -1
  248. package/compiler/input/write.js +0 -15
  249. package/compiler/pluralisation.js +0 -59
  250. package/compiler/summary/data.js +0 -28
  251. package/compiler/summary/generate.js +0 -27
  252. package/compiler/summary/index.js +0 -2
  253. package/compiler/summary/write.js +0 -18
  254. package/compiler/types.js +0 -1
  255. package/compiler-sync.js +0 -2
  256. package/compiler-worker.js +0 -3
  257. package/compiler.js +0 -1
  258. package/index.js +0 -2
  259. package/next.js +0 -3
  260. package/types.js +0 -1
@@ -1,187 +0,0 @@
1
- import { arrayUniqueByProperties as e, normaliseUrlPathname as t } from "@koine/utils";
2
- function n(e, t) {
3
- let { [t]: n, ...l } = e;
4
- return {
5
- [t]: n,
6
- ...l
7
- };
8
- }
9
- function l(e) {
10
- let { pathname: t, template: n } = e, l = t.split("/").filter((e)=>!!e), i = n.split("/").filter((e)=>!!e), r = {};
11
- return {
12
- pathname: l.map((e)=>{
13
- let t = e.endsWith("*"), n = (e = e.replace("*", "")).startsWith("{{") && e.endsWith("}}"), l = n ? e.match(/{{(.+)}}/)?.[1].trim() ?? "" : e.trim(), i = encodeURIComponent(l) + (t ? "*" : "");
14
- return r[l] = {
15
- isDynamic: n,
16
- hasWildcard: t
17
- }, n ? `:${i}` : i;
18
- }).join("/"),
19
- template: i.map((e)=>{
20
- let t = e.startsWith("[") && e.endsWith("]"), n = t ? e.match(/\[(.+)\]/)?.[1].trim() ?? "" : e.trim(), l = r[n]?.hasWildcard, i = encodeURIComponent(n) + (l ? "*" : "");
21
- return t ? `:${i}` : i;
22
- }).join("/")
23
- };
24
- }
25
- function i(e = {}, t, n = "", l = "") {
26
- let r = Object.keys(t).includes("[spa]");
27
- for(let a in t){
28
- let o = t[a], s = `${l}/${a}`;
29
- "string" == typeof o ? (!r || r && [
30
- "[spa]",
31
- "index"
32
- ].includes(a)) && (e[s] = {
33
- template: s,
34
- pathname: o,
35
- wildcard: o.includes("*")
36
- }) : r || i(e, o, n, s);
37
- }
38
- return e;
39
- }
40
- function r(e) {
41
- return e.replace(/\/index$/, "");
42
- }
43
- function a(e) {
44
- let { localeSource: n, localeDestination: i, route: a, usePathnameAsSource: o, permanent: s } = e, { template: c, pathname: u } = l(a), f = n ? `${n}/` : "", p = r(`/${t(f + (o ? u : c))}`), h = i ? `${i}/` : "", m = `/${t(h + u)}`;
45
- if (p !== m) return {
46
- source: p,
47
- destination: m,
48
- permanent: !!s
49
- };
50
- }
51
- function o(e) {
52
- let { localeSource: n, localeDestination: i, localeParam: a, route: o } = e, { pathname: s, template: c } = l(o), u = "";
53
- n ? u = `${n}/` : a && (u = `:${a}/`);
54
- let f = `/${t(u + s)}`, p = "";
55
- i ? p = `${i}/` : a && (p = `:${a}/`);
56
- let h = r(`/${t(p + c)}`);
57
- if (f !== h) return {
58
- source: f,
59
- destination: h
60
- };
61
- }
62
- export let withI18nLegacy = (t)=>{
63
- let { i18nRoutes: l, ...s } = t;
64
- if (!l) return s;
65
- let { locales: c = [
66
- "en"
67
- ], defaultLocale: u = "en", ...f } = t.i18n || {};
68
- s.i18n = {
69
- ...f,
70
- locales: c,
71
- defaultLocale: u
72
- };
73
- let p = {
74
- hideDefaultLocaleInUrl: !0,
75
- localeParam: "",
76
- ...l,
77
- locales: c,
78
- defaultLocale: u
79
- }, h = {
80
- ...s
81
- };
82
- if (p.routes) {
83
- let { redirects: t, rewrites: l } = h;
84
- h.redirects = async ()=>{
85
- let l = function(t) {
86
- let { routes: l, defaultLocale: o, hideDefaultLocaleInUrl: s, localeParam: c, permanent: u, debug: f } = t, p = n(l, o), h = [];
87
- for(let e in p){
88
- let t = i({}, l[e]);
89
- for(let n in t){
90
- let l = t[n];
91
- if (l.pathname !== r(n)) {
92
- let t = e === o && !s, n = e === o && s;
93
- c ? t ? h.push(a({
94
- localeDestination: e,
95
- route: l,
96
- permanent: u
97
- })) : n ? h.push(a({
98
- localeSource: e,
99
- route: l,
100
- permanent: u
101
- })) : e !== o ? h.push(a({
102
- localeSource: e,
103
- localeDestination: e,
104
- route: l,
105
- permanent: u
106
- })) : h.push(a({
107
- route: l,
108
- permanent: u
109
- })) : t ? h.push(a({
110
- localeDestination: e,
111
- route: l,
112
- permanent: u
113
- })) : e !== o ? h.push(a({
114
- localeSource: e,
115
- localeDestination: e,
116
- route: l,
117
- permanent: u
118
- })) : h.push(a({
119
- route: l,
120
- permanent: u
121
- }));
122
- }
123
- }
124
- }
125
- let m = e(h.filter(Boolean), [
126
- "source",
127
- "destination"
128
- ]).map((e)=>c ? e : {
129
- ...e,
130
- locale: !1
131
- });
132
- return f && console.info("[@koine/next/plugin-legacy:generateRedirects]", m), m;
133
- }(p);
134
- return t ? [
135
- ...l,
136
- ...await t()
137
- ] : l;
138
- }, h.rewrites = async ()=>{
139
- let t = function(t) {
140
- let { routes: l, defaultLocale: a, hideDefaultLocaleInUrl: s, localeParam: c, debug: u } = t, f = n(l, a), p = [];
141
- for(let e in f){
142
- let t = i({}, l[e]);
143
- for(let n in t){
144
- let l = t[n], i = e === a && !s, u = e === a && s;
145
- c ? u ? p.push(o({
146
- localeDestination: e,
147
- route: l
148
- })) : p.push(o({
149
- localeParam: c,
150
- route: l
151
- })) : l.pathname !== r(n) && (e !== a || i ? p.push(o({
152
- localeSource: e,
153
- route: l
154
- })) : p.push(o({
155
- route: l
156
- })));
157
- }
158
- }
159
- let h = e(p.filter(Boolean), [
160
- "source",
161
- "destination"
162
- ]);
163
- return u && console.info("[@koine/next/plugin-legacy:generateRewrites]", h), h;
164
- }(p);
165
- if (l) {
166
- let e = await l();
167
- return Array.isArray(e) ? {
168
- beforeFiles: t,
169
- afterFiles: e,
170
- fallback: []
171
- } : {
172
- ...e,
173
- beforeFiles: [
174
- ...t,
175
- ...e.beforeFiles || []
176
- ]
177
- };
178
- }
179
- return {
180
- beforeFiles: t,
181
- afterFiles: [],
182
- fallback: []
183
- };
184
- };
185
- }
186
- return h;
187
- };
@@ -1,39 +0,0 @@
1
- import { ContextReplacementPlugin as e } from "webpack";
2
- import { generateRedirects as t } from "./redirects";
3
- import { generateRewrites as r } from "./rewrites";
4
- export let tweakNextConfig = (t, r)=>{
5
- let { defaultLocale: o, locales: i, appRouterLocaleParamName: l } = t;
6
- return l ? delete r.i18n : (r.i18n = r.i18n || {
7
- locales: i,
8
- defaultLocale: o
9
- }, r.i18n.locales = i, r.i18n.defaultLocale = o), r.webpack = (t)=>(t.plugins.push(new e(/^date-fns[/\\]locale$/, RegExp(`\\.[/\\\\](${i.join("|")})[/\\\\]index\\.js$`))), t), r;
10
- };
11
- export let getRedirects = async (e, { appRouterLocaleParamName: r, permanentRedirects: o }, i)=>{
12
- let l = t(i.config, i.code.routes.byId, i.code.options.routes, r, o);
13
- return e ? [
14
- ...l,
15
- ...await e()
16
- ] : l;
17
- };
18
- export let getRewrites = async (e, { appRouterLocaleParamName: t }, o)=>{
19
- let i = r(o.config, o.code.routes.byId, o.code.options.routes, t);
20
- if (e) {
21
- let t = await e();
22
- return Array.isArray(t) ? {
23
- beforeFiles: i,
24
- afterFiles: t,
25
- fallback: []
26
- } : {
27
- ...t,
28
- beforeFiles: [
29
- ...i,
30
- ...t.beforeFiles || []
31
- ]
32
- };
33
- }
34
- return {
35
- beforeFiles: i,
36
- afterFiles: [],
37
- fallback: []
38
- };
39
- };
@@ -1,13 +0,0 @@
1
- import { createRequire as r } from "node:module";
2
- import { i18nCompilerSync as t } from "../compiler-sync";
3
- import { getRedirects as e, getRewrites as i, tweakNextConfig as o } from "./plugin-shared";
4
- let n = r(import.meta.url);
5
- export let withI18n = (r = {})=>{
6
- let { i18nCompiler: l, redirects: m, rewrites: p, ...a } = r, c = a;
7
- if (!l) return c;
8
- let d = t(l);
9
- if ((c = o(d.config, c)).redirects = ()=>e(m, l, d), c.rewrites = ()=>i(p, l, d), "next-translate" === l.code.adapter) try {
10
- c = n("next-translate-plugin")(c);
11
- } catch (r) {}
12
- return c;
13
- };
@@ -1,51 +0,0 @@
1
- import { arrayUniqueByProperties as e, escapeRegExp as o } from "@koine/utils";
2
- import { formatRoutePathname as t } from "../client";
3
- import { transformPathname as l } from "./transformPathname";
4
- function r(e) {
5
- let { localeSource: o, localeDestination: l, template: r, pathname: i, permanent: a } = e, n = t((o ? `${o}/` : "") + r), c = t((l ? `${l}/` : "") + i);
6
- if (n !== c) return {
7
- source: n,
8
- destination: c,
9
- permanent: !!a
10
- };
11
- }
12
- export let generateRedirects = (t, i, a, n = "", c = !1)=>{
13
- let { defaultLocale: s, hideDefaultLocaleInUrl: p } = t, u = RegExp(o(a.tokens.idDelimiter), "g"), m = [];
14
- for(let e in i){
15
- let o = i[e], t = i[e].pathnames;
16
- for(let i in t){
17
- let a = t[i], f = l(e.replace(u, "/"), o.wildcard), d = l(a, o.wildcard);
18
- if (o.inWildcard) break;
19
- let h = i === s, D = h && !p, g = h && p, k = {
20
- template: f,
21
- pathname: d,
22
- permanent: c
23
- };
24
- n ? D ? m.push(r({
25
- ...k,
26
- localeDestination: i
27
- })) : g ? m.push(r({
28
- ...k,
29
- localeSource: i
30
- })) : h ? m.push(r(k)) : m.push(r({
31
- ...k,
32
- localeSource: i,
33
- localeDestination: i
34
- })) : d !== f && (D ? m.push(r({
35
- ...k,
36
- localeDestination: i
37
- })) : h ? m.push(r(k)) : m.push(r({
38
- ...k,
39
- localeSource: i,
40
- localeDestination: i
41
- })));
42
- }
43
- }
44
- return e(m.filter(Boolean), [
45
- "source",
46
- "destination"
47
- ]).sort((e, o)=>e.source.localeCompare(o.source)).map((e)=>n ? e : {
48
- ...e,
49
- locale: !1
50
- });
51
- };
@@ -1,50 +0,0 @@
1
- import { arrayUniqueByProperties as e, escapeRegExp as t } from "@koine/utils";
2
- import { formatRoutePathname as l } from "../client";
3
- import { transformPathname as r } from "./transformPathname";
4
- function o(e) {
5
- let { localeSource: t, localeDestination: r, template: o, pathname: i } = e, a = "";
6
- t && (a = `/${t}`);
7
- let n = l(a + i), c = "";
8
- r && (c = `/${r}`);
9
- let s = l(c + o);
10
- if (n !== s) return {
11
- source: n,
12
- destination: s
13
- };
14
- }
15
- let i = (e, t = "", l, r, i, a)=>{
16
- let { defaultLocale: n, hideDefaultLocaleInUrl: c } = e, s = l === n && c, u = {
17
- config: e,
18
- template: r,
19
- pathname: i
20
- };
21
- t ? s ? a.push(o({
22
- ...u,
23
- localeDestination: l
24
- })) : a.push(o({
25
- ...u,
26
- localeSource: l,
27
- localeDestination: l
28
- })) : i !== r && (s ? a.push(o(u)) : a.push({
29
- ...o({
30
- ...u,
31
- localeSource: l
32
- }),
33
- locale: !1
34
- }));
35
- };
36
- export let generateRewrites = (l, o, a, n = "")=>{
37
- let c = RegExp(t(a.tokens.idDelimiter), "g"), s = [];
38
- for(let e in o){
39
- let t = o[e], a = o[e].pathnames;
40
- for(let o in a){
41
- let u = a[o], p = e.replace(c, "/");
42
- if (t.inWildcard) break;
43
- i(l, n, o, r(p), r(u), s), t.wildcard && i(l, n, o, r(p, t.wildcard), r(u, t.wildcard), s);
44
- }
45
- }
46
- return e(s.filter(Boolean), [
47
- "source",
48
- "destination"
49
- ]).sort((e, t)=>e.source.localeCompare(t.source));
50
- };
@@ -1,3 +0,0 @@
1
- export function transformPathname(e, t) {
2
- return "/" + e.split("/").filter(Boolean).map((e)=>e.startsWith("[[...") ? `:${encodeURIComponent(e.slice(5, -2))}` : e.startsWith("[[") ? `:${encodeURIComponent(e.slice(2, -2))}` : e.startsWith("[") ? `:${encodeURIComponent(e.slice(1, -1))}` : `${encodeURIComponent(e)}`).join("/") + (t ? "/:wildcard*" : "");
3
- }
@@ -1,11 +0,0 @@
1
- import { i18nCompiler as o } from "../compiler";
2
- export class I18nWebpackPlugin {
3
- constructor(o){
4
- this.opts = o;
5
- }
6
- apply(s) {
7
- s.hooks && s.hooks.beforeCompile.tapPromise("I18nWebpackPlugin", async (s, p)=>{
8
- await o(this.opts), console.log("done async!!!!!!!!!!!!!!!!!!!!!!!", this.opts), p();
9
- });
10
- }
11
- }
@@ -1,9 +0,0 @@
1
- export default (()=>`
2
- "use client";
3
-
4
- import _DynamicNamespaces from "next-translate/DynamicNamespaces";
5
-
6
- export const DynamicNamespaces = _DynamicNamespaces;
7
-
8
- export default DynamicNamespaces;
9
- `);
@@ -1,31 +0,0 @@
1
- export default (()=>`
2
- "use client";
3
-
4
- import type { TransProps } from "next-translate";
5
- import Trans from "next-translate/Trans";
6
- import type { I18n } from "./types";
7
-
8
- export type TProps<
9
- TNamespace extends I18n.TranslateNamespace | undefined = undefined,
10
- > =
11
- | (Omit<TransProps, "i18nKey" | "ns"> & {
12
- i18nKey: I18n.TranslationsAllPaths;
13
- })
14
- | (Omit<TransProps, "i18nKey" | "ns"> & {
15
- ns: TNamespace;
16
- i18nKey: I18n.TranslationsPaths<TNamespace>;
17
- });
18
-
19
- const TypedT = <
20
- TNamespace extends I18n.TranslateNamespace | undefined = undefined,
21
- >(
22
- props: TProps<TNamespace>,
23
- ) =>
24
- (<Trans {...(props as TransProps)} />) as React.ReactElement<
25
- TProps<TNamespace>
26
- >;
27
-
28
- export const T = Trans as typeof TypedT;
29
-
30
- export default T;
31
- `);
@@ -1,9 +0,0 @@
1
- export default (()=>`
2
- "use client";
3
-
4
- import _TransText from "next-translate/TransText";
5
-
6
- export const TransText = _TransText;
7
-
8
- export default TransText;
9
- `);
@@ -1,15 +0,0 @@
1
- export default (()=>`
2
- import _getT from "next-translate/getT";
3
- import type { I18n } from "./types";
4
-
5
- export type GetT = <
6
- TNamespace extends I18n.TranslateNamespace | undefined = undefined,
7
- >(
8
- locale?: I18n.Locale,
9
- namespace?: TNamespace,
10
- ) => Promise<I18n.Translate<TNamespace>>;
11
-
12
- export const getT = _getT as GetT;
13
-
14
- export default getT;
15
- `);
@@ -1,49 +0,0 @@
1
- import e from "./DynamicNamespaces";
2
- import n from "./T";
3
- import t from "./TransText";
4
- import m from "./getT";
5
- import s from "./nextTranslateI18n";
6
- import a from "./useT";
7
- export default (()=>({
8
- dependsOn: [
9
- "next"
10
- ],
11
- needsTranslationsFiles: !0,
12
- files: [
13
- {
14
- name: "DynamicNamespaces",
15
- fn: e,
16
- ext: "tsx",
17
- index: !0
18
- },
19
- {
20
- name: "getT",
21
- fn: m,
22
- ext: "ts",
23
- index: !0
24
- },
25
- {
26
- name: "nextTranslateI18n",
27
- fn: s,
28
- ext: "js"
29
- },
30
- {
31
- name: "T",
32
- fn: n,
33
- ext: "tsx",
34
- index: !0
35
- },
36
- {
37
- name: "TransText",
38
- fn: t,
39
- ext: "tsx",
40
- index: !0
41
- },
42
- {
43
- name: "useT",
44
- fn: a,
45
- ext: "ts",
46
- index: !0
47
- }
48
- ]
49
- }));
@@ -1,19 +0,0 @@
1
- export default (({ config: a })=>`
2
- /**
3
- * Get 'next-translate' configuration
4
- *
5
- * @see https://github.com/vinissimus/next-translate#how-are-translations-loaded
6
- *
7
- * @param {Omit<Partial<import("next-translate").I18nConfig>, "pages"> & { pages: Record<string, import("./types").I18n.TranslateNamespace[]> }} config
8
- */
9
- module.exports = (config = { pages: {} }) => {
10
- return {
11
- locales: [${a.locales.map((a)=>`"${a}"`).join(", ")}],
12
- defaultLocale: "${a.defaultLocale}",
13
- logBuild: false,
14
- // logger: () => void 0,
15
- loadLocaleFrom: (locale, namespace) => import(\`./translations/\${locale}/\${namespace}.json\`).then((m) => m.default),
16
- ...config,
17
- };
18
- }
19
- `);
@@ -1,43 +0,0 @@
1
- export default (()=>`
2
- "use client";
3
-
4
- import { useMemo } from "react";
5
- import useTranslation from "next-translate/useTranslation";
6
- import type { I18n } from "./types";
7
-
8
- /**
9
- * Wrap next-translate useTranslations for type safety and adds TranslationShortcut
10
- * as second/thir argument.
11
- *
12
- * @see https://github.com/vinissimus/next-translate/issues/513#issuecomment-779826418
13
- *
14
- * About the typescript support for translation strings see:
15
- * - https://github.com/vinissimus/next-translate/issues/721
16
- */
17
- export const useT = <TNamespace extends I18n.TranslateNamespace>(namespace: TNamespace) => {
18
- const t = useTranslation().t;
19
- const tMemoized = useMemo(
20
- () =>
21
- function <
22
- TPath extends I18n.TranslationsPaths<I18n.TranslationsDictionary[TNamespace]>,
23
- TReturn = I18n.TranslationAtPathFromNamespace<TNamespace, TPath>,
24
- >(s: TPath, q?: I18n.TranslationQuery, o?: I18n.TranslationOptions): TReturn {
25
- return t(
26
- (namespace ? namespace + ":" + s : s) as string,
27
- q === "obj" || q === "" ? null : q,
28
- q === "obj" || o === "obj"
29
- ? { returnObjects: true }
30
- : q === "" || o === ""
31
- ? { fallback: "" }
32
- : o,
33
- ) as TReturn;
34
- // ) as TReturn extends (undefined | never | unknown) ? TranslateReturn<I18n.TranslationQuery, I18n.TranslationOptions> : TReturn;
35
- // );
36
- },
37
- [t, namespace],
38
- );
39
- return tMemoized;
40
- };
41
-
42
- export default useT;
43
- `);
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const adapter: I18nCompiler.AdpaterCreator;
3
- export default adapter;
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ options }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ routes }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ routes }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ routes }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config, options, translations }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ options }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config, routes, options }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config, options }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config, input, routes, options, }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const adapter: I18nCompiler.AdpaterCreator;
3
- export default adapter;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config, routes, options }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,3 +0,0 @@
1
- import type { I18nCompiler } from "../../compiler/types";
2
- declare const _default: ({ config, routes, options }: I18nCompiler.AdapterArg) => string;
3
- export default _default;
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;