gt-tanstack-start 11.0.0-odysseus.9 → 11.0.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,150 @@
1
1
  # gt-tanstack-start
2
2
 
3
+ ## 11.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - gt-i18n@1.0.1
9
+ - gt-react@11.0.1
10
+ - @generaltranslation/react-core@11.0.1
11
+
12
+ ## 11.0.0
13
+
14
+ ### Major Changes
15
+
16
+ - [#1439](https://github.com/generaltranslation/gt/pull/1439) [`e12fb17`](https://github.com/generaltranslation/gt/commit/e12fb17d41cfa5fa231e64fe70423434739ea985) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Prepare Odysseus major releases for core runtime packages.
17
+
18
+ ### Patch Changes
19
+
20
+ - [#1439](https://github.com/generaltranslation/gt/pull/1439) [`7a9dbe3`](https://github.com/generaltranslation/gt/commit/7a9dbe3c188787a39ee1de78f54c92dff470b502) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Clean up stale package metadata and align TanStack Start package entry points.
21
+
22
+ - [#1439](https://github.com/generaltranslation/gt/pull/1439) [`b3bb391`](https://github.com/generaltranslation/gt/commit/b3bb391d33041680e2d62b6a7c9b05662946544f) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Store cookie names in I18nConfig so custom cookie names work before the condition store is initialized.
23
+ - `gt-i18n`: Removed the unused React locale cookie name from the shared GT config type.
24
+ - `@generaltranslation/react-core`: `ReactI18nConfig` now accepts `localeCookieName`, `regionCookieName`, and `enableI18nCookieName`, exposes getters that fall back to the default names, and exports the default storage names from the `pure` entrypoint.
25
+ - `gt-next`: Imports default cookie names from the React Core `pure` entrypoint instead of the removed React Core cookie constants subpath.
26
+ - `gt-react`: The browser condition store now resolves cookie names from `I18nConfig` instead of hardcoding the defaults, so custom cookie names passed to `initializeGT()` are honored for both reads and writes.
27
+ - `gt-react-native`: Native condition storage now resolves its store keys from `I18nConfig`, matching `gt-react` behavior.
28
+ - `gt-tanstack-start`: `parseLocale()` reads and writes the locale cookie using the configured cookie name instead of the default.
29
+
30
+ - [#1439](https://github.com/generaltranslation/gt/pull/1439) [`d48604e`](https://github.com/generaltranslation/gt/commit/d48604e2171aa84c76873cacb6eb8d43c2f17546) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Trigger an odysseus prerelease patch for all publishable packages.
31
+
32
+ - [#1439](https://github.com/generaltranslation/gt/pull/1439) [`2c46baf`](https://github.com/generaltranslation/gt/commit/2c46baf137400613495e3fe2865865b5506edece) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Persist TanStack Start locale resolution through the browser locale cookie.
33
+ Allow React i18n config checks to work across bundled react-core entrypoints.
34
+
35
+ - [#1439](https://github.com/generaltranslation/gt/pull/1439) [`efbd970`](https://github.com/generaltranslation/gt/commit/efbd9704d43912e3febb888e7acb3670fc9e70fc) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Consolidate TanStack Start package entrypoint exports.
36
+
37
+ - [#1439](https://github.com/generaltranslation/gt/pull/1439) [`9804aa4`](https://github.com/generaltranslation/gt/commit/9804aa460c07ec36d2e667d79a839720a1e011e8) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - Remove three orphaned, never-imported files:
38
+ - `gt-tanstack-start`: `condition-store/WritableConditionStore.ts` (an orphaned local copy; the package uses gt-i18n's writable condition store).
39
+ - `gt-react-native`: `utils/utils.ts` (`readAuthFromEnv`, no consumers).
40
+ - `gt-i18n`: `i18n-cache/translations-manager/utils/types/translations-manager.ts` (unreferenced `TranslationsManagerConfig` type).
41
+
42
+ - Updated dependencies [[`463a8db`](https://github.com/generaltranslation/gt/commit/463a8dbb03bde35f2f229dfdabfe117197d4527b), [`37e0080`](https://github.com/generaltranslation/gt/commit/37e0080b2c072840cf6c0f1c66a8f0f3a54e17e5), [`5bfd0a7`](https://github.com/generaltranslation/gt/commit/5bfd0a73e286bf76ae26f9178171aeca1c53ecc5), [`8870496`](https://github.com/generaltranslation/gt/commit/88704963eb74e81401994681ce7cdae3ba91b6c0), [`7a9dbe3`](https://github.com/generaltranslation/gt/commit/7a9dbe3c188787a39ee1de78f54c92dff470b502), [`1212135`](https://github.com/generaltranslation/gt/commit/1212135e4e09ed754756cac2805bc3a139408dc1), [`04f419d`](https://github.com/generaltranslation/gt/commit/04f419d65e69db3eb4adb8ee6299c0ddee153135), [`bd52e5e`](https://github.com/generaltranslation/gt/commit/bd52e5ef3fb38a63d9bac8a4af08ff93402c0749), [`b72c30b`](https://github.com/generaltranslation/gt/commit/b72c30bc603562310a51b656fb003f1486315a8a), [`72e9e16`](https://github.com/generaltranslation/gt/commit/72e9e1643797be8e4ae1453897fd0b023fce2674), [`42a440f`](https://github.com/generaltranslation/gt/commit/42a440ff3420bdbdb35ed24f9a5af1c9040eaf66), [`fd22c68`](https://github.com/generaltranslation/gt/commit/fd22c68978af50ce519dc06c7b887d3fa67181ae), [`bea8233`](https://github.com/generaltranslation/gt/commit/bea8233d8b055980483cb2e226157f6adcbd8c2b), [`8870496`](https://github.com/generaltranslation/gt/commit/88704963eb74e81401994681ce7cdae3ba91b6c0), [`5736d58`](https://github.com/generaltranslation/gt/commit/5736d585b8285ef56cc6f412799308969ac786c0), [`8d2e84e`](https://github.com/generaltranslation/gt/commit/8d2e84e5083bb740815004bec90eaa341be7aff5), [`04b5064`](https://github.com/generaltranslation/gt/commit/04b50645675abb9e927a82056b249b50f0907fcc), [`4335432`](https://github.com/generaltranslation/gt/commit/43354326beb16e13784b0c82faad447768bb8404), [`04c285c`](https://github.com/generaltranslation/gt/commit/04c285c7b44f5404918cd4c80336dddf412472e9), [`947fe0c`](https://github.com/generaltranslation/gt/commit/947fe0c97a2821a0980cd3e779252ea0078e80f8), [`5adeede`](https://github.com/generaltranslation/gt/commit/5adeede157922d547a33a078d0f527f572c9a8b4), [`e026c42`](https://github.com/generaltranslation/gt/commit/e026c42bc137e9865b548daee7238e6a458a5662), [`328795b`](https://github.com/generaltranslation/gt/commit/328795bf730296658a57b7132bbd1e0bbff2fd62), [`1f53e42`](https://github.com/generaltranslation/gt/commit/1f53e420e9a6475f85cf27e1cd0c9c89f4beeb36), [`b3bb391`](https://github.com/generaltranslation/gt/commit/b3bb391d33041680e2d62b6a7c9b05662946544f), [`d48604e`](https://github.com/generaltranslation/gt/commit/d48604e2171aa84c76873cacb6eb8d43c2f17546), [`e12fb17`](https://github.com/generaltranslation/gt/commit/e12fb17d41cfa5fa231e64fe70423434739ea985), [`44bc998`](https://github.com/generaltranslation/gt/commit/44bc998abf813ea4a96ade6c2632e1143034bd45), [`5752fe8`](https://github.com/generaltranslation/gt/commit/5752fe81bf5b5deaae878638e0de99959bf719be), [`7744c55`](https://github.com/generaltranslation/gt/commit/7744c557d37c85ce3626681410cc0cd622374ecf), [`b7d44dc`](https://github.com/generaltranslation/gt/commit/b7d44dc2d79ac3332a0ed55da0ba130b6896f756), [`9561761`](https://github.com/generaltranslation/gt/commit/9561761c3ab72a5e39327415b3274eccc63f4ffe), [`72c6a85`](https://github.com/generaltranslation/gt/commit/72c6a85cc3ca025ebdeb006dbdd865e935ec77ae), [`3d95277`](https://github.com/generaltranslation/gt/commit/3d95277a057b28fffc73b3fa616210bdcb447e85), [`97dc7f4`](https://github.com/generaltranslation/gt/commit/97dc7f4818476a319a54b1519e994a62d5a9a3a5), [`c1e0a0f`](https://github.com/generaltranslation/gt/commit/c1e0a0f837da440eeed84af10b553dee24bfc936), [`85a0c19`](https://github.com/generaltranslation/gt/commit/85a0c1998a6500233affd8c1987551170584c782), [`693288d`](https://github.com/generaltranslation/gt/commit/693288d632c42b923920a2fdd9ae2babc1bc28f5), [`463a8db`](https://github.com/generaltranslation/gt/commit/463a8dbb03bde35f2f229dfdabfe117197d4527b), [`e343775`](https://github.com/generaltranslation/gt/commit/e343775d8a41ce3eea03dd319b90497a9744cc4f), [`40db0c5`](https://github.com/generaltranslation/gt/commit/40db0c54a58e82d693d8a16d19fe5071baabecdc), [`8a2f7ee`](https://github.com/generaltranslation/gt/commit/8a2f7ee79f4b890fb1aaf47f42bb844334899793), [`c5364f9`](https://github.com/generaltranslation/gt/commit/c5364f977ffb4b387ad39206e6ed626bbeec56f3), [`2e85ebd`](https://github.com/generaltranslation/gt/commit/2e85ebd1528a4f99a8e36e1d8d6714a639040596), [`2c46baf`](https://github.com/generaltranslation/gt/commit/2c46baf137400613495e3fe2865865b5506edece), [`d5cf2d3`](https://github.com/generaltranslation/gt/commit/d5cf2d34f412ad49e8b2818fe788b870a5964d65), [`9e78cf0`](https://github.com/generaltranslation/gt/commit/9e78cf07db58bfe6063bcd0b217553176c9681bd), [`4986567`](https://github.com/generaltranslation/gt/commit/498656728741898a56ae348a536107bd92f95c04), [`795edc8`](https://github.com/generaltranslation/gt/commit/795edc8a2b3e91fc9801d726f4b5cd6fbbc98fb0), [`d863bcf`](https://github.com/generaltranslation/gt/commit/d863bcf05770c336c98b2b2fae8534c90f00df51), [`11ecf87`](https://github.com/generaltranslation/gt/commit/11ecf876a1221b9dbce9fc0c0f0804101558c8a7), [`03bae6d`](https://github.com/generaltranslation/gt/commit/03bae6d3b4791107781cb800c1ae7ac4f675705c), [`5d42608`](https://github.com/generaltranslation/gt/commit/5d426089f04f37dd7369620e9db3e6512f06eee8), [`9804aa4`](https://github.com/generaltranslation/gt/commit/9804aa460c07ec36d2e667d79a839720a1e011e8), [`338e5e8`](https://github.com/generaltranslation/gt/commit/338e5e8a42354c7d288d9be960ebd1d58adfd402), [`8834c51`](https://github.com/generaltranslation/gt/commit/8834c518ac84259706f2b603fd024ad13a9072ee), [`2ca78ec`](https://github.com/generaltranslation/gt/commit/2ca78ec4805639c10c7b200c8dee660b55eddf15), [`195f009`](https://github.com/generaltranslation/gt/commit/195f00910c2a675a6f9da327e19e3d3c5e44e26b)]:
43
+ - gt-i18n@1.0.0
44
+ - @generaltranslation/react-core@11.0.0
45
+ - gt-react@11.0.0
46
+ - generaltranslation@9.0.0
47
+
48
+ ## 11.0.0-odysseus.16
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies [463a8db]
53
+ - Updated dependencies [b72c30b]
54
+ - Updated dependencies [bea8233]
55
+ - Updated dependencies [5736d58]
56
+ - Updated dependencies [1f53e42]
57
+ - Updated dependencies [7744c55]
58
+ - Updated dependencies [463a8db]
59
+ - Updated dependencies [e343775]
60
+ - Updated dependencies [40db0c5]
61
+ - Updated dependencies [d5cf2d3]
62
+ - gt-i18n@1.0.0-odysseus.9
63
+ - @generaltranslation/react-core@11.0.0-odysseus.16
64
+ - gt-react@11.0.0-odysseus.16
65
+ - generaltranslation@9.0.0-odysseus.6
66
+
67
+ ## 11.0.0-odysseus.15
68
+
69
+ ### Patch Changes
70
+
71
+ - Updated dependencies [04f419d]
72
+ - Updated dependencies [72e9e16]
73
+ - Updated dependencies [42a440f]
74
+ - Updated dependencies [8d2e84e]
75
+ - Updated dependencies [5adeede]
76
+ - Updated dependencies [c5364f9]
77
+ - Updated dependencies [2e85ebd]
78
+ - Updated dependencies [195f009]
79
+ - @generaltranslation/react-core@11.0.0-odysseus.15
80
+ - generaltranslation@9.0.0-odysseus.5
81
+ - gt-i18n@1.0.0-odysseus.8
82
+ - gt-react@11.0.0-odysseus.15
83
+
84
+ ## 11.0.0-odysseus.14
85
+
86
+ ### Patch Changes
87
+
88
+ - 0cd7813: Store cookie names in I18nConfig so custom cookie names work before the condition store is initialized.
89
+ - `gt-i18n`: Removed the unused React locale cookie name from the shared GT config type.
90
+ - `@generaltranslation/react-core`: `ReactI18nConfig` now accepts `localeCookieName`, `regionCookieName`, and `enableI18nCookieName`, exposes getters that fall back to the default names, and exports the default storage names from the `pure` entrypoint.
91
+ - `gt-next`: Imports default cookie names from the React Core `pure` entrypoint instead of the removed React Core cookie constants subpath.
92
+ - `gt-react`: The browser condition store now resolves cookie names from `I18nConfig` instead of hardcoding the defaults, so custom cookie names passed to `initializeGT()` are honored for both reads and writes.
93
+ - `gt-react-native`: Native condition storage now resolves its store keys from `I18nConfig`, matching `gt-react` behavior.
94
+ - `gt-tanstack-start`: `parseLocale()` reads and writes the locale cookie using the configured cookie name instead of the default.
95
+
96
+ - Updated dependencies [ab61565]
97
+ - Updated dependencies [0cd7813]
98
+ - gt-i18n@1.0.0-odysseus.7
99
+ - @generaltranslation/react-core@11.0.0-odysseus.14
100
+ - gt-react@11.0.0-odysseus.14
101
+
102
+ ## 11.0.0-odysseus.13
103
+
104
+ ### Patch Changes
105
+
106
+ - Updated dependencies [a2b9677]
107
+ - Updated dependencies [41371e0]
108
+ - gt-i18n@1.0.0-odysseus.6
109
+ - gt-react@11.0.0-odysseus.13
110
+ - @generaltranslation/react-core@11.0.0-odysseus.13
111
+
112
+ ## 11.0.0-odysseus.12
113
+
114
+ ### Patch Changes
115
+
116
+ - cde28be: Consolidate TanStack Start package entrypoint exports.
117
+ - Updated dependencies [7be23bc]
118
+ - @generaltranslation/react-core@11.0.0-odysseus.12
119
+ - gt-react@11.0.0-odysseus.12
120
+
121
+ ## 11.0.0-odysseus.11
122
+
123
+ ### Patch Changes
124
+
125
+ - @generaltranslation/react-core@11.0.0-odysseus.11
126
+ - gt-react@11.0.0-odysseus.11
127
+
128
+ ## 11.0.0-odysseus.10
129
+
130
+ ### Patch Changes
131
+
132
+ - 07f74f0: Clean up stale package metadata and align TanStack Start package entry points.
133
+ - Updated dependencies [432fa49]
134
+ - Updated dependencies [07f74f0]
135
+ - Updated dependencies [432fa49]
136
+ - Updated dependencies [ee34fea]
137
+ - Updated dependencies [bcba6fd]
138
+ - Updated dependencies [933916e]
139
+ - Updated dependencies [b7b3eaf]
140
+ - Updated dependencies [dfb5fc9]
141
+ - Updated dependencies [4a5f8e8]
142
+ - Updated dependencies [288c9f8]
143
+ - Updated dependencies [083d306]
144
+ - gt-i18n@1.0.0-odysseus.5
145
+ - gt-react@11.0.0-odysseus.10
146
+ - @generaltranslation/react-core@11.0.0-odysseus.10
147
+
3
148
  ## 11.0.0-odysseus.9
4
149
 
5
150
  ### Patch Changes
@@ -157,6 +302,78 @@
157
302
 
158
303
  ### Patch Changes
159
304
 
305
+ - Updated dependencies []:
306
+ - gt-i18n@0.9.4
307
+ - gt-react@10.19.18
308
+ - @generaltranslation/react-core@1.8.20
309
+
310
+ ## 0.4.29
311
+
312
+ ### Patch Changes
313
+
314
+ - Updated dependencies [[`6945a98`](https://github.com/generaltranslation/gt/commit/6945a9871ea260dd999dcb2246c48b21134721f6)]:
315
+ - @generaltranslation/react-core@1.8.25
316
+ - generaltranslation@8.2.19
317
+ - gt-i18n@0.9.9
318
+ - gt-react@10.20.5
319
+
320
+ ## 0.4.28
321
+
322
+ ### Patch Changes
323
+
324
+ - Updated dependencies []:
325
+ - gt-i18n@0.9.8
326
+ - gt-react@10.20.4
327
+ - @generaltranslation/react-core@1.8.24
328
+
329
+ ## 0.4.27
330
+
331
+ ### Patch Changes
332
+
333
+ - Updated dependencies [[`9709a2f`](https://github.com/generaltranslation/gt/commit/9709a2f2b97b9d8239298e39bb31e57692bbffd8)]:
334
+ - generaltranslation@8.2.18
335
+ - gt-i18n@0.9.7
336
+ - gt-react@10.20.3
337
+ - @generaltranslation/react-core@1.8.23
338
+
339
+ ## 0.4.26
340
+
341
+ ### Patch Changes
342
+
343
+ - Updated dependencies [[`3197028`](https://github.com/generaltranslation/gt/commit/319702855a7b129f95217d41be9f2402680a2f01)]:
344
+ - generaltranslation@8.2.17
345
+ - gt-i18n@0.9.6
346
+ - gt-react@10.20.2
347
+ - @generaltranslation/react-core@1.8.22
348
+
349
+ ## 0.4.25
350
+
351
+ ### Patch Changes
352
+
353
+ - Updated dependencies []:
354
+ - gt-react@10.20.1
355
+
356
+ ## 0.4.24
357
+
358
+ ### Patch Changes
359
+
360
+ - Updated dependencies []:
361
+ - gt-react@10.20.0
362
+
363
+ ## 0.4.23
364
+
365
+ ### Patch Changes
366
+
367
+ - Updated dependencies [[`e041312`](https://github.com/generaltranslation/gt/commit/e04131263dd61e469db977bcc196dc1283e773d0)]:
368
+ - generaltranslation@8.2.16
369
+ - gt-i18n@0.9.5
370
+ - gt-react@10.19.19
371
+ - @generaltranslation/react-core@1.8.21
372
+
373
+ ## 0.4.22
374
+
375
+ ### Patch Changes
376
+
160
377
  - Updated dependencies []:
161
378
  - gt-i18n@0.9.4
162
379
  - gt-react@10.19.18
@@ -1,16 +1,15 @@
1
- "use client";
2
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- let gt_react = require("gt-react");
4
2
  let _tanstack_react_start = require("@tanstack/react-start");
5
3
  let _tanstack_react_start_server = require("@tanstack/react-start/server");
6
- let gt_i18n_internal = require("gt-i18n/internal");
4
+ let _generaltranslation_react_core_pure = require("@generaltranslation/react-core/pure");
5
+ let gt_react = require("gt-react");
7
6
  //#region src/functions/parseLocale.ts
8
7
  const determineLocale = (0, _tanstack_react_start.createIsomorphicFn)().server(determineLocaleServer).client(determineLocaleClient);
9
8
  /**
10
9
  * Resolve the user's locale for the current TanStack Start request or browser.
11
10
  */
12
11
  function parseLocale() {
13
- const i18nConfig = (0, gt_i18n_internal.getI18nConfig)();
12
+ const i18nConfig = (0, _generaltranslation_react_core_pure.getI18nConfig)();
14
13
  return determineLocale({
15
14
  defaultLocale: i18nConfig.getDefaultLocale(),
16
15
  locales: i18nConfig.getLocales(),
@@ -18,18 +17,20 @@ function parseLocale() {
18
17
  });
19
18
  }
20
19
  function determineLocaleServer({ defaultLocale, locales, customMapping }) {
20
+ const i18nConfig = (0, _generaltranslation_react_core_pure.getI18nConfig)();
21
+ const localeCookieName = i18nConfig.getLocaleCookieName();
21
22
  const candidates = [];
22
- const cookie = (0, _tanstack_react_start_server.getCookie)(gt_react.defaultLocaleCookieName);
23
+ const cookie = (0, _tanstack_react_start_server.getCookie)(localeCookieName);
23
24
  if (cookie) candidates.push(cookie);
24
25
  const headers = (0, _tanstack_react_start_server.getRequestHeader)("accept-language")?.split(",").map((item) => item.split(";")?.[0].trim()) || [];
25
26
  candidates.push(...headers);
26
27
  if (candidates.length === 0) console.warn("gt-tanstack-start(server): no locales could be determined for this request");
27
- const locale = (0, gt_i18n_internal.getI18nConfig)().resolveSupportedLocale(candidates, {
28
+ const locale = i18nConfig.resolveSupportedLocale(candidates, {
28
29
  defaultLocale,
29
30
  locales,
30
31
  customMapping
31
32
  });
32
- (0, _tanstack_react_start_server.setCookie)(gt_react.defaultLocaleCookieName, locale, {
33
+ (0, _tanstack_react_start_server.setCookie)(localeCookieName, locale, {
33
34
  path: "/",
34
35
  sameSite: "lax",
35
36
  maxAge: 3600 * 24 * 365
@@ -37,11 +38,13 @@ function determineLocaleServer({ defaultLocale, locales, customMapping }) {
37
38
  return locale;
38
39
  }
39
40
  function determineLocaleClient({ defaultLocale, locales, customMapping }) {
41
+ const i18nConfig = (0, _generaltranslation_react_core_pure.getI18nConfig)();
42
+ const localeCookieName = i18nConfig.getLocaleCookieName();
40
43
  const candidates = [];
41
- const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${gt_react.defaultLocaleCookieName}=`))?.slice(gt_react.defaultLocaleCookieName.length + 1);
44
+ const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${localeCookieName}=`))?.slice(localeCookieName.length + 1);
42
45
  if (cookie) candidates.push(cookie);
43
46
  if (candidates.length === 0) console.warn("gt-tanstack-start(client): no locales could be determined for this request");
44
- return (0, gt_i18n_internal.getI18nConfig)().resolveSupportedLocale(candidates, {
47
+ return i18nConfig.resolveSupportedLocale(candidates, {
45
48
  defaultLocale,
46
49
  locales,
47
50
  customMapping
@@ -254,4 +257,4 @@ Object.defineProperty(exports, "useTranslations", {
254
257
  }
255
258
  });
256
259
 
257
- //# sourceMappingURL=index.client.cjs.map
260
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../src/functions/parseLocale.ts"],"sourcesContent":["import { createIsomorphicFn } from '@tanstack/react-start';\nimport {\n getRequestHeader,\n getCookie,\n setCookie,\n} from '@tanstack/react-start/server';\nimport { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport type { LocaleResolverConfig } from 'gt-i18n/internal/types';\n\nexport const determineLocale = createIsomorphicFn()\n .server(determineLocaleServer)\n .client(determineLocaleClient);\n\n/**\n * Resolve the user's locale for the current TanStack Start request or browser.\n */\nexport function parseLocale(): string {\n const i18nConfig = getI18nConfig();\n return determineLocale({\n defaultLocale: i18nConfig.getDefaultLocale(),\n locales: i18nConfig.getLocales(),\n customMapping: i18nConfig.getCustomMapping(),\n });\n}\n\nfunction determineLocaleServer({\n defaultLocale,\n locales,\n customMapping,\n}: LocaleResolverConfig) {\n const i18nConfig = getI18nConfig();\n const localeCookieName = i18nConfig.getLocaleCookieName();\n const candidates: string[] = [];\n\n const cookie = getCookie(localeCookieName);\n if (cookie) candidates.push(cookie);\n\n const headers =\n getRequestHeader('accept-language')\n ?.split(',')\n .map((item) => item.split(';')?.[0].trim()) || [];\n candidates.push(...headers);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(server): no locales could be determined for this request'\n );\n }\n\n const locale = i18nConfig.resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n\n setCookie(localeCookieName, locale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n\n return locale;\n}\n\nfunction determineLocaleClient({\n defaultLocale,\n locales,\n customMapping,\n}: LocaleResolverConfig) {\n const i18nConfig = getI18nConfig();\n const localeCookieName = i18nConfig.getLocaleCookieName();\n const candidates: string[] = [];\n\n const cookie = document.cookie\n .split('; ')\n .find((row) => row.startsWith(`${localeCookieName}=`))\n ?.slice(localeCookieName.length + 1);\n if (cookie) candidates.push(cookie);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(client): no locales could be determined for this request'\n );\n }\n\n return i18nConfig.resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n}\n"],"mappings":";;;;;;AASA,MAAa,mBAAA,GAAA,sBAAA,qBAAsC,CAChD,OAAO,sBAAsB,CAC7B,OAAO,sBAAsB;;;;AAKhC,SAAgB,cAAsB;CACpC,MAAM,cAAA,GAAA,oCAAA,gBAA4B;AAClC,QAAO,gBAAgB;EACrB,eAAe,WAAW,kBAAkB;EAC5C,SAAS,WAAW,YAAY;EAChC,eAAe,WAAW,kBAAkB;EAC7C,CAAC;;AAGJ,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACuB;CACvB,MAAM,cAAA,GAAA,oCAAA,gBAA4B;CAClC,MAAM,mBAAmB,WAAW,qBAAqB;CACzD,MAAM,aAAuB,EAAE;CAE/B,MAAM,UAAA,GAAA,6BAAA,WAAmB,iBAAiB;AAC1C,KAAI,OAAQ,YAAW,KAAK,OAAO;CAEnC,MAAM,WAAA,GAAA,6BAAA,kBACa,kBAAkB,EAC/B,MAAM,IAAI,CACX,KAAK,SAAS,KAAK,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE;AACrD,YAAW,KAAK,GAAG,QAAQ;AAE3B,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;CAGH,MAAM,SAAS,WAAW,uBAAuB,YAAY;EAC3D;EACA;EACA;EACD,CAAC;AAEF,EAAA,GAAA,6BAAA,WAAU,kBAAkB,QAAQ;EAClC,MAAM;EACN,UAAU;EACV,QAAQ,OAAU,KAAK;EACxB,CAAC;AAEF,QAAO;;AAGT,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACuB;CACvB,MAAM,cAAA,GAAA,oCAAA,gBAA4B;CAClC,MAAM,mBAAmB,WAAW,qBAAqB;CACzD,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,SAAS,OACrB,MAAM,KAAK,CACX,MAAM,QAAQ,IAAI,WAAW,GAAG,iBAAiB,GAAG,CAAC,EACpD,MAAM,iBAAiB,SAAS,EAAE;AACtC,KAAI,OAAQ,YAAW,KAAK,OAAO;AAEnC,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;AAGH,QAAO,WAAW,uBAAuB,YAAY;EACnD;EACA;EACA;EACD,CAAC"}
@@ -7,4 +7,4 @@ import { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Pl
7
7
  declare function parseLocale(): string;
8
8
  //#endregion
9
9
  export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, parseLocale, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations };
10
- //# sourceMappingURL=index.types.d.cts.map
10
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/functions/parseLocale.ts"],"mappings":";;;;;;iBAgBgB,WAAA,CAAA"}
@@ -6,4 +6,4 @@ import { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Pl
6
6
  declare function parseLocale(): string;
7
7
  //#endregion
8
8
  export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, parseLocale, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations };
9
- //# sourceMappingURL=index.types.d.mts.map
9
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/functions/parseLocale.ts"],"mappings":";;;;;iBAgBgB,WAAA,CAAA"}
@@ -1,8 +1,7 @@
1
- "use client";
2
- import { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, defaultLocaleCookieName, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations } from "gt-react";
3
1
  import { createIsomorphicFn } from "@tanstack/react-start";
4
2
  import { getCookie, getRequestHeader, setCookie } from "@tanstack/react-start/server";
5
- import { getI18nConfig } from "gt-i18n/internal";
3
+ import { getI18nConfig } from "@generaltranslation/react-core/pure";
4
+ import { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations } from "gt-react";
6
5
  //#region src/functions/parseLocale.ts
7
6
  const determineLocale = createIsomorphicFn().server(determineLocaleServer).client(determineLocaleClient);
8
7
  /**
@@ -17,18 +16,20 @@ function parseLocale() {
17
16
  });
18
17
  }
19
18
  function determineLocaleServer({ defaultLocale, locales, customMapping }) {
19
+ const i18nConfig = getI18nConfig();
20
+ const localeCookieName = i18nConfig.getLocaleCookieName();
20
21
  const candidates = [];
21
- const cookie = getCookie(defaultLocaleCookieName);
22
+ const cookie = getCookie(localeCookieName);
22
23
  if (cookie) candidates.push(cookie);
23
24
  const headers = getRequestHeader("accept-language")?.split(",").map((item) => item.split(";")?.[0].trim()) || [];
24
25
  candidates.push(...headers);
25
26
  if (candidates.length === 0) console.warn("gt-tanstack-start(server): no locales could be determined for this request");
26
- const locale = getI18nConfig().resolveSupportedLocale(candidates, {
27
+ const locale = i18nConfig.resolveSupportedLocale(candidates, {
27
28
  defaultLocale,
28
29
  locales,
29
30
  customMapping
30
31
  });
31
- setCookie(defaultLocaleCookieName, locale, {
32
+ setCookie(localeCookieName, locale, {
32
33
  path: "/",
33
34
  sameSite: "lax",
34
35
  maxAge: 3600 * 24 * 365
@@ -36,11 +37,13 @@ function determineLocaleServer({ defaultLocale, locales, customMapping }) {
36
37
  return locale;
37
38
  }
38
39
  function determineLocaleClient({ defaultLocale, locales, customMapping }) {
40
+ const i18nConfig = getI18nConfig();
41
+ const localeCookieName = i18nConfig.getLocaleCookieName();
39
42
  const candidates = [];
40
- const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${defaultLocaleCookieName}=`))?.slice(defaultLocaleCookieName.length + 1);
43
+ const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${localeCookieName}=`))?.slice(localeCookieName.length + 1);
41
44
  if (cookie) candidates.push(cookie);
42
45
  if (candidates.length === 0) console.warn("gt-tanstack-start(client): no locales could be determined for this request");
43
- return getI18nConfig().resolveSupportedLocale(candidates, {
46
+ return i18nConfig.resolveSupportedLocale(candidates, {
44
47
  defaultLocale,
45
48
  locales,
46
49
  customMapping
@@ -49,4 +52,4 @@ function determineLocaleClient({ defaultLocale, locales, customMapping }) {
49
52
  //#endregion
50
53
  export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, parseLocale, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations };
51
54
 
52
- //# sourceMappingURL=index.client.mjs.map
55
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/functions/parseLocale.ts"],"sourcesContent":["import { createIsomorphicFn } from '@tanstack/react-start';\nimport {\n getRequestHeader,\n getCookie,\n setCookie,\n} from '@tanstack/react-start/server';\nimport { getI18nConfig } from '@generaltranslation/react-core/pure';\nimport type { LocaleResolverConfig } from 'gt-i18n/internal/types';\n\nexport const determineLocale = createIsomorphicFn()\n .server(determineLocaleServer)\n .client(determineLocaleClient);\n\n/**\n * Resolve the user's locale for the current TanStack Start request or browser.\n */\nexport function parseLocale(): string {\n const i18nConfig = getI18nConfig();\n return determineLocale({\n defaultLocale: i18nConfig.getDefaultLocale(),\n locales: i18nConfig.getLocales(),\n customMapping: i18nConfig.getCustomMapping(),\n });\n}\n\nfunction determineLocaleServer({\n defaultLocale,\n locales,\n customMapping,\n}: LocaleResolverConfig) {\n const i18nConfig = getI18nConfig();\n const localeCookieName = i18nConfig.getLocaleCookieName();\n const candidates: string[] = [];\n\n const cookie = getCookie(localeCookieName);\n if (cookie) candidates.push(cookie);\n\n const headers =\n getRequestHeader('accept-language')\n ?.split(',')\n .map((item) => item.split(';')?.[0].trim()) || [];\n candidates.push(...headers);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(server): no locales could be determined for this request'\n );\n }\n\n const locale = i18nConfig.resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n\n setCookie(localeCookieName, locale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n\n return locale;\n}\n\nfunction determineLocaleClient({\n defaultLocale,\n locales,\n customMapping,\n}: LocaleResolverConfig) {\n const i18nConfig = getI18nConfig();\n const localeCookieName = i18nConfig.getLocaleCookieName();\n const candidates: string[] = [];\n\n const cookie = document.cookie\n .split('; ')\n .find((row) => row.startsWith(`${localeCookieName}=`))\n ?.slice(localeCookieName.length + 1);\n if (cookie) candidates.push(cookie);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(client): no locales could be determined for this request'\n );\n }\n\n return i18nConfig.resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n}\n"],"mappings":";;;;;AASA,MAAa,kBAAkB,oBAAoB,CAChD,OAAO,sBAAsB,CAC7B,OAAO,sBAAsB;;;;AAKhC,SAAgB,cAAsB;CACpC,MAAM,aAAa,eAAe;AAClC,QAAO,gBAAgB;EACrB,eAAe,WAAW,kBAAkB;EAC5C,SAAS,WAAW,YAAY;EAChC,eAAe,WAAW,kBAAkB;EAC7C,CAAC;;AAGJ,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACuB;CACvB,MAAM,aAAa,eAAe;CAClC,MAAM,mBAAmB,WAAW,qBAAqB;CACzD,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,UAAU,iBAAiB;AAC1C,KAAI,OAAQ,YAAW,KAAK,OAAO;CAEnC,MAAM,UACJ,iBAAiB,kBAAkB,EAC/B,MAAM,IAAI,CACX,KAAK,SAAS,KAAK,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE;AACrD,YAAW,KAAK,GAAG,QAAQ;AAE3B,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;CAGH,MAAM,SAAS,WAAW,uBAAuB,YAAY;EAC3D;EACA;EACA;EACD,CAAC;AAEF,WAAU,kBAAkB,QAAQ;EAClC,MAAM;EACN,UAAU;EACV,QAAQ,OAAU,KAAK;EACxB,CAAC;AAEF,QAAO;;AAGT,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACuB;CACvB,MAAM,aAAa,eAAe;CAClC,MAAM,mBAAmB,WAAW,qBAAqB;CACzD,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,SAAS,OACrB,MAAM,KAAK,CACX,MAAM,QAAQ,IAAI,WAAW,GAAG,iBAAiB,GAAG,CAAC,EACpD,MAAM,iBAAiB,SAAS,EAAE;AACtC,KAAI,OAAQ,YAAW,KAAK,OAAO;AAEnC,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;AAGH,QAAO,WAAW,uBAAuB,YAAY;EACnD;EACA;EACA;EACD,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "gt-tanstack-start",
3
- "version": "11.0.0-odysseus.9",
3
+ "version": "11.0.1",
4
4
  "description": "TanStack Start integration for General Translation",
5
- "main": "./dist/index.client.cjs",
6
- "module": "./dist/index.client.mjs",
7
- "types": "./dist/index.types.d.cts",
5
+ "main": "./dist/index.cjs",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.cts",
8
8
  "files": [
9
9
  "dist",
10
10
  "CHANGELOG.md"
@@ -16,10 +16,10 @@
16
16
  "@tanstack/react-start": ">=1.159.0"
17
17
  },
18
18
  "dependencies": {
19
- "gt-react": "11.0.0-odysseus.9",
20
- "@generaltranslation/react-core": "11.0.0-odysseus.9",
21
- "gt-i18n": "1.0.0-odysseus.4",
22
- "generaltranslation": "9.0.0-odysseus.4"
19
+ "@generaltranslation/react-core": "11.0.1",
20
+ "gt-react": "11.0.1",
21
+ "gt-i18n": "1.0.1",
22
+ "generaltranslation": "9.0.0"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
@@ -41,55 +41,15 @@
41
41
  },
42
42
  "exports": {
43
43
  ".": {
44
- "react-server": {
45
- "require": {
46
- "types": "./dist/index.types.d.cts",
47
- "default": "./dist/index.server.cjs"
48
- },
49
- "import": {
50
- "types": "./dist/index.types.d.mts",
51
- "default": "./dist/index.server.mjs"
52
- },
53
- "default": "./dist/index.server.mjs"
54
- },
55
- "browser": {
56
- "require": {
57
- "types": "./dist/index.types.d.cts",
58
- "default": "./dist/index.client.cjs"
59
- },
60
- "import": {
61
- "types": "./dist/index.types.d.mts",
62
- "default": "./dist/index.client.mjs"
63
- },
64
- "default": "./dist/index.client.mjs"
65
- },
66
44
  "require": {
67
- "types": "./dist/index.types.d.cts",
68
- "default": "./dist/index.server.cjs"
45
+ "types": "./dist/index.d.cts",
46
+ "default": "./dist/index.cjs"
69
47
  },
70
48
  "import": {
71
- "types": "./dist/index.types.d.mts",
72
- "default": "./dist/index.server.mjs"
49
+ "types": "./dist/index.d.mts",
50
+ "default": "./dist/index.mjs"
73
51
  },
74
- "default": "./dist/index.server.mjs"
75
- },
76
- "./types": {
77
- "types": "./dist/types.d.cts"
78
- }
79
- },
80
- "typesVersions": {
81
- "*": {
82
- "types": [
83
- "./dist/types.d.cts"
84
- ]
85
- }
86
- },
87
- "compilerOptions": {
88
- "baseUrl": ".",
89
- "paths": {
90
- "gt-tanstack-start/types": [
91
- "./dist/types.d.cts"
92
- ]
52
+ "default": "./dist/index.mjs"
93
53
  }
94
54
  },
95
55
  "keywords": [
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.client.cjs","names":["defaultLocaleCookieName"],"sources":["../src/functions/parseLocale.ts"],"sourcesContent":["import { defaultLocaleCookieName } from 'gt-react';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport {\n getRequestHeader,\n getCookie,\n setCookie,\n} from '@tanstack/react-start/server';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\nexport const determineLocale = createIsomorphicFn()\n .server(determineLocaleServer)\n .client(determineLocaleClient);\n\n/**\n * Resolve the user's locale for the current TanStack Start request or browser.\n */\nexport function parseLocale(): string {\n const i18nConfig = getI18nConfig();\n return determineLocale({\n defaultLocale: i18nConfig.getDefaultLocale(),\n locales: i18nConfig.getLocales(),\n customMapping: i18nConfig.getCustomMapping(),\n });\n}\n\nfunction determineLocaleServer({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = getCookie(defaultLocaleCookieName);\n if (cookie) candidates.push(cookie);\n\n const headers =\n getRequestHeader('accept-language')\n ?.split(',')\n .map((item) => item.split(';')?.[0].trim()) || [];\n candidates.push(...headers);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(server): no locales could be determined for this request'\n );\n }\n\n const locale = getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n\n setCookie(defaultLocaleCookieName, locale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n\n return locale;\n}\n\nfunction determineLocaleClient({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = document.cookie\n .split('; ')\n .find((row) => row.startsWith(`${defaultLocaleCookieName}=`))\n ?.slice(defaultLocaleCookieName.length + 1);\n if (cookie) candidates.push(cookie);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(client): no locales could be determined for this request'\n );\n }\n\n return getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n}\n"],"mappings":";;;;;;;AAUA,MAAa,mBAAA,GAAA,sBAAA,qBAAsC,CAChD,OAAO,sBAAsB,CAC7B,OAAO,sBAAsB;;;;AAKhC,SAAgB,cAAsB;CACpC,MAAM,cAAA,GAAA,iBAAA,gBAA4B;AAClC,QAAO,gBAAgB;EACrB,eAAe,WAAW,kBAAkB;EAC5C,SAAS,WAAW,YAAY;EAChC,eAAe,WAAW,kBAAkB;EAC7C,CAAC;;AAGJ,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,UAAA,GAAA,6BAAA,WAAmBA,SAAAA,wBAAwB;AACjD,KAAI,OAAQ,YAAW,KAAK,OAAO;CAEnC,MAAM,WAAA,GAAA,6BAAA,kBACa,kBAAkB,EAC/B,MAAM,IAAI,CACX,KAAK,SAAS,KAAK,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE;AACrD,YAAW,KAAK,GAAG,QAAQ;AAE3B,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;CAGH,MAAM,UAAA,GAAA,iBAAA,gBAAwB,CAAC,uBAAuB,YAAY;EAChE;EACA;EACA;EACD,CAAC;AAEF,EAAA,GAAA,6BAAA,WAAUA,SAAAA,yBAAyB,QAAQ;EACzC,MAAM;EACN,UAAU;EACV,QAAQ,OAAU,KAAK;EACxB,CAAC;AAEF,QAAO;;AAGT,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,SAAS,OACrB,MAAM,KAAK,CACX,MAAM,QAAQ,IAAI,WAAW,GAAGA,SAAAA,wBAAwB,GAAG,CAAC,EAC3D,MAAMA,SAAAA,wBAAwB,SAAS,EAAE;AAC7C,KAAI,OAAQ,YAAW,KAAK,OAAO;AAEnC,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;AAGH,SAAA,GAAA,iBAAA,gBAAsB,CAAC,uBAAuB,YAAY;EACxD;EACA;EACA;EACD,CAAC"}
@@ -1,10 +0,0 @@
1
- import { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations } from "gt-react";
2
-
3
- //#region src/functions/parseLocale.d.ts
4
- /**
5
- * Resolve the user's locale for the current TanStack Start request or browser.
6
- */
7
- declare function parseLocale(): string;
8
- //#endregion
9
- export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, parseLocale, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations };
10
- //# sourceMappingURL=index.client.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.client.d.cts","names":[],"sources":["../src/functions/parseLocale.ts"],"mappings":";;;;;;iBAiBgB,WAAA,CAAA"}
@@ -1,9 +0,0 @@
1
- import { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations } from "gt-react";
2
- //#region src/functions/parseLocale.d.ts
3
- /**
4
- * Resolve the user's locale for the current TanStack Start request or browser.
5
- */
6
- declare function parseLocale(): string;
7
- //#endregion
8
- export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, parseLocale, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations };
9
- //# sourceMappingURL=index.client.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.client.d.mts","names":[],"sources":["../src/functions/parseLocale.ts"],"mappings":";;;;;iBAiBgB,WAAA,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.client.mjs","names":[],"sources":["../src/functions/parseLocale.ts"],"sourcesContent":["import { defaultLocaleCookieName } from 'gt-react';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport {\n getRequestHeader,\n getCookie,\n setCookie,\n} from '@tanstack/react-start/server';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\nexport const determineLocale = createIsomorphicFn()\n .server(determineLocaleServer)\n .client(determineLocaleClient);\n\n/**\n * Resolve the user's locale for the current TanStack Start request or browser.\n */\nexport function parseLocale(): string {\n const i18nConfig = getI18nConfig();\n return determineLocale({\n defaultLocale: i18nConfig.getDefaultLocale(),\n locales: i18nConfig.getLocales(),\n customMapping: i18nConfig.getCustomMapping(),\n });\n}\n\nfunction determineLocaleServer({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = getCookie(defaultLocaleCookieName);\n if (cookie) candidates.push(cookie);\n\n const headers =\n getRequestHeader('accept-language')\n ?.split(',')\n .map((item) => item.split(';')?.[0].trim()) || [];\n candidates.push(...headers);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(server): no locales could be determined for this request'\n );\n }\n\n const locale = getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n\n setCookie(defaultLocaleCookieName, locale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n\n return locale;\n}\n\nfunction determineLocaleClient({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = document.cookie\n .split('; ')\n .find((row) => row.startsWith(`${defaultLocaleCookieName}=`))\n ?.slice(defaultLocaleCookieName.length + 1);\n if (cookie) candidates.push(cookie);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(client): no locales could be determined for this request'\n );\n }\n\n return getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n}\n"],"mappings":";;;;;;AAUA,MAAa,kBAAkB,oBAAoB,CAChD,OAAO,sBAAsB,CAC7B,OAAO,sBAAsB;;;;AAKhC,SAAgB,cAAsB;CACpC,MAAM,aAAa,eAAe;AAClC,QAAO,gBAAgB;EACrB,eAAe,WAAW,kBAAkB;EAC5C,SAAS,WAAW,YAAY;EAChC,eAAe,WAAW,kBAAkB;EAC7C,CAAC;;AAGJ,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,UAAU,wBAAwB;AACjD,KAAI,OAAQ,YAAW,KAAK,OAAO;CAEnC,MAAM,UACJ,iBAAiB,kBAAkB,EAC/B,MAAM,IAAI,CACX,KAAK,SAAS,KAAK,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE;AACrD,YAAW,KAAK,GAAG,QAAQ;AAE3B,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;CAGH,MAAM,SAAS,eAAe,CAAC,uBAAuB,YAAY;EAChE;EACA;EACA;EACD,CAAC;AAEF,WAAU,yBAAyB,QAAQ;EACzC,MAAM;EACN,UAAU;EACV,QAAQ,OAAU,KAAK;EACxB,CAAC;AAEF,QAAO;;AAGT,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,SAAS,OACrB,MAAM,KAAK,CACX,MAAM,QAAQ,IAAI,WAAW,GAAG,wBAAwB,GAAG,CAAC,EAC3D,MAAM,wBAAwB,SAAS,EAAE;AAC7C,KAAI,OAAQ,YAAW,KAAK,OAAO;AAEnC,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;AAGH,QAAO,eAAe,CAAC,uBAAuB,YAAY;EACxD;EACA;EACA;EACD,CAAC"}
@@ -1,256 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let gt_react = require("gt-react");
3
- let _tanstack_react_start = require("@tanstack/react-start");
4
- let _tanstack_react_start_server = require("@tanstack/react-start/server");
5
- let gt_i18n_internal = require("gt-i18n/internal");
6
- //#region src/functions/parseLocale.ts
7
- const determineLocale = (0, _tanstack_react_start.createIsomorphicFn)().server(determineLocaleServer).client(determineLocaleClient);
8
- /**
9
- * Resolve the user's locale for the current TanStack Start request or browser.
10
- */
11
- function parseLocale() {
12
- const i18nConfig = (0, gt_i18n_internal.getI18nConfig)();
13
- return determineLocale({
14
- defaultLocale: i18nConfig.getDefaultLocale(),
15
- locales: i18nConfig.getLocales(),
16
- customMapping: i18nConfig.getCustomMapping()
17
- });
18
- }
19
- function determineLocaleServer({ defaultLocale, locales, customMapping }) {
20
- const candidates = [];
21
- const cookie = (0, _tanstack_react_start_server.getCookie)(gt_react.defaultLocaleCookieName);
22
- if (cookie) candidates.push(cookie);
23
- const headers = (0, _tanstack_react_start_server.getRequestHeader)("accept-language")?.split(",").map((item) => item.split(";")?.[0].trim()) || [];
24
- candidates.push(...headers);
25
- if (candidates.length === 0) console.warn("gt-tanstack-start(server): no locales could be determined for this request");
26
- const locale = (0, gt_i18n_internal.getI18nConfig)().resolveSupportedLocale(candidates, {
27
- defaultLocale,
28
- locales,
29
- customMapping
30
- });
31
- (0, _tanstack_react_start_server.setCookie)(gt_react.defaultLocaleCookieName, locale, {
32
- path: "/",
33
- sameSite: "lax",
34
- maxAge: 3600 * 24 * 365
35
- });
36
- return locale;
37
- }
38
- function determineLocaleClient({ defaultLocale, locales, customMapping }) {
39
- const candidates = [];
40
- const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${gt_react.defaultLocaleCookieName}=`))?.slice(gt_react.defaultLocaleCookieName.length + 1);
41
- if (cookie) candidates.push(cookie);
42
- if (candidates.length === 0) console.warn("gt-tanstack-start(client): no locales could be determined for this request");
43
- return (0, gt_i18n_internal.getI18nConfig)().resolveSupportedLocale(candidates, {
44
- defaultLocale,
45
- locales,
46
- customMapping
47
- });
48
- }
49
- //#endregion
50
- Object.defineProperty(exports, "Branch", {
51
- enumerable: true,
52
- get: function() {
53
- return gt_react.Branch;
54
- }
55
- });
56
- Object.defineProperty(exports, "Currency", {
57
- enumerable: true,
58
- get: function() {
59
- return gt_react.Currency;
60
- }
61
- });
62
- Object.defineProperty(exports, "DateTime", {
63
- enumerable: true,
64
- get: function() {
65
- return gt_react.DateTime;
66
- }
67
- });
68
- Object.defineProperty(exports, "Derive", {
69
- enumerable: true,
70
- get: function() {
71
- return gt_react.Derive;
72
- }
73
- });
74
- Object.defineProperty(exports, "GTProvider", {
75
- enumerable: true,
76
- get: function() {
77
- return gt_react.GTProvider;
78
- }
79
- });
80
- Object.defineProperty(exports, "LocaleSelector", {
81
- enumerable: true,
82
- get: function() {
83
- return gt_react.LocaleSelector;
84
- }
85
- });
86
- Object.defineProperty(exports, "Num", {
87
- enumerable: true,
88
- get: function() {
89
- return gt_react.Num;
90
- }
91
- });
92
- Object.defineProperty(exports, "Plural", {
93
- enumerable: true,
94
- get: function() {
95
- return gt_react.Plural;
96
- }
97
- });
98
- Object.defineProperty(exports, "RelativeTime", {
99
- enumerable: true,
100
- get: function() {
101
- return gt_react.RelativeTime;
102
- }
103
- });
104
- Object.defineProperty(exports, "T", {
105
- enumerable: true,
106
- get: function() {
107
- return gt_react.T;
108
- }
109
- });
110
- Object.defineProperty(exports, "Var", {
111
- enumerable: true,
112
- get: function() {
113
- return gt_react.Var;
114
- }
115
- });
116
- Object.defineProperty(exports, "declareVar", {
117
- enumerable: true,
118
- get: function() {
119
- return gt_react.declareVar;
120
- }
121
- });
122
- Object.defineProperty(exports, "decodeMsg", {
123
- enumerable: true,
124
- get: function() {
125
- return gt_react.decodeMsg;
126
- }
127
- });
128
- Object.defineProperty(exports, "decodeOptions", {
129
- enumerable: true,
130
- get: function() {
131
- return gt_react.decodeOptions;
132
- }
133
- });
134
- Object.defineProperty(exports, "decodeVars", {
135
- enumerable: true,
136
- get: function() {
137
- return gt_react.decodeVars;
138
- }
139
- });
140
- Object.defineProperty(exports, "derive", {
141
- enumerable: true,
142
- get: function() {
143
- return gt_react.derive;
144
- }
145
- });
146
- Object.defineProperty(exports, "getTranslationsSnapshot", {
147
- enumerable: true,
148
- get: function() {
149
- return gt_react.getTranslationsSnapshot;
150
- }
151
- });
152
- Object.defineProperty(exports, "gtFallback", {
153
- enumerable: true,
154
- get: function() {
155
- return gt_react.gtFallback;
156
- }
157
- });
158
- Object.defineProperty(exports, "initializeGT", {
159
- enumerable: true,
160
- get: function() {
161
- return gt_react.initializeGT;
162
- }
163
- });
164
- Object.defineProperty(exports, "mFallback", {
165
- enumerable: true,
166
- get: function() {
167
- return gt_react.mFallback;
168
- }
169
- });
170
- Object.defineProperty(exports, "msg", {
171
- enumerable: true,
172
- get: function() {
173
- return gt_react.msg;
174
- }
175
- });
176
- exports.parseLocale = parseLocale;
177
- Object.defineProperty(exports, "t", {
178
- enumerable: true,
179
- get: function() {
180
- return gt_react.t;
181
- }
182
- });
183
- Object.defineProperty(exports, "useCustomMapping", {
184
- enumerable: true,
185
- get: function() {
186
- return gt_react.useCustomMapping;
187
- }
188
- });
189
- Object.defineProperty(exports, "useDefaultLocale", {
190
- enumerable: true,
191
- get: function() {
192
- return gt_react.useDefaultLocale;
193
- }
194
- });
195
- Object.defineProperty(exports, "useEnableI18n", {
196
- enumerable: true,
197
- get: function() {
198
- return gt_react.useEnableI18n;
199
- }
200
- });
201
- Object.defineProperty(exports, "useFormatLocales", {
202
- enumerable: true,
203
- get: function() {
204
- return gt_react.useFormatLocales;
205
- }
206
- });
207
- Object.defineProperty(exports, "useGT", {
208
- enumerable: true,
209
- get: function() {
210
- return gt_react.useGT;
211
- }
212
- });
213
- Object.defineProperty(exports, "useLocale", {
214
- enumerable: true,
215
- get: function() {
216
- return gt_react.useLocale;
217
- }
218
- });
219
- Object.defineProperty(exports, "useLocaleSelector", {
220
- enumerable: true,
221
- get: function() {
222
- return gt_react.useLocaleSelector;
223
- }
224
- });
225
- Object.defineProperty(exports, "useLocales", {
226
- enumerable: true,
227
- get: function() {
228
- return gt_react.useLocales;
229
- }
230
- });
231
- Object.defineProperty(exports, "useMessages", {
232
- enumerable: true,
233
- get: function() {
234
- return gt_react.useMessages;
235
- }
236
- });
237
- Object.defineProperty(exports, "useSetEnableI18n", {
238
- enumerable: true,
239
- get: function() {
240
- return gt_react.useSetEnableI18n;
241
- }
242
- });
243
- Object.defineProperty(exports, "useSetLocale", {
244
- enumerable: true,
245
- get: function() {
246
- return gt_react.useSetLocale;
247
- }
248
- });
249
- Object.defineProperty(exports, "useTranslations", {
250
- enumerable: true,
251
- get: function() {
252
- return gt_react.useTranslations;
253
- }
254
- });
255
-
256
- //# sourceMappingURL=index.server.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.server.cjs","names":["defaultLocaleCookieName"],"sources":["../src/functions/parseLocale.ts"],"sourcesContent":["import { defaultLocaleCookieName } from 'gt-react';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport {\n getRequestHeader,\n getCookie,\n setCookie,\n} from '@tanstack/react-start/server';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\nexport const determineLocale = createIsomorphicFn()\n .server(determineLocaleServer)\n .client(determineLocaleClient);\n\n/**\n * Resolve the user's locale for the current TanStack Start request or browser.\n */\nexport function parseLocale(): string {\n const i18nConfig = getI18nConfig();\n return determineLocale({\n defaultLocale: i18nConfig.getDefaultLocale(),\n locales: i18nConfig.getLocales(),\n customMapping: i18nConfig.getCustomMapping(),\n });\n}\n\nfunction determineLocaleServer({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = getCookie(defaultLocaleCookieName);\n if (cookie) candidates.push(cookie);\n\n const headers =\n getRequestHeader('accept-language')\n ?.split(',')\n .map((item) => item.split(';')?.[0].trim()) || [];\n candidates.push(...headers);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(server): no locales could be determined for this request'\n );\n }\n\n const locale = getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n\n setCookie(defaultLocaleCookieName, locale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n\n return locale;\n}\n\nfunction determineLocaleClient({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = document.cookie\n .split('; ')\n .find((row) => row.startsWith(`${defaultLocaleCookieName}=`))\n ?.slice(defaultLocaleCookieName.length + 1);\n if (cookie) candidates.push(cookie);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(client): no locales could be determined for this request'\n );\n }\n\n return getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n}\n"],"mappings":";;;;;;AAUA,MAAa,mBAAA,GAAA,sBAAA,qBAAsC,CAChD,OAAO,sBAAsB,CAC7B,OAAO,sBAAsB;;;;AAKhC,SAAgB,cAAsB;CACpC,MAAM,cAAA,GAAA,iBAAA,gBAA4B;AAClC,QAAO,gBAAgB;EACrB,eAAe,WAAW,kBAAkB;EAC5C,SAAS,WAAW,YAAY;EAChC,eAAe,WAAW,kBAAkB;EAC7C,CAAC;;AAGJ,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,UAAA,GAAA,6BAAA,WAAmBA,SAAAA,wBAAwB;AACjD,KAAI,OAAQ,YAAW,KAAK,OAAO;CAEnC,MAAM,WAAA,GAAA,6BAAA,kBACa,kBAAkB,EAC/B,MAAM,IAAI,CACX,KAAK,SAAS,KAAK,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE;AACrD,YAAW,KAAK,GAAG,QAAQ;AAE3B,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;CAGH,MAAM,UAAA,GAAA,iBAAA,gBAAwB,CAAC,uBAAuB,YAAY;EAChE;EACA;EACA;EACD,CAAC;AAEF,EAAA,GAAA,6BAAA,WAAUA,SAAAA,yBAAyB,QAAQ;EACzC,MAAM;EACN,UAAU;EACV,QAAQ,OAAU,KAAK;EACxB,CAAC;AAEF,QAAO;;AAGT,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,SAAS,OACrB,MAAM,KAAK,CACX,MAAM,QAAQ,IAAI,WAAW,GAAGA,SAAAA,wBAAwB,GAAG,CAAC,EAC3D,MAAMA,SAAAA,wBAAwB,SAAS,EAAE;AAC7C,KAAI,OAAQ,YAAW,KAAK,OAAO;AAEnC,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;AAGH,SAAA,GAAA,iBAAA,gBAAsB,CAAC,uBAAuB,YAAY;EACxD;EACA;EACA;EACD,CAAC"}
@@ -1,10 +0,0 @@
1
- import { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations } from "gt-react";
2
-
3
- //#region src/functions/parseLocale.d.ts
4
- /**
5
- * Resolve the user's locale for the current TanStack Start request or browser.
6
- */
7
- declare function parseLocale(): string;
8
- //#endregion
9
- export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, parseLocale, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations };
10
- //# sourceMappingURL=index.server.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.server.d.cts","names":[],"sources":["../src/functions/parseLocale.ts"],"mappings":";;;;;;iBAiBgB,WAAA,CAAA"}
@@ -1,9 +0,0 @@
1
- import { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations } from "gt-react";
2
- //#region src/functions/parseLocale.d.ts
3
- /**
4
- * Resolve the user's locale for the current TanStack Start request or browser.
5
- */
6
- declare function parseLocale(): string;
7
- //#endregion
8
- export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, parseLocale, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations };
9
- //# sourceMappingURL=index.server.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.server.d.mts","names":[],"sources":["../src/functions/parseLocale.ts"],"mappings":";;;;;iBAiBgB,WAAA,CAAA"}
@@ -1,51 +0,0 @@
1
- import { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, defaultLocaleCookieName, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations } from "gt-react";
2
- import { createIsomorphicFn } from "@tanstack/react-start";
3
- import { getCookie, getRequestHeader, setCookie } from "@tanstack/react-start/server";
4
- import { getI18nConfig } from "gt-i18n/internal";
5
- //#region src/functions/parseLocale.ts
6
- const determineLocale = createIsomorphicFn().server(determineLocaleServer).client(determineLocaleClient);
7
- /**
8
- * Resolve the user's locale for the current TanStack Start request or browser.
9
- */
10
- function parseLocale() {
11
- const i18nConfig = getI18nConfig();
12
- return determineLocale({
13
- defaultLocale: i18nConfig.getDefaultLocale(),
14
- locales: i18nConfig.getLocales(),
15
- customMapping: i18nConfig.getCustomMapping()
16
- });
17
- }
18
- function determineLocaleServer({ defaultLocale, locales, customMapping }) {
19
- const candidates = [];
20
- const cookie = getCookie(defaultLocaleCookieName);
21
- if (cookie) candidates.push(cookie);
22
- const headers = getRequestHeader("accept-language")?.split(",").map((item) => item.split(";")?.[0].trim()) || [];
23
- candidates.push(...headers);
24
- if (candidates.length === 0) console.warn("gt-tanstack-start(server): no locales could be determined for this request");
25
- const locale = getI18nConfig().resolveSupportedLocale(candidates, {
26
- defaultLocale,
27
- locales,
28
- customMapping
29
- });
30
- setCookie(defaultLocaleCookieName, locale, {
31
- path: "/",
32
- sameSite: "lax",
33
- maxAge: 3600 * 24 * 365
34
- });
35
- return locale;
36
- }
37
- function determineLocaleClient({ defaultLocale, locales, customMapping }) {
38
- const candidates = [];
39
- const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${defaultLocaleCookieName}=`))?.slice(defaultLocaleCookieName.length + 1);
40
- if (cookie) candidates.push(cookie);
41
- if (candidates.length === 0) console.warn("gt-tanstack-start(client): no locales could be determined for this request");
42
- return getI18nConfig().resolveSupportedLocale(candidates, {
43
- defaultLocale,
44
- locales,
45
- customMapping
46
- });
47
- }
48
- //#endregion
49
- export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, parseLocale, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations };
50
-
51
- //# sourceMappingURL=index.server.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.server.mjs","names":[],"sources":["../src/functions/parseLocale.ts"],"sourcesContent":["import { defaultLocaleCookieName } from 'gt-react';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport {\n getRequestHeader,\n getCookie,\n setCookie,\n} from '@tanstack/react-start/server';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\nexport const determineLocale = createIsomorphicFn()\n .server(determineLocaleServer)\n .client(determineLocaleClient);\n\n/**\n * Resolve the user's locale for the current TanStack Start request or browser.\n */\nexport function parseLocale(): string {\n const i18nConfig = getI18nConfig();\n return determineLocale({\n defaultLocale: i18nConfig.getDefaultLocale(),\n locales: i18nConfig.getLocales(),\n customMapping: i18nConfig.getCustomMapping(),\n });\n}\n\nfunction determineLocaleServer({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = getCookie(defaultLocaleCookieName);\n if (cookie) candidates.push(cookie);\n\n const headers =\n getRequestHeader('accept-language')\n ?.split(',')\n .map((item) => item.split(';')?.[0].trim()) || [];\n candidates.push(...headers);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(server): no locales could be determined for this request'\n );\n }\n\n const locale = getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n\n setCookie(defaultLocaleCookieName, locale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n\n return locale;\n}\n\nfunction determineLocaleClient({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = document.cookie\n .split('; ')\n .find((row) => row.startsWith(`${defaultLocaleCookieName}=`))\n ?.slice(defaultLocaleCookieName.length + 1);\n if (cookie) candidates.push(cookie);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(client): no locales could be determined for this request'\n );\n }\n\n return getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n}\n"],"mappings":";;;;;AAUA,MAAa,kBAAkB,oBAAoB,CAChD,OAAO,sBAAsB,CAC7B,OAAO,sBAAsB;;;;AAKhC,SAAgB,cAAsB;CACpC,MAAM,aAAa,eAAe;AAClC,QAAO,gBAAgB;EACrB,eAAe,WAAW,kBAAkB;EAC5C,SAAS,WAAW,YAAY;EAChC,eAAe,WAAW,kBAAkB;EAC7C,CAAC;;AAGJ,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,UAAU,wBAAwB;AACjD,KAAI,OAAQ,YAAW,KAAK,OAAO;CAEnC,MAAM,UACJ,iBAAiB,kBAAkB,EAC/B,MAAM,IAAI,CACX,KAAK,SAAS,KAAK,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE;AACrD,YAAW,KAAK,GAAG,QAAQ;AAE3B,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;CAGH,MAAM,SAAS,eAAe,CAAC,uBAAuB,YAAY;EAChE;EACA;EACA;EACD,CAAC;AAEF,WAAU,yBAAyB,QAAQ;EACzC,MAAM;EACN,UAAU;EACV,QAAQ,OAAU,KAAK;EACxB,CAAC;AAEF,QAAO;;AAGT,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,SAAS,OACrB,MAAM,KAAK,CACX,MAAM,QAAQ,IAAI,WAAW,GAAG,wBAAwB,GAAG,CAAC,EAC3D,MAAM,wBAAwB,SAAS,EAAE;AAC7C,KAAI,OAAQ,YAAW,KAAK,OAAO;AAEnC,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;AAGH,QAAO,eAAe,CAAC,uBAAuB,YAAY;EACxD;EACA;EACA;EACD,CAAC"}
@@ -1,256 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- let gt_react = require("gt-react");
3
- let _tanstack_react_start = require("@tanstack/react-start");
4
- let _tanstack_react_start_server = require("@tanstack/react-start/server");
5
- let gt_i18n_internal = require("gt-i18n/internal");
6
- //#region src/functions/parseLocale.ts
7
- const determineLocale = (0, _tanstack_react_start.createIsomorphicFn)().server(determineLocaleServer).client(determineLocaleClient);
8
- /**
9
- * Resolve the user's locale for the current TanStack Start request or browser.
10
- */
11
- function parseLocale() {
12
- const i18nConfig = (0, gt_i18n_internal.getI18nConfig)();
13
- return determineLocale({
14
- defaultLocale: i18nConfig.getDefaultLocale(),
15
- locales: i18nConfig.getLocales(),
16
- customMapping: i18nConfig.getCustomMapping()
17
- });
18
- }
19
- function determineLocaleServer({ defaultLocale, locales, customMapping }) {
20
- const candidates = [];
21
- const cookie = (0, _tanstack_react_start_server.getCookie)(gt_react.defaultLocaleCookieName);
22
- if (cookie) candidates.push(cookie);
23
- const headers = (0, _tanstack_react_start_server.getRequestHeader)("accept-language")?.split(",").map((item) => item.split(";")?.[0].trim()) || [];
24
- candidates.push(...headers);
25
- if (candidates.length === 0) console.warn("gt-tanstack-start(server): no locales could be determined for this request");
26
- const locale = (0, gt_i18n_internal.getI18nConfig)().resolveSupportedLocale(candidates, {
27
- defaultLocale,
28
- locales,
29
- customMapping
30
- });
31
- (0, _tanstack_react_start_server.setCookie)(gt_react.defaultLocaleCookieName, locale, {
32
- path: "/",
33
- sameSite: "lax",
34
- maxAge: 3600 * 24 * 365
35
- });
36
- return locale;
37
- }
38
- function determineLocaleClient({ defaultLocale, locales, customMapping }) {
39
- const candidates = [];
40
- const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${gt_react.defaultLocaleCookieName}=`))?.slice(gt_react.defaultLocaleCookieName.length + 1);
41
- if (cookie) candidates.push(cookie);
42
- if (candidates.length === 0) console.warn("gt-tanstack-start(client): no locales could be determined for this request");
43
- return (0, gt_i18n_internal.getI18nConfig)().resolveSupportedLocale(candidates, {
44
- defaultLocale,
45
- locales,
46
- customMapping
47
- });
48
- }
49
- //#endregion
50
- Object.defineProperty(exports, "Branch", {
51
- enumerable: true,
52
- get: function() {
53
- return gt_react.Branch;
54
- }
55
- });
56
- Object.defineProperty(exports, "Currency", {
57
- enumerable: true,
58
- get: function() {
59
- return gt_react.Currency;
60
- }
61
- });
62
- Object.defineProperty(exports, "DateTime", {
63
- enumerable: true,
64
- get: function() {
65
- return gt_react.DateTime;
66
- }
67
- });
68
- Object.defineProperty(exports, "Derive", {
69
- enumerable: true,
70
- get: function() {
71
- return gt_react.Derive;
72
- }
73
- });
74
- Object.defineProperty(exports, "GTProvider", {
75
- enumerable: true,
76
- get: function() {
77
- return gt_react.GTProvider;
78
- }
79
- });
80
- Object.defineProperty(exports, "LocaleSelector", {
81
- enumerable: true,
82
- get: function() {
83
- return gt_react.LocaleSelector;
84
- }
85
- });
86
- Object.defineProperty(exports, "Num", {
87
- enumerable: true,
88
- get: function() {
89
- return gt_react.Num;
90
- }
91
- });
92
- Object.defineProperty(exports, "Plural", {
93
- enumerable: true,
94
- get: function() {
95
- return gt_react.Plural;
96
- }
97
- });
98
- Object.defineProperty(exports, "RelativeTime", {
99
- enumerable: true,
100
- get: function() {
101
- return gt_react.RelativeTime;
102
- }
103
- });
104
- Object.defineProperty(exports, "T", {
105
- enumerable: true,
106
- get: function() {
107
- return gt_react.T;
108
- }
109
- });
110
- Object.defineProperty(exports, "Var", {
111
- enumerable: true,
112
- get: function() {
113
- return gt_react.Var;
114
- }
115
- });
116
- Object.defineProperty(exports, "declareVar", {
117
- enumerable: true,
118
- get: function() {
119
- return gt_react.declareVar;
120
- }
121
- });
122
- Object.defineProperty(exports, "decodeMsg", {
123
- enumerable: true,
124
- get: function() {
125
- return gt_react.decodeMsg;
126
- }
127
- });
128
- Object.defineProperty(exports, "decodeOptions", {
129
- enumerable: true,
130
- get: function() {
131
- return gt_react.decodeOptions;
132
- }
133
- });
134
- Object.defineProperty(exports, "decodeVars", {
135
- enumerable: true,
136
- get: function() {
137
- return gt_react.decodeVars;
138
- }
139
- });
140
- Object.defineProperty(exports, "derive", {
141
- enumerable: true,
142
- get: function() {
143
- return gt_react.derive;
144
- }
145
- });
146
- Object.defineProperty(exports, "getTranslationsSnapshot", {
147
- enumerable: true,
148
- get: function() {
149
- return gt_react.getTranslationsSnapshot;
150
- }
151
- });
152
- Object.defineProperty(exports, "gtFallback", {
153
- enumerable: true,
154
- get: function() {
155
- return gt_react.gtFallback;
156
- }
157
- });
158
- Object.defineProperty(exports, "initializeGT", {
159
- enumerable: true,
160
- get: function() {
161
- return gt_react.initializeGT;
162
- }
163
- });
164
- Object.defineProperty(exports, "mFallback", {
165
- enumerable: true,
166
- get: function() {
167
- return gt_react.mFallback;
168
- }
169
- });
170
- Object.defineProperty(exports, "msg", {
171
- enumerable: true,
172
- get: function() {
173
- return gt_react.msg;
174
- }
175
- });
176
- exports.parseLocale = parseLocale;
177
- Object.defineProperty(exports, "t", {
178
- enumerable: true,
179
- get: function() {
180
- return gt_react.t;
181
- }
182
- });
183
- Object.defineProperty(exports, "useCustomMapping", {
184
- enumerable: true,
185
- get: function() {
186
- return gt_react.useCustomMapping;
187
- }
188
- });
189
- Object.defineProperty(exports, "useDefaultLocale", {
190
- enumerable: true,
191
- get: function() {
192
- return gt_react.useDefaultLocale;
193
- }
194
- });
195
- Object.defineProperty(exports, "useEnableI18n", {
196
- enumerable: true,
197
- get: function() {
198
- return gt_react.useEnableI18n;
199
- }
200
- });
201
- Object.defineProperty(exports, "useFormatLocales", {
202
- enumerable: true,
203
- get: function() {
204
- return gt_react.useFormatLocales;
205
- }
206
- });
207
- Object.defineProperty(exports, "useGT", {
208
- enumerable: true,
209
- get: function() {
210
- return gt_react.useGT;
211
- }
212
- });
213
- Object.defineProperty(exports, "useLocale", {
214
- enumerable: true,
215
- get: function() {
216
- return gt_react.useLocale;
217
- }
218
- });
219
- Object.defineProperty(exports, "useLocaleSelector", {
220
- enumerable: true,
221
- get: function() {
222
- return gt_react.useLocaleSelector;
223
- }
224
- });
225
- Object.defineProperty(exports, "useLocales", {
226
- enumerable: true,
227
- get: function() {
228
- return gt_react.useLocales;
229
- }
230
- });
231
- Object.defineProperty(exports, "useMessages", {
232
- enumerable: true,
233
- get: function() {
234
- return gt_react.useMessages;
235
- }
236
- });
237
- Object.defineProperty(exports, "useSetEnableI18n", {
238
- enumerable: true,
239
- get: function() {
240
- return gt_react.useSetEnableI18n;
241
- }
242
- });
243
- Object.defineProperty(exports, "useSetLocale", {
244
- enumerable: true,
245
- get: function() {
246
- return gt_react.useSetLocale;
247
- }
248
- });
249
- Object.defineProperty(exports, "useTranslations", {
250
- enumerable: true,
251
- get: function() {
252
- return gt_react.useTranslations;
253
- }
254
- });
255
-
256
- //# sourceMappingURL=index.types.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.types.cjs","names":["defaultLocaleCookieName"],"sources":["../src/functions/parseLocale.ts"],"sourcesContent":["import { defaultLocaleCookieName } from 'gt-react';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport {\n getRequestHeader,\n getCookie,\n setCookie,\n} from '@tanstack/react-start/server';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\nexport const determineLocale = createIsomorphicFn()\n .server(determineLocaleServer)\n .client(determineLocaleClient);\n\n/**\n * Resolve the user's locale for the current TanStack Start request or browser.\n */\nexport function parseLocale(): string {\n const i18nConfig = getI18nConfig();\n return determineLocale({\n defaultLocale: i18nConfig.getDefaultLocale(),\n locales: i18nConfig.getLocales(),\n customMapping: i18nConfig.getCustomMapping(),\n });\n}\n\nfunction determineLocaleServer({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = getCookie(defaultLocaleCookieName);\n if (cookie) candidates.push(cookie);\n\n const headers =\n getRequestHeader('accept-language')\n ?.split(',')\n .map((item) => item.split(';')?.[0].trim()) || [];\n candidates.push(...headers);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(server): no locales could be determined for this request'\n );\n }\n\n const locale = getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n\n setCookie(defaultLocaleCookieName, locale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n\n return locale;\n}\n\nfunction determineLocaleClient({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = document.cookie\n .split('; ')\n .find((row) => row.startsWith(`${defaultLocaleCookieName}=`))\n ?.slice(defaultLocaleCookieName.length + 1);\n if (cookie) candidates.push(cookie);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(client): no locales could be determined for this request'\n );\n }\n\n return getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n}\n"],"mappings":";;;;;;AAUA,MAAa,mBAAA,GAAA,sBAAA,qBAAsC,CAChD,OAAO,sBAAsB,CAC7B,OAAO,sBAAsB;;;;AAKhC,SAAgB,cAAsB;CACpC,MAAM,cAAA,GAAA,iBAAA,gBAA4B;AAClC,QAAO,gBAAgB;EACrB,eAAe,WAAW,kBAAkB;EAC5C,SAAS,WAAW,YAAY;EAChC,eAAe,WAAW,kBAAkB;EAC7C,CAAC;;AAGJ,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,UAAA,GAAA,6BAAA,WAAmBA,SAAAA,wBAAwB;AACjD,KAAI,OAAQ,YAAW,KAAK,OAAO;CAEnC,MAAM,WAAA,GAAA,6BAAA,kBACa,kBAAkB,EAC/B,MAAM,IAAI,CACX,KAAK,SAAS,KAAK,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE;AACrD,YAAW,KAAK,GAAG,QAAQ;AAE3B,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;CAGH,MAAM,UAAA,GAAA,iBAAA,gBAAwB,CAAC,uBAAuB,YAAY;EAChE;EACA;EACA;EACD,CAAC;AAEF,EAAA,GAAA,6BAAA,WAAUA,SAAAA,yBAAyB,QAAQ;EACzC,MAAM;EACN,UAAU;EACV,QAAQ,OAAU,KAAK;EACxB,CAAC;AAEF,QAAO;;AAGT,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,SAAS,OACrB,MAAM,KAAK,CACX,MAAM,QAAQ,IAAI,WAAW,GAAGA,SAAAA,wBAAwB,GAAG,CAAC,EAC3D,MAAMA,SAAAA,wBAAwB,SAAS,EAAE;AAC7C,KAAI,OAAQ,YAAW,KAAK,OAAO;AAEnC,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;AAGH,SAAA,GAAA,iBAAA,gBAAsB,CAAC,uBAAuB,YAAY;EACxD;EACA;EACA;EACD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.types.d.cts","names":[],"sources":["../src/functions/parseLocale.ts"],"mappings":";;;;;;iBAiBgB,WAAA,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.types.d.mts","names":[],"sources":["../src/functions/parseLocale.ts"],"mappings":";;;;;iBAiBgB,WAAA,CAAA"}
@@ -1,51 +0,0 @@
1
- import { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, defaultLocaleCookieName, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations } from "gt-react";
2
- import { createIsomorphicFn } from "@tanstack/react-start";
3
- import { getCookie, getRequestHeader, setCookie } from "@tanstack/react-start/server";
4
- import { getI18nConfig } from "gt-i18n/internal";
5
- //#region src/functions/parseLocale.ts
6
- const determineLocale = createIsomorphicFn().server(determineLocaleServer).client(determineLocaleClient);
7
- /**
8
- * Resolve the user's locale for the current TanStack Start request or browser.
9
- */
10
- function parseLocale() {
11
- const i18nConfig = getI18nConfig();
12
- return determineLocale({
13
- defaultLocale: i18nConfig.getDefaultLocale(),
14
- locales: i18nConfig.getLocales(),
15
- customMapping: i18nConfig.getCustomMapping()
16
- });
17
- }
18
- function determineLocaleServer({ defaultLocale, locales, customMapping }) {
19
- const candidates = [];
20
- const cookie = getCookie(defaultLocaleCookieName);
21
- if (cookie) candidates.push(cookie);
22
- const headers = getRequestHeader("accept-language")?.split(",").map((item) => item.split(";")?.[0].trim()) || [];
23
- candidates.push(...headers);
24
- if (candidates.length === 0) console.warn("gt-tanstack-start(server): no locales could be determined for this request");
25
- const locale = getI18nConfig().resolveSupportedLocale(candidates, {
26
- defaultLocale,
27
- locales,
28
- customMapping
29
- });
30
- setCookie(defaultLocaleCookieName, locale, {
31
- path: "/",
32
- sameSite: "lax",
33
- maxAge: 3600 * 24 * 365
34
- });
35
- return locale;
36
- }
37
- function determineLocaleClient({ defaultLocale, locales, customMapping }) {
38
- const candidates = [];
39
- const cookie = document.cookie.split("; ").find((row) => row.startsWith(`${defaultLocaleCookieName}=`))?.slice(defaultLocaleCookieName.length + 1);
40
- if (cookie) candidates.push(cookie);
41
- if (candidates.length === 0) console.warn("gt-tanstack-start(client): no locales could be determined for this request");
42
- return getI18nConfig().resolveSupportedLocale(candidates, {
43
- defaultLocale,
44
- locales,
45
- customMapping
46
- });
47
- }
48
- //#endregion
49
- export { Branch, Currency, DateTime, Derive, GTProvider, LocaleSelector, Num, Plural, RelativeTime, T, Var, declareVar, decodeMsg, decodeOptions, decodeVars, derive, getTranslationsSnapshot, gtFallback, initializeGT, mFallback, msg, parseLocale, t, useCustomMapping, useDefaultLocale, useEnableI18n, useFormatLocales, useGT, useLocale, useLocaleSelector, useLocales, useMessages, useSetEnableI18n, useSetLocale, useTranslations };
50
-
51
- //# sourceMappingURL=index.types.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.types.mjs","names":[],"sources":["../src/functions/parseLocale.ts"],"sourcesContent":["import { defaultLocaleCookieName } from 'gt-react';\nimport { createIsomorphicFn } from '@tanstack/react-start';\nimport {\n getRequestHeader,\n getCookie,\n setCookie,\n} from '@tanstack/react-start/server';\nimport { getI18nConfig } from 'gt-i18n/internal';\nimport type { I18nConfigParams } from 'gt-i18n/internal/types';\n\nexport const determineLocale = createIsomorphicFn()\n .server(determineLocaleServer)\n .client(determineLocaleClient);\n\n/**\n * Resolve the user's locale for the current TanStack Start request or browser.\n */\nexport function parseLocale(): string {\n const i18nConfig = getI18nConfig();\n return determineLocale({\n defaultLocale: i18nConfig.getDefaultLocale(),\n locales: i18nConfig.getLocales(),\n customMapping: i18nConfig.getCustomMapping(),\n });\n}\n\nfunction determineLocaleServer({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = getCookie(defaultLocaleCookieName);\n if (cookie) candidates.push(cookie);\n\n const headers =\n getRequestHeader('accept-language')\n ?.split(',')\n .map((item) => item.split(';')?.[0].trim()) || [];\n candidates.push(...headers);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(server): no locales could be determined for this request'\n );\n }\n\n const locale = getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n\n setCookie(defaultLocaleCookieName, locale, {\n path: '/',\n sameSite: 'lax',\n maxAge: 60 * 60 * 24 * 365,\n });\n\n return locale;\n}\n\nfunction determineLocaleClient({\n defaultLocale,\n locales,\n customMapping,\n}: I18nConfigParams) {\n const candidates: string[] = [];\n\n const cookie = document.cookie\n .split('; ')\n .find((row) => row.startsWith(`${defaultLocaleCookieName}=`))\n ?.slice(defaultLocaleCookieName.length + 1);\n if (cookie) candidates.push(cookie);\n\n if (candidates.length === 0) {\n console.warn(\n 'gt-tanstack-start(client): no locales could be determined for this request'\n );\n }\n\n return getI18nConfig().resolveSupportedLocale(candidates, {\n defaultLocale,\n locales,\n customMapping,\n });\n}\n"],"mappings":";;;;;AAUA,MAAa,kBAAkB,oBAAoB,CAChD,OAAO,sBAAsB,CAC7B,OAAO,sBAAsB;;;;AAKhC,SAAgB,cAAsB;CACpC,MAAM,aAAa,eAAe;AAClC,QAAO,gBAAgB;EACrB,eAAe,WAAW,kBAAkB;EAC5C,SAAS,WAAW,YAAY;EAChC,eAAe,WAAW,kBAAkB;EAC7C,CAAC;;AAGJ,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,UAAU,wBAAwB;AACjD,KAAI,OAAQ,YAAW,KAAK,OAAO;CAEnC,MAAM,UACJ,iBAAiB,kBAAkB,EAC/B,MAAM,IAAI,CACX,KAAK,SAAS,KAAK,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,EAAE;AACrD,YAAW,KAAK,GAAG,QAAQ;AAE3B,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;CAGH,MAAM,SAAS,eAAe,CAAC,uBAAuB,YAAY;EAChE;EACA;EACA;EACD,CAAC;AAEF,WAAU,yBAAyB,QAAQ;EACzC,MAAM;EACN,UAAU;EACV,QAAQ,OAAU,KAAK;EACxB,CAAC;AAEF,QAAO;;AAGT,SAAS,sBAAsB,EAC7B,eACA,SACA,iBACmB;CACnB,MAAM,aAAuB,EAAE;CAE/B,MAAM,SAAS,SAAS,OACrB,MAAM,KAAK,CACX,MAAM,QAAQ,IAAI,WAAW,GAAG,wBAAwB,GAAG,CAAC,EAC3D,MAAM,wBAAwB,SAAS,EAAE;AAC7C,KAAI,OAAQ,YAAW,KAAK,OAAO;AAEnC,KAAI,WAAW,WAAW,EACxB,SAAQ,KACN,6EACD;AAGH,QAAO,eAAe,CAAC,uBAAuB,YAAY;EACxD;EACA;EACA;EACD,CAAC"}
package/dist/types.cjs DELETED
File without changes
package/dist/types.d.cts DELETED
@@ -1 +0,0 @@
1
- export { };
package/dist/types.d.mts DELETED
@@ -1 +0,0 @@
1
- export { };
package/dist/types.mjs DELETED
@@ -1 +0,0 @@
1
- export {};