gt-react 11.0.7 → 11.0.9
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 +20 -0
- package/dist/index.client.cjs +22 -36
- package/dist/index.client.cjs.map +1 -1
- package/dist/index.client.d.cts +1 -15
- package/dist/index.client.d.cts.map +1 -1
- package/dist/index.client.d.mts +2 -16
- package/dist/index.client.d.mts.map +1 -1
- package/dist/index.client.mjs +5 -34
- package/dist/index.client.mjs.map +1 -1
- package/dist/index.server.cjs +22 -36
- package/dist/index.server.cjs.map +1 -1
- package/dist/index.server.d.cts +1 -15
- package/dist/index.server.d.cts.map +1 -1
- package/dist/index.server.d.mts +2 -16
- package/dist/index.server.d.mts.map +1 -1
- package/dist/index.server.mjs +5 -34
- package/dist/index.server.mjs.map +1 -1
- package/dist/index.types.d.cts +1 -15
- package/dist/index.types.d.cts.map +1 -1
- package/dist/index.types.d.mts +2 -16
- package/dist/index.types.d.mts.map +1 -1
- package/package.json +4 -4
- package/dist/index.types.cjs +0 -1059
- package/dist/index.types.cjs.map +0 -1
- package/dist/index.types.mjs +0 -777
- package/dist/index.types.mjs.map +0 -1
package/dist/index.types.cjs
DELETED
|
@@ -1,1059 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
let _generaltranslation_react_core_pure = require("@generaltranslation/react-core/pure");
|
|
4
|
-
let gt_i18n_internal = require("gt-i18n/internal");
|
|
5
|
-
let react = require("react");
|
|
6
|
-
let _generaltranslation_react_core_hooks = require("@generaltranslation/react-core/hooks");
|
|
7
|
-
let _generaltranslation_react_core_components = require("@generaltranslation/react-core/components");
|
|
8
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
|
-
//#region src/i18n-cache/constants.ts
|
|
10
|
-
const DEFAULT_HTML_TAG_OPTIONS = {
|
|
11
|
-
updateHtmlLangTag: true,
|
|
12
|
-
updateHtmlDirTag: true
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/i18n-cache/LocalStorageTranslationCache.ts
|
|
16
|
-
const STORAGE_KEY_PREFIX = "gt:tx:";
|
|
17
|
-
const PURGE_TIMESTAMP_PREFIX = "gt:tx:purge:";
|
|
18
|
-
const FLUSH_INTERVAL = 500;
|
|
19
|
-
const DEFAULT_MAX_SIZE = 1e6;
|
|
20
|
-
const DEFAULT_TTL_MS = 864e5;
|
|
21
|
-
const DEFAULT_PURGE_INTERVAL_MS = 3e5;
|
|
22
|
-
const PURGE_TARGET_RATIO = .8;
|
|
23
|
-
const activeIntervals = /* @__PURE__ */ new Map();
|
|
24
|
-
/**
|
|
25
|
-
* A localStorage-backed translation cache for a single locale.
|
|
26
|
-
* Used in development mode only to persist runtime translations across page refreshes.
|
|
27
|
-
*
|
|
28
|
-
* Entries are stored with per-entry expiry timestamps and the cache is purged
|
|
29
|
-
* when estimated size exceeds the configured maximum.
|
|
30
|
-
*/
|
|
31
|
-
var LocalStorageTranslationCache = class {
|
|
32
|
-
/**
|
|
33
|
-
* @param locale - The locale this cache is for
|
|
34
|
-
* @param projectId - The project id (namespaces localStorage keys)
|
|
35
|
-
* @param init - Optional initial translations to merge on top of localStorage data.
|
|
36
|
-
* init values take priority over stale localStorage entries.
|
|
37
|
-
* @param maxSize - Maximum cache size in characters (default: ~1M)
|
|
38
|
-
* @param ttl - TTL in milliseconds for each entry (default: 24 hours)
|
|
39
|
-
* @param purgeInterval - Background purge check interval in ms (default: 5 min)
|
|
40
|
-
*/
|
|
41
|
-
constructor({ locale, projectId, init, maxSize, ttl, purgeInterval }) {
|
|
42
|
-
this._writeBuffer = {};
|
|
43
|
-
this._flushTimer = null;
|
|
44
|
-
this._estimatedSize = 0;
|
|
45
|
-
this._storageKey = `${STORAGE_KEY_PREFIX}${projectId}:${locale}`;
|
|
46
|
-
this._purgeTimestampKey = `${PURGE_TIMESTAMP_PREFIX}${projectId}:${locale}`;
|
|
47
|
-
this._maxSize = maxSize ?? DEFAULT_MAX_SIZE;
|
|
48
|
-
this._ttl = ttl ?? DEFAULT_TTL_MS;
|
|
49
|
-
this._purgeInterval = purgeInterval ?? DEFAULT_PURGE_INTERVAL_MS;
|
|
50
|
-
if (init) this.initStorage(init);
|
|
51
|
-
if (activeIntervals.has(this._storageKey)) clearInterval(activeIntervals.get(this._storageKey));
|
|
52
|
-
const intervalId = setInterval(() => this._backgroundPurge(), this._purgeInterval);
|
|
53
|
-
activeIntervals.set(this._storageKey, intervalId);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Returns the full translation map (cache + pending buffer writes).
|
|
57
|
-
* Filters out expired entries. Buffer entries take priority.
|
|
58
|
-
*/
|
|
59
|
-
getInternalCache() {
|
|
60
|
-
const now = Date.now();
|
|
61
|
-
const cache = this._readFromStorage();
|
|
62
|
-
const result = {};
|
|
63
|
-
for (const [key, entry] of Object.entries(cache)) if (entry.exp > now) result[key] = entry.t;
|
|
64
|
-
Object.assign(result, this._writeBuffer);
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Queue a translation for writing to localStorage.
|
|
69
|
-
* Writes are batched via a debounced flush.
|
|
70
|
-
*/
|
|
71
|
-
write(hash, translation) {
|
|
72
|
-
this._writeBuffer[hash] = translation;
|
|
73
|
-
this._scheduleFlush();
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Remove specific entries from the cache by hash.
|
|
77
|
-
*/
|
|
78
|
-
purge(hashes) {
|
|
79
|
-
const cache = this._readFromStorage();
|
|
80
|
-
for (const hash of hashes) delete cache[hash];
|
|
81
|
-
this._writeRaw(JSON.stringify(cache));
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Schedule a flush of the write buffer.
|
|
85
|
-
* Uses a leading throttle — the first write in a burst schedules a flush
|
|
86
|
-
* after FLUSH_INTERVAL ms; subsequent writes before the timer fires are
|
|
87
|
-
* batched into the same flush.
|
|
88
|
-
*/
|
|
89
|
-
_scheduleFlush() {
|
|
90
|
-
if (this._flushTimer) return;
|
|
91
|
-
this._flushTimer = setTimeout(() => {
|
|
92
|
-
this._flushTimer = null;
|
|
93
|
-
this._flush();
|
|
94
|
-
}, FLUSH_INTERVAL);
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Merge the write buffer into the cache and persist to localStorage.
|
|
98
|
-
* Purges before writing if estimated size exceeds max.
|
|
99
|
-
*/
|
|
100
|
-
_flush() {
|
|
101
|
-
if (Object.keys(this._writeBuffer).length === 0) return;
|
|
102
|
-
try {
|
|
103
|
-
const cache = this._readFromStorage();
|
|
104
|
-
const now = Date.now();
|
|
105
|
-
if (this._estimatedSize > this._maxSize) this._purgeCache(cache, now);
|
|
106
|
-
const exp = now + this._ttl;
|
|
107
|
-
for (const [key, value] of Object.entries(this._writeBuffer)) cache[key] = {
|
|
108
|
-
t: value,
|
|
109
|
-
exp
|
|
110
|
-
};
|
|
111
|
-
this._writeRaw(JSON.stringify(cache));
|
|
112
|
-
} catch {}
|
|
113
|
-
this._writeBuffer = {};
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Purge entries from the cache in place.
|
|
117
|
-
* Phase 1: Remove expired entries.
|
|
118
|
-
* Phase 2: If still over target, drop oldest entries by expiry time.
|
|
119
|
-
*/
|
|
120
|
-
_purgeCache(cache, now) {
|
|
121
|
-
const keysBeforePurge = Object.keys(cache);
|
|
122
|
-
if (keysBeforePurge.length === 0) return;
|
|
123
|
-
const avgEntrySize = this._estimatedSize / keysBeforePurge.length;
|
|
124
|
-
deleteExpiredEntries(cache, now);
|
|
125
|
-
const targetSize = this._maxSize * PURGE_TARGET_RATIO;
|
|
126
|
-
const maxEntries = Math.floor(targetSize / avgEntrySize);
|
|
127
|
-
const remaining = Object.entries(cache);
|
|
128
|
-
if (remaining.length > maxEntries) {
|
|
129
|
-
remaining.sort((a, b) => a[1].exp - b[1].exp);
|
|
130
|
-
const toDrop = remaining.length - maxEntries;
|
|
131
|
-
for (let i = 0; i < toDrop; i++) delete cache[remaining[i][0]];
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Background purge triggered by setInterval.
|
|
136
|
-
* Checks the last purge timestamp to avoid redundant work across tabs,
|
|
137
|
-
* then removes expired entries. Only writes back if something changed.
|
|
138
|
-
* Timestamp is updated after the purge completes.
|
|
139
|
-
*/
|
|
140
|
-
_backgroundPurge() {
|
|
141
|
-
try {
|
|
142
|
-
const raw = localStorage.getItem(this._purgeTimestampKey);
|
|
143
|
-
const lastPurge = raw ? parseInt(raw, 10) : 0;
|
|
144
|
-
const now = Date.now();
|
|
145
|
-
if (now - lastPurge < this._purgeInterval) return;
|
|
146
|
-
const cache = this._readFromStorage();
|
|
147
|
-
const keysBefore = Object.keys(cache).length;
|
|
148
|
-
deleteExpiredEntries(cache, now);
|
|
149
|
-
if (Object.keys(cache).length < keysBefore) this._writeRaw(JSON.stringify(cache));
|
|
150
|
-
localStorage.setItem(this._purgeTimestampKey, String(now));
|
|
151
|
-
} catch {}
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Read and parse translations from localStorage.
|
|
155
|
-
* Recalibrates estimated size as a side effect.
|
|
156
|
-
* Returns empty object on any error (unavailable, corrupt data, etc.)
|
|
157
|
-
*/
|
|
158
|
-
_readFromStorage() {
|
|
159
|
-
try {
|
|
160
|
-
const raw = localStorage.getItem(this._storageKey);
|
|
161
|
-
if (!raw) {
|
|
162
|
-
this._estimatedSize = 0;
|
|
163
|
-
return {};
|
|
164
|
-
}
|
|
165
|
-
this._estimatedSize = raw.length;
|
|
166
|
-
return JSON.parse(raw);
|
|
167
|
-
} catch {
|
|
168
|
-
this._estimatedSize = 0;
|
|
169
|
-
return {};
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Persist new entries to localStorage with expiry timestamps.
|
|
174
|
-
* Reads current cache, merges buffer on top, writes back.
|
|
175
|
-
*/
|
|
176
|
-
initStorage(buffer) {
|
|
177
|
-
try {
|
|
178
|
-
const cache = this._readFromStorage();
|
|
179
|
-
const exp = Date.now() + this._ttl;
|
|
180
|
-
for (const [key, value] of Object.entries(buffer)) cache[key] = {
|
|
181
|
-
t: value,
|
|
182
|
-
exp
|
|
183
|
-
};
|
|
184
|
-
this._writeRaw(JSON.stringify(cache));
|
|
185
|
-
} catch {}
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Write a pre-serialized string to localStorage and recalibrate estimate.
|
|
189
|
-
*/
|
|
190
|
-
_writeRaw(serialized) {
|
|
191
|
-
try {
|
|
192
|
-
localStorage.setItem(this._storageKey, serialized);
|
|
193
|
-
this._estimatedSize = serialized.length;
|
|
194
|
-
} catch {}
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
/**
|
|
198
|
-
* Helper function deletes expired entries from a cache in place.
|
|
199
|
-
*/
|
|
200
|
-
function deleteExpiredEntries(cache, now = Date.now()) {
|
|
201
|
-
for (const key of Object.keys(cache)) if (cache[key].exp <= now) delete cache[key];
|
|
202
|
-
}
|
|
203
|
-
//#endregion
|
|
204
|
-
//#region ../core/dist/api-BOEGbEF6.mjs
|
|
205
|
-
function ensureSentence(text) {
|
|
206
|
-
const trimmed = text.trim();
|
|
207
|
-
if (!trimmed) return "";
|
|
208
|
-
return /[.!?)]$/.test(trimmed) ? trimmed : `${trimmed}.`;
|
|
209
|
-
}
|
|
210
|
-
function stripSentence(text) {
|
|
211
|
-
const trimmed = text.trim();
|
|
212
|
-
let end = trimmed.length;
|
|
213
|
-
while (end > 0) {
|
|
214
|
-
const char = trimmed[end - 1];
|
|
215
|
-
if (char !== "." && char !== "!" && char !== "?") break;
|
|
216
|
-
end -= 1;
|
|
217
|
-
}
|
|
218
|
-
return trimmed.slice(0, end);
|
|
219
|
-
}
|
|
220
|
-
function lowercaseFirstWord(text) {
|
|
221
|
-
return text.replace(/^[A-Z][a-z]/, (match) => match.toLowerCase());
|
|
222
|
-
}
|
|
223
|
-
function formatDetails(details) {
|
|
224
|
-
if (!details) return "";
|
|
225
|
-
const detailText = Array.isArray(details) ? details.join(", ") : details;
|
|
226
|
-
if (!detailText.trim()) return "";
|
|
227
|
-
return ensureSentence(`Details: ${detailText}`);
|
|
228
|
-
}
|
|
229
|
-
function createDiagnosticMessage({ source, severity, whatHappened, reassurance, why, fix, wayOut, details, docsUrl }) {
|
|
230
|
-
const prefix = source ? severity ? `${source} ${severity}:` : `${source}:` : severity ? `${severity}:` : "";
|
|
231
|
-
const whatAndWhy = why ? `${stripSentence(whatHappened)} because ${lowercaseFirstWord(stripSentence(why))}` : whatHappened;
|
|
232
|
-
const shouldCombineWayOut = !!fix && !!wayOut && /^[a-z]/.test(stripSentence(wayOut));
|
|
233
|
-
const messageParts = [
|
|
234
|
-
whatAndWhy,
|
|
235
|
-
reassurance,
|
|
236
|
-
shouldCombineWayOut ? `${stripSentence(fix)}, or ${lowercaseFirstWord(stripSentence(wayOut))}` : fix,
|
|
237
|
-
shouldCombineWayOut ? void 0 : wayOut,
|
|
238
|
-
formatDetails(details)
|
|
239
|
-
].filter((part) => !!part).map(ensureSentence);
|
|
240
|
-
if (docsUrl) messageParts.push(`Learn more: ${docsUrl}`);
|
|
241
|
-
const message = messageParts.join(" ");
|
|
242
|
-
return prefix ? `${prefix} ${message}` : message;
|
|
243
|
-
}
|
|
244
|
-
//#endregion
|
|
245
|
-
//#region src/i18n-cache/BrowserI18nCache.ts
|
|
246
|
-
/**
|
|
247
|
-
* I18nCache implementation for Browser.
|
|
248
|
-
*/
|
|
249
|
-
var BrowserI18nCache = class extends gt_i18n_internal.I18nCache {
|
|
250
|
-
constructor(config) {
|
|
251
|
-
const { htmlTagOptions, ...managerConfig } = config;
|
|
252
|
-
const localStorageCaches = {};
|
|
253
|
-
const i18nConfig = (0, gt_i18n_internal.getI18nConfig)();
|
|
254
|
-
const devHotReloadEnabled = !!config.loadTranslations && i18nConfig.isDevHotReloadEnabled();
|
|
255
|
-
const projectId = i18nConfig.getProjectId();
|
|
256
|
-
const loadTranslations = devHotReloadEnabled ? wrapLoaderWithLocalStorage(config.loadTranslations, projectId, localStorageCaches) : config.loadTranslations;
|
|
257
|
-
super({
|
|
258
|
-
...managerConfig,
|
|
259
|
-
loadTranslations
|
|
260
|
-
});
|
|
261
|
-
this._devHotReloadJsx = false;
|
|
262
|
-
this._localStorageCaches = localStorageCaches;
|
|
263
|
-
this._devHotReloadJsx = devHotReloadEnabled;
|
|
264
|
-
this.htmlTagOptions = {
|
|
265
|
-
...DEFAULT_HTML_TAG_OPTIONS,
|
|
266
|
-
...htmlTagOptions
|
|
267
|
-
};
|
|
268
|
-
if (devHotReloadEnabled) this.onTranslationsCacheMiss = ({ locale, hash, translation }) => {
|
|
269
|
-
const cache = localStorageCaches[locale];
|
|
270
|
-
if (cache) cache.write(hash, translation);
|
|
271
|
-
else localStorageCaches[locale] = new LocalStorageTranslationCache({
|
|
272
|
-
locale,
|
|
273
|
-
projectId,
|
|
274
|
-
init: { [hash]: translation }
|
|
275
|
-
});
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
/**
|
|
279
|
-
* Whether dev hot reload JSX (Suspense-based <T>) is active
|
|
280
|
-
*/
|
|
281
|
-
isDevHotReloadJsx() {
|
|
282
|
-
return this._devHotReloadJsx;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Get or create a LocalStorageTranslationCache for the given locale.
|
|
286
|
-
* Instances are lazily created and cached per locale.
|
|
287
|
-
* Returns undefined if not in development mode.
|
|
288
|
-
*/
|
|
289
|
-
getLocalStorageTranslationCache(locale, init) {
|
|
290
|
-
if ((0, gt_i18n_internal.getRuntimeEnvironment)() !== "development") return void 0;
|
|
291
|
-
if (!this._localStorageCaches[locale]) this._localStorageCaches[locale] = new LocalStorageTranslationCache({
|
|
292
|
-
locale,
|
|
293
|
-
projectId: this.config.projectId,
|
|
294
|
-
init
|
|
295
|
-
});
|
|
296
|
-
return this._localStorageCaches[locale];
|
|
297
|
-
}
|
|
298
|
-
/**
|
|
299
|
-
* Update the html tag (lang, dir)
|
|
300
|
-
*
|
|
301
|
-
* @deprecated, TODO: we should use a different system for managing this html tag
|
|
302
|
-
* this should just be for managing translations
|
|
303
|
-
*/
|
|
304
|
-
updateHtmlTag(locale, htmlTagOptions) {
|
|
305
|
-
const htmlLocale = htmlTagOptions?.lang || locale;
|
|
306
|
-
const i18nConfig = (0, gt_i18n_internal.getI18nConfig)();
|
|
307
|
-
const canonicalLocale = i18nConfig.resolveCanonicalLocale(htmlLocale);
|
|
308
|
-
if (!i18nConfig.isValidLocale(canonicalLocale)) {
|
|
309
|
-
console.warn(createInvalidLocaleWarning(htmlLocale));
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
const localeDirection = htmlTagOptions?.dir || i18nConfig.getLocaleDirection(canonicalLocale);
|
|
313
|
-
const mergedHtmlTagOptions = {
|
|
314
|
-
...this.htmlTagOptions,
|
|
315
|
-
...htmlTagOptions
|
|
316
|
-
};
|
|
317
|
-
if (mergedHtmlTagOptions.updateHtmlLangTag) document.documentElement.lang = canonicalLocale;
|
|
318
|
-
if (mergedHtmlTagOptions.updateHtmlDirTag) document.documentElement.dir = localeDirection;
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
|
-
/**
|
|
322
|
-
* Wraps a translation loader to merge localStorage translations in dev mode.
|
|
323
|
-
* On each call: runs the original loader, seeds a LocalStorageTranslationCache
|
|
324
|
-
* with the result (loader wins over stale localStorage), and returns the merged
|
|
325
|
-
* translations — preserving runtime tx() translations from previous sessions.
|
|
326
|
-
*
|
|
327
|
-
* TODO: this should be moved to wrapping in I18nStore
|
|
328
|
-
*/
|
|
329
|
-
function wrapLoaderWithLocalStorage(originalLoader, projectId, localStorageCaches) {
|
|
330
|
-
return async (locale) => {
|
|
331
|
-
const loaderTranslations = await originalLoader(locale);
|
|
332
|
-
localStorageCaches[locale] ||= new LocalStorageTranslationCache({
|
|
333
|
-
locale,
|
|
334
|
-
projectId,
|
|
335
|
-
init: loaderTranslations
|
|
336
|
-
});
|
|
337
|
-
return localStorageCaches[locale].getInternalCache();
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
const createInvalidLocaleWarning = (locale) => createDiagnosticMessage({
|
|
341
|
-
source: "gt-react",
|
|
342
|
-
severity: "Warning",
|
|
343
|
-
whatHappened: `Locale "${locale}" is not valid`,
|
|
344
|
-
fix: "Use a valid BCP 47 locale code or add a custom mapping"
|
|
345
|
-
});
|
|
346
|
-
//#endregion
|
|
347
|
-
//#region src/condition-store/cookies.ts
|
|
348
|
-
/**
|
|
349
|
-
* Minimally parses a cookie value for a given cookie name
|
|
350
|
-
* @param cookieName - The name of the cookie
|
|
351
|
-
* @returns The locale from the cookie or undefined if not found or invalid
|
|
352
|
-
*/
|
|
353
|
-
function getCookieValue$1({ cookieName }) {
|
|
354
|
-
if (typeof document === "undefined") return void 0;
|
|
355
|
-
return (0, gt_i18n_internal.getCookieValue)(document.cookie, cookieName);
|
|
356
|
-
}
|
|
357
|
-
/**
|
|
358
|
-
* Sets a cookie value for a given cookie name
|
|
359
|
-
* @param cookieName - The name of the cookie
|
|
360
|
-
* @param value - The value to set
|
|
361
|
-
* @returns The value that was set
|
|
362
|
-
*/
|
|
363
|
-
function setCookieValue({ cookieName, value }) {
|
|
364
|
-
if (typeof document === "undefined") return;
|
|
365
|
-
document.cookie = `${cookieName}=${value};path=/`;
|
|
366
|
-
}
|
|
367
|
-
//#endregion
|
|
368
|
-
//#region src/condition-store/readBrowserLocale.ts
|
|
369
|
-
function readBrowserLocale(localeCookieName) {
|
|
370
|
-
const candidates = [];
|
|
371
|
-
const cookieLocale = getCookieValue$1({ cookieName: localeCookieName });
|
|
372
|
-
if (cookieLocale) candidates.push(cookieLocale);
|
|
373
|
-
const navigatorLocales = navigator?.languages || [];
|
|
374
|
-
candidates.push(...navigatorLocales);
|
|
375
|
-
return candidates;
|
|
376
|
-
}
|
|
377
|
-
//#endregion
|
|
378
|
-
//#region src/condition-store/BrowserConditionStore.ts
|
|
379
|
-
/**
|
|
380
|
-
* Condition store implementation for Browser.
|
|
381
|
-
*/
|
|
382
|
-
var BrowserConditionStore = class {
|
|
383
|
-
constructor(config) {
|
|
384
|
-
this.getLocale = () => {
|
|
385
|
-
return getBrowserLocale(this.customGetLocale);
|
|
386
|
-
};
|
|
387
|
-
this.setLocale = (locale) => {
|
|
388
|
-
this.updateLocale(locale);
|
|
389
|
-
setCookieValue({
|
|
390
|
-
cookieName: _generaltranslation_react_core_pure.defaultResetLocaleCookieName,
|
|
391
|
-
value: "true"
|
|
392
|
-
});
|
|
393
|
-
this.reload();
|
|
394
|
-
};
|
|
395
|
-
this.getRegion = () => {
|
|
396
|
-
const cookieRegion = getCookieValue$1({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getRegionCookieName() });
|
|
397
|
-
if (cookieRegion) return cookieRegion;
|
|
398
|
-
return this.customGetRegion?.();
|
|
399
|
-
};
|
|
400
|
-
this.setRegion = (region) => {
|
|
401
|
-
this.updateRegion(region);
|
|
402
|
-
this.reload();
|
|
403
|
-
};
|
|
404
|
-
this.getEnableI18n = () => {
|
|
405
|
-
const cookieEnableI18n = getCookieValue$1({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getEnableI18nCookieName() });
|
|
406
|
-
if (cookieEnableI18n === void 0) return this.customGetEnableI18n?.() ?? true;
|
|
407
|
-
return cookieEnableI18n === "true";
|
|
408
|
-
};
|
|
409
|
-
this.setEnableI18n = (enableI18n) => {
|
|
410
|
-
this.updateEnableI18n(enableI18n);
|
|
411
|
-
this.reload();
|
|
412
|
-
};
|
|
413
|
-
this.updateLocale = (locale) => {
|
|
414
|
-
const i18nConfig = (0, _generaltranslation_react_core_pure.getI18nConfig)();
|
|
415
|
-
setCookieValue({
|
|
416
|
-
cookieName: i18nConfig.getLocaleCookieName(),
|
|
417
|
-
value: i18nConfig.resolveSupportedLocale(locale)
|
|
418
|
-
});
|
|
419
|
-
};
|
|
420
|
-
this.updateRegion = (region) => {
|
|
421
|
-
setCookieValue({
|
|
422
|
-
cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getRegionCookieName(),
|
|
423
|
-
value: region ?? ""
|
|
424
|
-
});
|
|
425
|
-
};
|
|
426
|
-
this.updateEnableI18n = (enableI18n) => {
|
|
427
|
-
setCookieValue({
|
|
428
|
-
cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getEnableI18nCookieName(),
|
|
429
|
-
value: enableI18n ? "true" : "false"
|
|
430
|
-
});
|
|
431
|
-
};
|
|
432
|
-
this.reload = () => {
|
|
433
|
-
const state = {
|
|
434
|
-
locale: this.getLocale(),
|
|
435
|
-
region: this.getRegion(),
|
|
436
|
-
enableI18n: this.getEnableI18n()
|
|
437
|
-
};
|
|
438
|
-
this.customReload(state);
|
|
439
|
-
};
|
|
440
|
-
const i18nConfig = (0, _generaltranslation_react_core_pure.getI18nConfig)();
|
|
441
|
-
this.customReload = config._reload ?? (() => typeof window !== "undefined" ? window.location.reload() : void 0);
|
|
442
|
-
this.customGetLocale = config._getLocale;
|
|
443
|
-
this.customGetRegion = config._getRegion;
|
|
444
|
-
this.customGetEnableI18n = config._getEnableI18n;
|
|
445
|
-
setCookieValue({
|
|
446
|
-
cookieName: i18nConfig.getLocaleCookieName(),
|
|
447
|
-
value: i18nConfig.resolveSupportedLocale(config.locale)
|
|
448
|
-
});
|
|
449
|
-
if (config.region !== void 0) setCookieValue({
|
|
450
|
-
cookieName: i18nConfig.getRegionCookieName(),
|
|
451
|
-
value: config.region
|
|
452
|
-
});
|
|
453
|
-
this.updateEnableI18n(config.enableI18n ?? true);
|
|
454
|
-
}
|
|
455
|
-
};
|
|
456
|
-
function getBrowserLocale(getLocale) {
|
|
457
|
-
const i18nConfig = (0, _generaltranslation_react_core_pure.getI18nConfig)();
|
|
458
|
-
const candidates = readBrowserLocale(i18nConfig.getLocaleCookieName());
|
|
459
|
-
if (getLocale) candidates.push(getLocale());
|
|
460
|
-
return i18nConfig.resolveSupportedLocale(candidates);
|
|
461
|
-
}
|
|
462
|
-
//#endregion
|
|
463
|
-
//#region src/condition-store/singleton-operations.ts
|
|
464
|
-
const conditionStoreNotInitializedError = createDiagnosticMessage({
|
|
465
|
-
source: "gt-react",
|
|
466
|
-
severity: "Error",
|
|
467
|
-
whatHappened: "Cannot read GT runtime context before it has been initialized",
|
|
468
|
-
why: "the internal ConditionStore singleton is unavailable",
|
|
469
|
-
fix: "Call initializeGT() (or initializeGTSPA() in SPA apps) before rendering and add a <GTProvider> at the root of your component tree."
|
|
470
|
-
});
|
|
471
|
-
const { setConditionStore: setReadonlyConditionStore, isConditionStoreInitialized: isReadonlyConditionStoreInitialized } = (0, gt_i18n_internal.createConditionStoreSingleton)(conditionStoreNotInitializedError);
|
|
472
|
-
const { getConditionStore: getBrowserConditionStore, setConditionStore: setBrowserConditionStore, isConditionStoreInitialized: isBrowserConditionStoreInitialized } = (0, gt_i18n_internal.createConditionStoreSingleton)(conditionStoreNotInitializedError);
|
|
473
|
-
//#endregion
|
|
474
|
-
//#region src/condition-store/createBrowserConditionStore.ts
|
|
475
|
-
/**
|
|
476
|
-
* Factory to create a BrowserConditionStore for Singleton
|
|
477
|
-
*
|
|
478
|
-
* This exists so we can keep the locale param as required in the constructor
|
|
479
|
-
*
|
|
480
|
-
* Server-provided props are the first candidates for hydration consistency.
|
|
481
|
-
* Cookies fill in missing values to persist state across page reloads.
|
|
482
|
-
*
|
|
483
|
-
* Cookie names come from the I18nConfig singleton so custom names passed to
|
|
484
|
-
* initializeGT() apply here without being threaded through provider props.
|
|
485
|
-
*/
|
|
486
|
-
function createOrUpdateBrowserConditionStore(config) {
|
|
487
|
-
const locale = determineLocale(config);
|
|
488
|
-
const region = determineRegion(config);
|
|
489
|
-
const enableI18n = determineEnableI18n(config);
|
|
490
|
-
if (isBrowserConditionStoreInitialized()) {
|
|
491
|
-
const conditionStore = getBrowserConditionStore();
|
|
492
|
-
conditionStore.updateLocale(locale);
|
|
493
|
-
if (region !== void 0) conditionStore.updateRegion(region);
|
|
494
|
-
conditionStore.updateEnableI18n(enableI18n);
|
|
495
|
-
return conditionStore;
|
|
496
|
-
}
|
|
497
|
-
const conditionStore = new BrowserConditionStore({
|
|
498
|
-
...config,
|
|
499
|
-
locale,
|
|
500
|
-
region,
|
|
501
|
-
enableI18n
|
|
502
|
-
});
|
|
503
|
-
setBrowserConditionStore(conditionStore);
|
|
504
|
-
return conditionStore;
|
|
505
|
-
}
|
|
506
|
-
function determineLocale({ _getLocale: getLocale, locale }) {
|
|
507
|
-
const i18nConfig = (0, _generaltranslation_react_core_pure.getI18nConfig)();
|
|
508
|
-
const candidates = [];
|
|
509
|
-
if (locale) candidates.push(...Array.isArray(locale) ? locale : [locale]);
|
|
510
|
-
if (getLocale) candidates.push(getLocale());
|
|
511
|
-
candidates.push(...readBrowserLocale(i18nConfig.getLocaleCookieName()));
|
|
512
|
-
return i18nConfig.resolveSupportedLocale(candidates);
|
|
513
|
-
}
|
|
514
|
-
function determineRegion({ _getRegion: getRegion, region }) {
|
|
515
|
-
return getCookieValue$1({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getRegionCookieName() }) || getRegion?.() || region;
|
|
516
|
-
}
|
|
517
|
-
function determineEnableI18n({ enableI18n, _getEnableI18n: getEnableI18n }) {
|
|
518
|
-
if (enableI18n !== void 0) return enableI18n;
|
|
519
|
-
const cookieEnableI18n = getCookieValue$1({ cookieName: (0, _generaltranslation_react_core_pure.getI18nConfig)().getEnableI18nCookieName() });
|
|
520
|
-
if (cookieEnableI18n === void 0) return getEnableI18n?.() ?? true;
|
|
521
|
-
return cookieEnableI18n === "true";
|
|
522
|
-
}
|
|
523
|
-
//#endregion
|
|
524
|
-
//#region src/setup/runtimeCredentials.ts
|
|
525
|
-
function addRuntimeCredentials(config) {
|
|
526
|
-
const credentials = getRuntimeCredentials();
|
|
527
|
-
return {
|
|
528
|
-
...config,
|
|
529
|
-
projectId: config.projectId || credentials.projectId,
|
|
530
|
-
devApiKey: config.devApiKey || credentials.devApiKey
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
function getRuntimeCredentials() {
|
|
534
|
-
return {
|
|
535
|
-
projectId: readImportMetaVite(() => ({}).env?.VITE_GT_PROJECT_ID) || readProcessEnvViteProjectId(),
|
|
536
|
-
devApiKey: (0, gt_i18n_internal.getRuntimeEnvironment)() === "development" ? readImportMetaVite(() => ({}).env?.DEV ? {}.env?.VITE_GT_DEV_API_KEY : void 0) || readProcessEnvViteDevApiKey() : void 0
|
|
537
|
-
};
|
|
538
|
-
}
|
|
539
|
-
function readImportMetaVite(readValue) {
|
|
540
|
-
try {
|
|
541
|
-
return normalizeEnvValue(readValue());
|
|
542
|
-
} catch {
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
function readProcessEnvViteProjectId() {
|
|
547
|
-
try {
|
|
548
|
-
return normalizeEnvValue(process.env.VITE_GT_PROJECT_ID);
|
|
549
|
-
} catch {
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
function readProcessEnvViteDevApiKey() {
|
|
554
|
-
try {
|
|
555
|
-
return normalizeEnvValue(process.env.VITE_GT_DEV_API_KEY);
|
|
556
|
-
} catch {
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
function normalizeEnvValue(value) {
|
|
561
|
-
return value || void 0;
|
|
562
|
-
}
|
|
563
|
-
//#endregion
|
|
564
|
-
//#region src/setup/initializeGTSPA.ts
|
|
565
|
-
/**
|
|
566
|
-
* Initialize GT for an SPA
|
|
567
|
-
* - i18nCache
|
|
568
|
-
* - conditionStore
|
|
569
|
-
* - i18nStore
|
|
570
|
-
*
|
|
571
|
-
* This is SPA for browser runtime
|
|
572
|
-
*/
|
|
573
|
-
async function initializeGTSPA(config) {
|
|
574
|
-
const runtimeConfig = addRuntimeCredentials(config);
|
|
575
|
-
(0, _generaltranslation_react_core_pure.initializeI18nConfig)(runtimeConfig, "SPA");
|
|
576
|
-
(0, _generaltranslation_react_core_pure.setReactI18nCache)(new BrowserI18nCache(runtimeConfig));
|
|
577
|
-
createOrUpdateBrowserConditionStore(runtimeConfig);
|
|
578
|
-
(0, _generaltranslation_react_core_pure.setI18nStore)(new _generaltranslation_react_core_pure.I18nStore());
|
|
579
|
-
await (0, _generaltranslation_react_core_pure.getTranslationsSnapshot)((0, _generaltranslation_react_core_pure.getReadonlyConditionStore)().getLocale());
|
|
580
|
-
}
|
|
581
|
-
//#endregion
|
|
582
|
-
//#region src/setup/initializeGTSRA.ts
|
|
583
|
-
/**
|
|
584
|
-
* Initialize GT for server-rendered React runtimes.
|
|
585
|
-
*/
|
|
586
|
-
function initializeGTSRA(config) {
|
|
587
|
-
(0, _generaltranslation_react_core_pure.internalInitializeGTSRA)(addRuntimeCredentials(config));
|
|
588
|
-
}
|
|
589
|
-
//#endregion
|
|
590
|
-
//#region src/functions/parseLocale.ts
|
|
591
|
-
/**
|
|
592
|
-
* Resolve the user's locale from a Web Request.
|
|
593
|
-
*
|
|
594
|
-
* The configured locale cookie takes precedence over the Accept-Language
|
|
595
|
-
* header. If neither contains a supported locale, the configured default
|
|
596
|
-
* locale is returned.
|
|
597
|
-
*
|
|
598
|
-
* This is intended for incoming server requests. A Request created in the
|
|
599
|
-
* browser does not automatically include document cookies or Accept-Language.
|
|
600
|
-
*/
|
|
601
|
-
function parseLocale(request) {
|
|
602
|
-
const i18nConfig = (0, _generaltranslation_react_core_pure.getI18nConfig)();
|
|
603
|
-
const candidates = [];
|
|
604
|
-
const cookieLocale = (0, gt_i18n_internal.getCookieValue)(request.headers.get("cookie"), i18nConfig.getLocaleCookieName());
|
|
605
|
-
if (cookieLocale) candidates.push(cookieLocale);
|
|
606
|
-
candidates.push(...(0, gt_i18n_internal.parseAcceptLanguage)(request.headers.get("accept-language")));
|
|
607
|
-
return i18nConfig.resolveSupportedLocale(candidates);
|
|
608
|
-
}
|
|
609
|
-
//#endregion
|
|
610
|
-
//#region src/hooks/conditions-store.ts
|
|
611
|
-
/**
|
|
612
|
-
* Returns a function that sets the locale
|
|
613
|
-
*/
|
|
614
|
-
function useSetLocale() {
|
|
615
|
-
const conditionStore = (0, _generaltranslation_react_core_hooks.useConditionStore)();
|
|
616
|
-
return (0, react.useCallback)((locale) => {
|
|
617
|
-
conditionStore.setLocale(locale);
|
|
618
|
-
}, [conditionStore]);
|
|
619
|
-
}
|
|
620
|
-
/**
|
|
621
|
-
* Returns a function that sets the region
|
|
622
|
-
*/
|
|
623
|
-
function useSetRegion() {
|
|
624
|
-
const conditionStore = (0, _generaltranslation_react_core_hooks.useConditionStore)();
|
|
625
|
-
return (0, react.useCallback)((region) => {
|
|
626
|
-
conditionStore.setRegion(region);
|
|
627
|
-
}, [conditionStore]);
|
|
628
|
-
}
|
|
629
|
-
/**
|
|
630
|
-
* Returns a function that sets the enableI18n flag in the condition store.
|
|
631
|
-
*/
|
|
632
|
-
function useSetEnableI18n() {
|
|
633
|
-
const conditionStore = (0, _generaltranslation_react_core_hooks.useConditionStore)();
|
|
634
|
-
return (0, react.useCallback)((enableI18n) => {
|
|
635
|
-
conditionStore.setEnableI18n(enableI18n);
|
|
636
|
-
}, [conditionStore]);
|
|
637
|
-
}
|
|
638
|
-
//#endregion
|
|
639
|
-
//#region src/components/useLocaleSelector.ts
|
|
640
|
-
/**
|
|
641
|
-
* Gets the list of properties for using a locale selector.
|
|
642
|
-
* Provides locale management utilities for the application.
|
|
643
|
-
*
|
|
644
|
-
* @param locales an optional list of locales to use for the drop down. These locales must be a subset of the locales provided by the `<GTProvider>` context. When not provided, the list of locales from the `<GTProvider>` context is used.
|
|
645
|
-
*
|
|
646
|
-
* @returns {Object} An object containing locale-related utilities:
|
|
647
|
-
* @returns {string} return.locale - The currently selected locale.
|
|
648
|
-
* @returns {string[]} return.locales - The list of all available locales.
|
|
649
|
-
* @returns {function} return.setLocale - Function to update the current locale.
|
|
650
|
-
* @returns {(locale: string) => LocaleProperties} return.getLocaleProperties - Function to retrieve properties for a given locale.
|
|
651
|
-
*/
|
|
652
|
-
function useLocaleSelector(locales) {
|
|
653
|
-
return {
|
|
654
|
-
setLocale: useSetLocale(),
|
|
655
|
-
...(0, _generaltranslation_react_core_hooks.useInternalLocaleSelector)(locales)
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
//#endregion
|
|
659
|
-
//#region src/components/useRegionSelector.ts
|
|
660
|
-
/**
|
|
661
|
-
* Gets the list of properties for using a region selector.
|
|
662
|
-
* Provides region management utilities for the application.
|
|
663
|
-
*
|
|
664
|
-
* @param {Object} [options] - Optional configuration object.
|
|
665
|
-
* @param {string[]} [options.regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from supported locales.
|
|
666
|
-
* @param {Object} [options.customMapping] - Optional mapping to override region display names, emojis, or associated locales.
|
|
667
|
-
* @param {boolean} [options.prioritizeCurrentLocaleRegion=true] - If true, the region corresponding to the current locale is prioritized in the list.
|
|
668
|
-
* @param {boolean} [options.sortRegionsAlphabetically=true] - If true, regions are sorted alphabetically by display name.
|
|
669
|
-
*
|
|
670
|
-
* @returns {Object} An object containing region-related utilities:
|
|
671
|
-
* @returns {string | undefined} return.region - The currently selected region code.
|
|
672
|
-
* @returns {function} return.setRegion - Function to update the current region.
|
|
673
|
-
* @returns {string[]} return.regions - The ordered list of available region codes.
|
|
674
|
-
* @returns {Map<string, RegionData>} return.regionData - Map of region codes to their display data (name, emoji, locale).
|
|
675
|
-
* @returns {string} return.locale - The current locale.
|
|
676
|
-
* @returns {function} return.setLocale - Function to update the current locale.
|
|
677
|
-
*/
|
|
678
|
-
function useRegionSelector(options) {
|
|
679
|
-
return {
|
|
680
|
-
setRegion: useSetRegion(),
|
|
681
|
-
setLocale: useSetLocale(),
|
|
682
|
-
...(0, _generaltranslation_react_core_hooks.useInternalRegionSelector)(options)
|
|
683
|
-
};
|
|
684
|
-
}
|
|
685
|
-
//#endregion
|
|
686
|
-
//#region src/components/LocaleSelector.tsx
|
|
687
|
-
/**
|
|
688
|
-
* A dropdown component that allows users to select a locale.
|
|
689
|
-
* @param {string[]} [locales] - An optional list of locales to use for the dropdown. If not provided, the list of locales from the `<GTProvider>` context is used.
|
|
690
|
-
* @param {object} [customNames] - (deprecated) An optional object to map locales to custom names. Use `customMapping` instead.
|
|
691
|
-
* @param {CustomMapping} [customMapping] - An optional object to map locales to custom display names, emojis, or other properties.
|
|
692
|
-
* @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.
|
|
693
|
-
*/
|
|
694
|
-
function LocaleSelector({ locales: _locales, ...props }) {
|
|
695
|
-
const { locale, locales, getLocaleProperties, setLocale } = useLocaleSelector(_locales);
|
|
696
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_generaltranslation_react_core_components.InternalLocaleSelector, {
|
|
697
|
-
locale,
|
|
698
|
-
locales,
|
|
699
|
-
setLocale,
|
|
700
|
-
getLocaleProperties,
|
|
701
|
-
...props
|
|
702
|
-
});
|
|
703
|
-
}
|
|
704
|
-
//#endregion
|
|
705
|
-
//#region src/components/RegionSelector.tsx
|
|
706
|
-
/**
|
|
707
|
-
* A dropdown component that allows users to select a region.
|
|
708
|
-
* @param {string[]} [regions] - An optional array of ISO 3166 region codes to display. If not provided, regions are inferred from the supported locales in the `<GTProvider>` context.
|
|
709
|
-
* @param {React.ReactNode} [placeholder] - Optional placeholder node to display as the first option when no region is selected.
|
|
710
|
-
* @param {object} [customMapping] - An optional object to map region codes to custom display names, emojis, or associated locales.
|
|
711
|
-
* @param {boolean} [prioritizeCurrentLocaleRegion] - If true, the region corresponding to the current locale is prioritized in the list.
|
|
712
|
-
* @param {boolean} [sortRegionsAlphabetically] - If true, regions are sorted alphabetically by display name.
|
|
713
|
-
* @param {boolean} [asLocaleSelector=false] - If true, selecting a region will also update the locale to the region's associated locale.
|
|
714
|
-
* @returns {React.ReactElement | null} The rendered region dropdown component or null to prevent rendering.
|
|
715
|
-
*
|
|
716
|
-
* @example
|
|
717
|
-
* ```tsx
|
|
718
|
-
* <RegionSelector
|
|
719
|
-
* regions={['US', 'CA']}
|
|
720
|
-
* customMapping={{ US: { name: "United States", emoji: "🇺🇸" } }}
|
|
721
|
-
* placeholder="Select a region"
|
|
722
|
-
* />
|
|
723
|
-
* ```
|
|
724
|
-
*/
|
|
725
|
-
function RegionSelector({ regions: _regions, customMapping, prioritizeCurrentLocaleRegion, sortRegionsAlphabetically, asLocaleSelector = false, ...props }) {
|
|
726
|
-
const { region, regions, regionData, locale, setRegion, setLocale } = useRegionSelector({
|
|
727
|
-
regions: _regions,
|
|
728
|
-
customMapping,
|
|
729
|
-
prioritizeCurrentLocaleRegion,
|
|
730
|
-
sortRegionsAlphabetically
|
|
731
|
-
});
|
|
732
|
-
const changeRegion = (region) => {
|
|
733
|
-
if (asLocaleSelector) {
|
|
734
|
-
const regionLocale = regionData.get(region)?.locale;
|
|
735
|
-
if (regionLocale && locale !== regionLocale) setLocale(regionLocale);
|
|
736
|
-
}
|
|
737
|
-
setRegion(region);
|
|
738
|
-
};
|
|
739
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_generaltranslation_react_core_components.InternalRegionSelector, {
|
|
740
|
-
region,
|
|
741
|
-
regions,
|
|
742
|
-
regionData,
|
|
743
|
-
setRegion: changeRegion,
|
|
744
|
-
...props
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
|
-
//#endregion
|
|
748
|
-
//#region src/provider/BrowserGTProvider.tsx
|
|
749
|
-
/**
|
|
750
|
-
* Consumes snapshot from server
|
|
751
|
-
* Implementation for client-side only
|
|
752
|
-
*/
|
|
753
|
-
function BrowserGTProvider(props) {
|
|
754
|
-
const conditionStore = (0, react.useMemo)(() => {
|
|
755
|
-
return createOrUpdateBrowserConditionStore(props);
|
|
756
|
-
}, [
|
|
757
|
-
props.locale,
|
|
758
|
-
props.region,
|
|
759
|
-
props.enableI18n,
|
|
760
|
-
props._reload
|
|
761
|
-
]);
|
|
762
|
-
const i18nStoreRef = (0, react.useRef)(null);
|
|
763
|
-
if (i18nStoreRef.current == null) i18nStoreRef.current = new _generaltranslation_react_core_components.I18nStore();
|
|
764
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_generaltranslation_react_core_components.InternalGTProvider, {
|
|
765
|
-
...props,
|
|
766
|
-
conditionStore,
|
|
767
|
-
i18nStore: i18nStoreRef.current
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
//#endregion
|
|
771
|
-
//#region src/index.types.ts
|
|
772
|
-
async function Tx(_props) {
|
|
773
|
-
throw new Error("Tx is only supported via RSC");
|
|
774
|
-
}
|
|
775
|
-
//#endregion
|
|
776
|
-
Object.defineProperty(exports, "Branch", {
|
|
777
|
-
enumerable: true,
|
|
778
|
-
get: function() {
|
|
779
|
-
return _generaltranslation_react_core_components.Branch;
|
|
780
|
-
}
|
|
781
|
-
});
|
|
782
|
-
Object.defineProperty(exports, "Currency", {
|
|
783
|
-
enumerable: true,
|
|
784
|
-
get: function() {
|
|
785
|
-
return _generaltranslation_react_core_components.Currency;
|
|
786
|
-
}
|
|
787
|
-
});
|
|
788
|
-
Object.defineProperty(exports, "DateTime", {
|
|
789
|
-
enumerable: true,
|
|
790
|
-
get: function() {
|
|
791
|
-
return _generaltranslation_react_core_components.DateTime;
|
|
792
|
-
}
|
|
793
|
-
});
|
|
794
|
-
Object.defineProperty(exports, "Derive", {
|
|
795
|
-
enumerable: true,
|
|
796
|
-
get: function() {
|
|
797
|
-
return _generaltranslation_react_core_components.Derive;
|
|
798
|
-
}
|
|
799
|
-
});
|
|
800
|
-
exports.GTProvider = BrowserGTProvider;
|
|
801
|
-
Object.defineProperty(exports, "GtInternalRuntimeTranslateJsx", {
|
|
802
|
-
enumerable: true,
|
|
803
|
-
get: function() {
|
|
804
|
-
return gt_i18n_internal.GtInternalRuntimeTranslateJsx;
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
Object.defineProperty(exports, "GtInternalRuntimeTranslateString", {
|
|
808
|
-
enumerable: true,
|
|
809
|
-
get: function() {
|
|
810
|
-
return gt_i18n_internal.GtInternalRuntimeTranslateString;
|
|
811
|
-
}
|
|
812
|
-
});
|
|
813
|
-
Object.defineProperty(exports, "GtInternalTranslateJsx", {
|
|
814
|
-
enumerable: true,
|
|
815
|
-
get: function() {
|
|
816
|
-
return _generaltranslation_react_core_components.GtInternalTranslateJsx;
|
|
817
|
-
}
|
|
818
|
-
});
|
|
819
|
-
Object.defineProperty(exports, "GtInternalVar", {
|
|
820
|
-
enumerable: true,
|
|
821
|
-
get: function() {
|
|
822
|
-
return _generaltranslation_react_core_components.GtInternalVar;
|
|
823
|
-
}
|
|
824
|
-
});
|
|
825
|
-
exports.LocaleSelector = LocaleSelector;
|
|
826
|
-
Object.defineProperty(exports, "Num", {
|
|
827
|
-
enumerable: true,
|
|
828
|
-
get: function() {
|
|
829
|
-
return _generaltranslation_react_core_components.Num;
|
|
830
|
-
}
|
|
831
|
-
});
|
|
832
|
-
Object.defineProperty(exports, "Plural", {
|
|
833
|
-
enumerable: true,
|
|
834
|
-
get: function() {
|
|
835
|
-
return _generaltranslation_react_core_components.Plural;
|
|
836
|
-
}
|
|
837
|
-
});
|
|
838
|
-
Object.defineProperty(exports, "ReactI18nCache", {
|
|
839
|
-
enumerable: true,
|
|
840
|
-
get: function() {
|
|
841
|
-
return _generaltranslation_react_core_pure.ReactI18nCache;
|
|
842
|
-
}
|
|
843
|
-
});
|
|
844
|
-
exports.RegionSelector = RegionSelector;
|
|
845
|
-
Object.defineProperty(exports, "RelativeTime", {
|
|
846
|
-
enumerable: true,
|
|
847
|
-
get: function() {
|
|
848
|
-
return _generaltranslation_react_core_components.RelativeTime;
|
|
849
|
-
}
|
|
850
|
-
});
|
|
851
|
-
Object.defineProperty(exports, "T", {
|
|
852
|
-
enumerable: true,
|
|
853
|
-
get: function() {
|
|
854
|
-
return _generaltranslation_react_core_components.T;
|
|
855
|
-
}
|
|
856
|
-
});
|
|
857
|
-
exports.Tx = Tx;
|
|
858
|
-
Object.defineProperty(exports, "Var", {
|
|
859
|
-
enumerable: true,
|
|
860
|
-
get: function() {
|
|
861
|
-
return _generaltranslation_react_core_components.Var;
|
|
862
|
-
}
|
|
863
|
-
});
|
|
864
|
-
Object.defineProperty(exports, "createRenderPipeline", {
|
|
865
|
-
enumerable: true,
|
|
866
|
-
get: function() {
|
|
867
|
-
return _generaltranslation_react_core_pure.createRenderPipeline;
|
|
868
|
-
}
|
|
869
|
-
});
|
|
870
|
-
Object.defineProperty(exports, "declareVar", {
|
|
871
|
-
enumerable: true,
|
|
872
|
-
get: function() {
|
|
873
|
-
return _generaltranslation_react_core_pure.declareVar;
|
|
874
|
-
}
|
|
875
|
-
});
|
|
876
|
-
Object.defineProperty(exports, "decodeMsg", {
|
|
877
|
-
enumerable: true,
|
|
878
|
-
get: function() {
|
|
879
|
-
return _generaltranslation_react_core_pure.decodeMsg;
|
|
880
|
-
}
|
|
881
|
-
});
|
|
882
|
-
Object.defineProperty(exports, "decodeOptions", {
|
|
883
|
-
enumerable: true,
|
|
884
|
-
get: function() {
|
|
885
|
-
return _generaltranslation_react_core_pure.decodeOptions;
|
|
886
|
-
}
|
|
887
|
-
});
|
|
888
|
-
Object.defineProperty(exports, "decodeVars", {
|
|
889
|
-
enumerable: true,
|
|
890
|
-
get: function() {
|
|
891
|
-
return _generaltranslation_react_core_pure.decodeVars;
|
|
892
|
-
}
|
|
893
|
-
});
|
|
894
|
-
Object.defineProperty(exports, "derive", {
|
|
895
|
-
enumerable: true,
|
|
896
|
-
get: function() {
|
|
897
|
-
return _generaltranslation_react_core_pure.derive;
|
|
898
|
-
}
|
|
899
|
-
});
|
|
900
|
-
Object.defineProperty(exports, "getDefaultLocale", {
|
|
901
|
-
enumerable: true,
|
|
902
|
-
get: function() {
|
|
903
|
-
return _generaltranslation_react_core_pure.getDefaultLocale;
|
|
904
|
-
}
|
|
905
|
-
});
|
|
906
|
-
Object.defineProperty(exports, "getFormatLocales", {
|
|
907
|
-
enumerable: true,
|
|
908
|
-
get: function() {
|
|
909
|
-
return _generaltranslation_react_core_pure.getFormatLocales;
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
Object.defineProperty(exports, "getLocaleProperties", {
|
|
913
|
-
enumerable: true,
|
|
914
|
-
get: function() {
|
|
915
|
-
return _generaltranslation_react_core_pure.getLocaleProperties;
|
|
916
|
-
}
|
|
917
|
-
});
|
|
918
|
-
Object.defineProperty(exports, "getLocales", {
|
|
919
|
-
enumerable: true,
|
|
920
|
-
get: function() {
|
|
921
|
-
return _generaltranslation_react_core_pure.getLocales;
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
Object.defineProperty(exports, "getReactI18nCache", {
|
|
925
|
-
enumerable: true,
|
|
926
|
-
get: function() {
|
|
927
|
-
return _generaltranslation_react_core_pure.getReactI18nCache;
|
|
928
|
-
}
|
|
929
|
-
});
|
|
930
|
-
Object.defineProperty(exports, "getTranslationsSnapshot", {
|
|
931
|
-
enumerable: true,
|
|
932
|
-
get: function() {
|
|
933
|
-
return _generaltranslation_react_core_pure.getTranslationsSnapshot;
|
|
934
|
-
}
|
|
935
|
-
});
|
|
936
|
-
Object.defineProperty(exports, "getVersionId", {
|
|
937
|
-
enumerable: true,
|
|
938
|
-
get: function() {
|
|
939
|
-
return _generaltranslation_react_core_pure.getVersionId;
|
|
940
|
-
}
|
|
941
|
-
});
|
|
942
|
-
Object.defineProperty(exports, "gtFallback", {
|
|
943
|
-
enumerable: true,
|
|
944
|
-
get: function() {
|
|
945
|
-
return _generaltranslation_react_core_pure.gtFallback;
|
|
946
|
-
}
|
|
947
|
-
});
|
|
948
|
-
exports.initializeGT = initializeGTSRA;
|
|
949
|
-
exports.initializeGTSPA = initializeGTSPA;
|
|
950
|
-
Object.defineProperty(exports, "mFallback", {
|
|
951
|
-
enumerable: true,
|
|
952
|
-
get: function() {
|
|
953
|
-
return _generaltranslation_react_core_pure.mFallback;
|
|
954
|
-
}
|
|
955
|
-
});
|
|
956
|
-
Object.defineProperty(exports, "msg", {
|
|
957
|
-
enumerable: true,
|
|
958
|
-
get: function() {
|
|
959
|
-
return _generaltranslation_react_core_pure.msg;
|
|
960
|
-
}
|
|
961
|
-
});
|
|
962
|
-
exports.parseLocale = parseLocale;
|
|
963
|
-
Object.defineProperty(exports, "resolveCanonicalLocale", {
|
|
964
|
-
enumerable: true,
|
|
965
|
-
get: function() {
|
|
966
|
-
return _generaltranslation_react_core_pure.resolveCanonicalLocale;
|
|
967
|
-
}
|
|
968
|
-
});
|
|
969
|
-
Object.defineProperty(exports, "setReactI18nCache", {
|
|
970
|
-
enumerable: true,
|
|
971
|
-
get: function() {
|
|
972
|
-
return _generaltranslation_react_core_pure.setReactI18nCache;
|
|
973
|
-
}
|
|
974
|
-
});
|
|
975
|
-
Object.defineProperty(exports, "t", {
|
|
976
|
-
enumerable: true,
|
|
977
|
-
get: function() {
|
|
978
|
-
return _generaltranslation_react_core_pure.t;
|
|
979
|
-
}
|
|
980
|
-
});
|
|
981
|
-
Object.defineProperty(exports, "useCustomMapping", {
|
|
982
|
-
enumerable: true,
|
|
983
|
-
get: function() {
|
|
984
|
-
return _generaltranslation_react_core_hooks.useCustomMapping;
|
|
985
|
-
}
|
|
986
|
-
});
|
|
987
|
-
Object.defineProperty(exports, "useDefaultLocale", {
|
|
988
|
-
enumerable: true,
|
|
989
|
-
get: function() {
|
|
990
|
-
return _generaltranslation_react_core_hooks.useDefaultLocale;
|
|
991
|
-
}
|
|
992
|
-
});
|
|
993
|
-
Object.defineProperty(exports, "useEnableI18n", {
|
|
994
|
-
enumerable: true,
|
|
995
|
-
get: function() {
|
|
996
|
-
return _generaltranslation_react_core_hooks.useEnableI18n;
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
Object.defineProperty(exports, "useFormatLocales", {
|
|
1000
|
-
enumerable: true,
|
|
1001
|
-
get: function() {
|
|
1002
|
-
return _generaltranslation_react_core_hooks.useFormatLocales;
|
|
1003
|
-
}
|
|
1004
|
-
});
|
|
1005
|
-
Object.defineProperty(exports, "useGT", {
|
|
1006
|
-
enumerable: true,
|
|
1007
|
-
get: function() {
|
|
1008
|
-
return _generaltranslation_react_core_hooks.useGT;
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
Object.defineProperty(exports, "useLocale", {
|
|
1012
|
-
enumerable: true,
|
|
1013
|
-
get: function() {
|
|
1014
|
-
return _generaltranslation_react_core_hooks.useLocale;
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
|
-
Object.defineProperty(exports, "useLocaleDirection", {
|
|
1018
|
-
enumerable: true,
|
|
1019
|
-
get: function() {
|
|
1020
|
-
return _generaltranslation_react_core_hooks.useLocaleDirection;
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
1023
|
-
Object.defineProperty(exports, "useLocaleProperties", {
|
|
1024
|
-
enumerable: true,
|
|
1025
|
-
get: function() {
|
|
1026
|
-
return _generaltranslation_react_core_hooks.useLocaleProperties;
|
|
1027
|
-
}
|
|
1028
|
-
});
|
|
1029
|
-
exports.useLocaleSelector = useLocaleSelector;
|
|
1030
|
-
Object.defineProperty(exports, "useLocales", {
|
|
1031
|
-
enumerable: true,
|
|
1032
|
-
get: function() {
|
|
1033
|
-
return _generaltranslation_react_core_hooks.useLocales;
|
|
1034
|
-
}
|
|
1035
|
-
});
|
|
1036
|
-
Object.defineProperty(exports, "useMessages", {
|
|
1037
|
-
enumerable: true,
|
|
1038
|
-
get: function() {
|
|
1039
|
-
return _generaltranslation_react_core_hooks.useMessages;
|
|
1040
|
-
}
|
|
1041
|
-
});
|
|
1042
|
-
Object.defineProperty(exports, "useRegion", {
|
|
1043
|
-
enumerable: true,
|
|
1044
|
-
get: function() {
|
|
1045
|
-
return _generaltranslation_react_core_hooks.useRegion;
|
|
1046
|
-
}
|
|
1047
|
-
});
|
|
1048
|
-
exports.useRegionSelector = useRegionSelector;
|
|
1049
|
-
exports.useSetEnableI18n = useSetEnableI18n;
|
|
1050
|
-
exports.useSetLocale = useSetLocale;
|
|
1051
|
-
exports.useSetRegion = useSetRegion;
|
|
1052
|
-
Object.defineProperty(exports, "useTranslations", {
|
|
1053
|
-
enumerable: true,
|
|
1054
|
-
get: function() {
|
|
1055
|
-
return _generaltranslation_react_core_hooks.useTranslations;
|
|
1056
|
-
}
|
|
1057
|
-
});
|
|
1058
|
-
|
|
1059
|
-
//# sourceMappingURL=index.types.cjs.map
|