@fisharmy100/react-auto-i18n 1.0.0

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/dist/index.js ADDED
@@ -0,0 +1,1346 @@
1
+ // src/components/CountryFlag.tsx
2
+ import "flag-icons/css/flag-icons.min.css";
3
+ import { jsx } from "react/jsx-runtime";
4
+ function CountryFlag({
5
+ country,
6
+ className,
7
+ ...rest
8
+ }) {
9
+ let flagClass = `fi fi-${country.toLocaleLowerCase()}`;
10
+ return /* @__PURE__ */ jsx(
11
+ "span",
12
+ {
13
+ className: `${flagClass}${className ? ` ${className}` : ""}`,
14
+ ...rest
15
+ }
16
+ );
17
+ }
18
+
19
+ // src/components/I18nFileProvider.tsx
20
+ import { useEffect as useEffect2, useState as useState2 } from "react";
21
+
22
+ // src/core/database.ts
23
+ var SimpleI18nDb = class _SimpleI18nDb {
24
+ db;
25
+ constructor(db) {
26
+ this.db = db;
27
+ }
28
+ addOnChangeListener() {
29
+ }
30
+ removeOnChangeListener() {
31
+ return false;
32
+ }
33
+ /**
34
+ * Creates a {@link SimpleI18nDb} from a file. The file the path points to must be in the format of {@link I18nDatabaseType}
35
+ * @param path The path of the database file.
36
+ * @returns
37
+ */
38
+ static async load(path) {
39
+ const res = await fetch(path);
40
+ const json = await res.text();
41
+ const db = JSON.parse(json);
42
+ return new _SimpleI18nDb(db);
43
+ }
44
+ get(lang, key) {
45
+ return this.db[lang]?.[key];
46
+ }
47
+ langs() {
48
+ return Object.keys(this.db).map((k) => k);
49
+ }
50
+ };
51
+ var FOLDER_LANGUAGE_MANIFEST_NAME = "manifest.json";
52
+ var CachedMultiFileI18nDb = class _CachedMultiFileI18nDb {
53
+ supportedLangs;
54
+ db;
55
+ path;
56
+ onChangedListeners;
57
+ /**
58
+ * @param path The folder path which contains all multiple files of type {@link LanguageTranslations} and each must be named using {@link LangScriptCode} followed by a `.json`
59
+ * @param langs Represents all of the languages that the translation folder contains. Essentially, if the folder has a file for a given language, add that language here.
60
+ */
61
+ constructor(path, langs) {
62
+ this.path = path;
63
+ this.supportedLangs = langs;
64
+ this.db = {};
65
+ this.onChangedListeners = [];
66
+ }
67
+ /**
68
+ * Creates a {@link CachedMultiFileI18nDb} from a folder path.
69
+ * The folder path which contains all multiple files of type {@link LanguageTranslations}, and each must be named using {@link LangScriptCode} followed by a `.json`.
70
+ * It needs to point to a folder inside of the `public` folder, and the folder must contain a `manifest.json` file of the format {@link FolderLanguageManifestType}
71
+ */
72
+ static async load(folder) {
73
+ const manifestPath = folder + "/" + FOLDER_LANGUAGE_MANIFEST_NAME;
74
+ const registered = await fetch(manifestPath).then((f) => f.text()).then((t) => JSON.parse(t));
75
+ return new _CachedMultiFileI18nDb(folder, registered.langs);
76
+ }
77
+ get(lang, key) {
78
+ if (!this.supportedLangs.includes(lang)) {
79
+ return void 0;
80
+ }
81
+ if (this.db[lang] === void 0) {
82
+ const filePath = this.path + `/${lang}.json`;
83
+ fetch(filePath).then((f) => f.text()).then((t) => JSON.parse(t)).then((translations) => {
84
+ this.db[lang] = translations;
85
+ this.invokeOnChangeListeners();
86
+ });
87
+ return void 0;
88
+ }
89
+ return this.db[lang]?.[key];
90
+ }
91
+ langs() {
92
+ return this.supportedLangs;
93
+ }
94
+ addOnChangeListener(listener) {
95
+ this.onChangedListeners.push(listener);
96
+ }
97
+ removeOnChangeListener(listener) {
98
+ const len = this.onChangedListeners.length;
99
+ this.onChangedListeners = this.onChangedListeners.filter((l) => l !== listener);
100
+ return len !== this.onChangedListeners.length;
101
+ }
102
+ invokeOnChangeListeners() {
103
+ this.onChangedListeners.forEach((l) => {
104
+ l();
105
+ });
106
+ }
107
+ };
108
+ var I18nDatabaseDefault = {
109
+ get: () => void 0,
110
+ langs: () => [],
111
+ addOnChangeListener: () => {
112
+ },
113
+ removeOnChangeListener: () => false
114
+ };
115
+
116
+ // src/i18n.ts
117
+ var currentLocale = "eng_Latn";
118
+ var database = I18nDatabaseDefault;
119
+ function setI18nDatabaseRaw(db) {
120
+ database = db;
121
+ }
122
+ function getI18nDatabaseRaw() {
123
+ return database;
124
+ }
125
+ function setCurrentLocalRaw(locale) {
126
+ currentLocale = locale;
127
+ }
128
+ function getCurrentLocalRaw() {
129
+ return currentLocale;
130
+ }
131
+ function __t(key, message, arg) {
132
+ const translated = innerT(key, message);
133
+ if (arg !== void 0) {
134
+ const regex = /\{\{\$(\w+)\}\}/g;
135
+ return translated.replaceAll(regex, (_, p1) => {
136
+ let a = arg[p1];
137
+ if (a === void 0) {
138
+ return `{{$${p1}}}`;
139
+ } else {
140
+ return `${a}`;
141
+ }
142
+ });
143
+ } else {
144
+ return translated;
145
+ }
146
+ }
147
+ function innerT(key, message) {
148
+ const translation = database.get(currentLocale, key);
149
+ if (translation === void 0) {
150
+ return message;
151
+ } else if (typeof translation === "string") {
152
+ return translation;
153
+ } else {
154
+ return translation[0];
155
+ }
156
+ }
157
+ function __tv(key, messages, arg) {
158
+ const translated = innerTv(key, messages, arg);
159
+ const regex = /\{\{\$(\w+)\}\}/g;
160
+ return translated.replaceAll(regex, (_, p1) => {
161
+ let a = arg[p1];
162
+ if (a === void 0) {
163
+ return `{{$${p1}}}`;
164
+ } else {
165
+ return `${a}`;
166
+ }
167
+ });
168
+ }
169
+ function innerTv(key, messages, arg) {
170
+ const translation = database.get(currentLocale, key);
171
+ const index = selectIndex(messages, arg);
172
+ if (translation === void 0) {
173
+ const msg = messages[index];
174
+ return typeof msg === "string" ? msg : msg[0];
175
+ }
176
+ if (typeof translation === "string") {
177
+ return translation;
178
+ }
179
+ return translation[index] ?? translation[translation.length - 1];
180
+ }
181
+ function selectIndex(messages, arg) {
182
+ for (let i = 0; i < messages.length - 1; i++) {
183
+ const m = messages[i];
184
+ if (typeof m !== "string") {
185
+ const [, predicate] = m;
186
+ if (predicate(arg)) return i;
187
+ }
188
+ }
189
+ return messages.length - 1;
190
+ }
191
+
192
+ // src/core/country.ts
193
+ function getCountryCode(code) {
194
+ const LANGUAGE_TO_COUNTRY = {
195
+ ace: "ID",
196
+ acm: "IQ",
197
+ acq: "YE",
198
+ aeb: "TN",
199
+ afr: "ZA",
200
+ als: "AL",
201
+ amh: "ET",
202
+ apc: "SY",
203
+ arb: "SA",
204
+ arg: "ES",
205
+ ars: "SA",
206
+ ary: "MA",
207
+ arz: "EG",
208
+ asm: "IN",
209
+ ast: "ES",
210
+ awa: "IN",
211
+ ayr: "BO",
212
+ azb: "IR",
213
+ azj: "AZ",
214
+ bak: "RU",
215
+ bam: "ML",
216
+ ban: "ID",
217
+ bel: "BY",
218
+ bem: "ZM",
219
+ ben: "BD",
220
+ bho: "IN",
221
+ bjn: "ID",
222
+ bod: "CN",
223
+ bos: "BA",
224
+ brx: "IN",
225
+ bug: "ID",
226
+ bul: "BG",
227
+ cat: "ES",
228
+ ceb: "PH",
229
+ ces: "CZ",
230
+ chv: "RU",
231
+ cjk: "CM",
232
+ ckb: "IQ",
233
+ cmn: "CN",
234
+ crh: "UA",
235
+ cym: "GB",
236
+ dan: "DK",
237
+ dar: "RU",
238
+ deu: "DE",
239
+ dgo: "IN",
240
+ dik: "SS",
241
+ dyu: "BF",
242
+ dzo: "BT",
243
+ ekk: "EE",
244
+ ell: "GR",
245
+ eng: "US",
246
+ epo: "PL",
247
+ eus: "ES",
248
+ ewe: "GH",
249
+ fao: "FO",
250
+ fij: "FJ",
251
+ fil: "PH",
252
+ fin: "FI",
253
+ fon: "BJ",
254
+ fra: "FR",
255
+ fur: "IT",
256
+ fuv: "NG",
257
+ gaz: "ET",
258
+ gla: "GB",
259
+ gle: "IE",
260
+ glg: "ES",
261
+ gom: "IN",
262
+ gug: "PY",
263
+ guj: "IN",
264
+ hat: "HT",
265
+ hau: "NG",
266
+ heb: "IL",
267
+ hin: "IN",
268
+ hne: "IN",
269
+ hrv: "HR",
270
+ hun: "HU",
271
+ hye: "AM",
272
+ ibo: "NG",
273
+ ilo: "PH",
274
+ ind: "ID",
275
+ isl: "IS",
276
+ ita: "IT",
277
+ jav: "ID",
278
+ jpn: "JP",
279
+ kaa: "UZ",
280
+ kab: "DZ",
281
+ kac: "MM",
282
+ kam: "KE",
283
+ kan: "IN",
284
+ kas: "IN",
285
+ kat: "GE",
286
+ kaz: "KZ",
287
+ kbp: "TG",
288
+ kea: "CV",
289
+ khk: "MN",
290
+ khm: "KH",
291
+ kik: "KE",
292
+ kin: "RW",
293
+ kir: "KG",
294
+ kmb: "AO",
295
+ kmr: "TR",
296
+ knc: "NG",
297
+ kor: "KR",
298
+ ktu: "CI",
299
+ lao: "LA",
300
+ lij: "IT",
301
+ lim: "NL",
302
+ lin: "CD",
303
+ lit: "LT",
304
+ lld: "IT",
305
+ lmo: "IT",
306
+ ltg: "LV",
307
+ ltz: "LU",
308
+ lua: "CD",
309
+ lug: "UG",
310
+ luo: "KE",
311
+ lus: "IN",
312
+ lvs: "LV",
313
+ mag: "IN",
314
+ mai: "IN",
315
+ mal: "IN",
316
+ mar: "IN",
317
+ mfe: "MU",
318
+ mhr: "RU",
319
+ min: "ID",
320
+ mkd: "MK",
321
+ mlt: "MT",
322
+ mni: "IN",
323
+ mos: "BF",
324
+ mri: "NZ",
325
+ mya: "MM",
326
+ myv: "RU",
327
+ nld: "NL",
328
+ nno: "NO",
329
+ nob: "NO",
330
+ npi: "NP",
331
+ nqo: "GN",
332
+ nso: "ZA",
333
+ nus: "SS",
334
+ nya: "MW",
335
+ oci: "FR",
336
+ ory: "IN",
337
+ pag: "PH",
338
+ pan: "IN",
339
+ pap: "AW",
340
+ pbt: "AF",
341
+ pes: "IR",
342
+ plt: "MG",
343
+ pol: "PL",
344
+ por: "BR",
345
+ prs: "AF",
346
+ quy: "PE",
347
+ ron: "RO",
348
+ run: "BI",
349
+ rus: "RU",
350
+ sag: "CF",
351
+ san: "IN",
352
+ sat: "IN",
353
+ scn: "IT",
354
+ shn: "MM",
355
+ sin: "LK",
356
+ slk: "SK",
357
+ slv: "SI",
358
+ smo: "WS",
359
+ sna: "ZW",
360
+ snd: "PK",
361
+ som: "SO",
362
+ sot: "LS",
363
+ spa: "ES",
364
+ srd: "IT",
365
+ srp: "RS",
366
+ ssw: "SZ",
367
+ sun: "ID",
368
+ swe: "SE",
369
+ swh: "TZ",
370
+ szl: "PL",
371
+ tam: "IN",
372
+ taq: "NE",
373
+ tat: "RU",
374
+ tel: "IN",
375
+ tgk: "TJ",
376
+ tha: "TH",
377
+ tir: "ER",
378
+ tpi: "PG",
379
+ tsn: "BW",
380
+ tso: "ZA",
381
+ tuk: "TM",
382
+ tum: "MW",
383
+ tur: "TR",
384
+ twi: "GH",
385
+ tyv: "RU",
386
+ uig: "CN",
387
+ ukr: "UA",
388
+ umb: "AO",
389
+ urd: "PK",
390
+ uzn: "UZ",
391
+ uzs: "UZ",
392
+ vec: "IT",
393
+ vie: "VN",
394
+ vmw: "MZ",
395
+ war: "PH",
396
+ wol: "SN",
397
+ wuu: "CN",
398
+ xho: "ZA",
399
+ ydd: "US",
400
+ yor: "NG",
401
+ yue: "HK",
402
+ zgh: "MA",
403
+ zsm: "MY",
404
+ zul: "ZA"
405
+ };
406
+ return LANGUAGE_TO_COUNTRY[code] ?? null;
407
+ }
408
+
409
+ // src/core/lang_code.ts
410
+ function getLangCode(code) {
411
+ return code.split("_")[0];
412
+ }
413
+ function stringToLangCode(str) {
414
+ if (LANG_CODES.includes(str)) {
415
+ return str;
416
+ } else {
417
+ return null;
418
+ }
419
+ }
420
+ function getEnglishLangName(code) {
421
+ const langNames = {
422
+ ace: "Acehnese",
423
+ acm: "Mesopotamian Arabic",
424
+ acq: "Ta\u02BDizzi-Adeni Arabic",
425
+ aeb: "Tunisian Arabic",
426
+ afr: "Afrikaans",
427
+ als: "Tosk Albanian",
428
+ amh: "Amharic",
429
+ apc: "North Levantine Arabic",
430
+ arb: "Modern Standard Arabic",
431
+ arg: "Aragonese",
432
+ ars: "Najdi Arabic",
433
+ ary: "Moroccan Arabic",
434
+ arz: "Egyptian Arabic",
435
+ asm: "Assamese",
436
+ ast: "Asturian",
437
+ awa: "Awadhi",
438
+ ayr: "Central Aymara",
439
+ azb: "South Azerbaijani",
440
+ azj: "North Azerbaijani",
441
+ bak: "Bashkir",
442
+ bam: "Bambara",
443
+ ban: "Balinese",
444
+ bel: "Belarusian",
445
+ bem: "Bemba",
446
+ ben: "Bengali",
447
+ bho: "Bhojpuri",
448
+ bjn: "Banjar",
449
+ bod: "Tibetan",
450
+ bos: "Bosnian",
451
+ brx: "Bodo",
452
+ bug: "Buginese",
453
+ bul: "Bulgarian",
454
+ cat: "Catalan",
455
+ ceb: "Cebuano",
456
+ ces: "Czech",
457
+ chv: "Chuvash",
458
+ cjk: "Chokwe",
459
+ ckb: "Central Kurdish",
460
+ cmn: "Mandarin Chinese",
461
+ crh: "Crimean Tatar",
462
+ cym: "Welsh",
463
+ dan: "Danish",
464
+ dar: "Dargwa",
465
+ deu: "German",
466
+ dgo: "Dogri",
467
+ dik: "Southwestern Dinka",
468
+ dyu: "Dyula",
469
+ dzo: "Dzongkha",
470
+ ekk: "Estonian",
471
+ ell: "Greek",
472
+ eng: "English",
473
+ epo: "Esperanto",
474
+ eus: "Basque",
475
+ ewe: "Ewe",
476
+ fao: "Faroese",
477
+ fij: "Fijian",
478
+ fil: "Filipino",
479
+ fin: "Finnish",
480
+ fon: "Fon",
481
+ fra: "French",
482
+ fur: "Friulian",
483
+ fuv: "Nigerian Fulfulde",
484
+ gaz: "West Central Oromo",
485
+ gla: "Scottish Gaelic",
486
+ gle: "Irish",
487
+ glg: "Galician",
488
+ gom: "Goan Konkani",
489
+ gug: "Paraguayan Guaran\xED",
490
+ guj: "Gujarati",
491
+ hat: "Haitian Creole",
492
+ hau: "Hausa",
493
+ heb: "Hebrew",
494
+ hin: "Hindi",
495
+ hne: "Chhattisgarhi",
496
+ hrv: "Croatian",
497
+ hun: "Hungarian",
498
+ hye: "Armenian",
499
+ ibo: "Igbo",
500
+ ilo: "Ilocano",
501
+ ind: "Indonesian",
502
+ isl: "Icelandic",
503
+ ita: "Italian",
504
+ jav: "Javanese",
505
+ jpn: "Japanese",
506
+ kaa: "Kara-Kalpak",
507
+ kab: "Kabyle",
508
+ kac: "Jingpho",
509
+ kam: "Kamba",
510
+ kan: "Kannada",
511
+ kas: "Kashmiri",
512
+ kat: "Georgian",
513
+ kaz: "Kazakh",
514
+ kbp: "Kabiy\xE8",
515
+ kea: "Kabuverdianu",
516
+ khk: "Halh Mongolian",
517
+ khm: "Khmer",
518
+ kik: "Kikuyu",
519
+ kin: "Kinyarwanda",
520
+ kir: "Kyrgyz",
521
+ kmb: "Kimbundu",
522
+ kmr: "Northern Kurdish",
523
+ knc: "Central Kanuri",
524
+ kor: "Korean",
525
+ ktu: "Kituba",
526
+ lao: "Lao",
527
+ lij: "Ligurian",
528
+ lim: "Limburgish",
529
+ lin: "Lingala",
530
+ lit: "Lithuanian",
531
+ lld: "Ladin",
532
+ lmo: "Lombard",
533
+ ltg: "Latgalian",
534
+ ltz: "Luxembourgish",
535
+ lua: "Luba-Kasai",
536
+ lug: "Ganda",
537
+ luo: "Luo",
538
+ lus: "Mizo",
539
+ lvs: "Latvian",
540
+ mag: "Magahi",
541
+ mai: "Maithili",
542
+ mal: "Malayalam",
543
+ mar: "Marathi",
544
+ mfe: "Morisyen",
545
+ mhr: "Eastern Mari",
546
+ min: "Minangkabau",
547
+ mkd: "Macedonian",
548
+ mlt: "Maltese",
549
+ mni: "Meitei",
550
+ mos: "Mossi",
551
+ mri: "M\u0101ori",
552
+ mya: "Burmese",
553
+ myv: "Erzya",
554
+ nld: "Dutch",
555
+ nno: "Norwegian Nynorsk",
556
+ nob: "Norwegian Bokm\xE5l",
557
+ npi: "Nepali",
558
+ nqo: "N'Ko",
559
+ nso: "Northern Sotho",
560
+ nus: "Nuer",
561
+ nya: "Nyanja",
562
+ oci: "Occitan",
563
+ ory: "Odia",
564
+ pag: "Pangasinan",
565
+ pan: "Punjabi",
566
+ pap: "Papiamento",
567
+ pbt: "Southern Pashto",
568
+ pes: "Western Persian",
569
+ plt: "Plateau Malagasy",
570
+ pol: "Polish",
571
+ por: "Portuguese",
572
+ prs: "Dari",
573
+ quy: "Ayacucho Quechua",
574
+ ron: "Romanian",
575
+ run: "Rundi",
576
+ rus: "Russian",
577
+ sag: "Sango",
578
+ san: "Sanskrit",
579
+ sat: "Santali",
580
+ scn: "Sicilian",
581
+ shn: "Shan",
582
+ sin: "Sinhala",
583
+ slk: "Slovak",
584
+ slv: "Slovenian",
585
+ smo: "Samoan",
586
+ sna: "Shona",
587
+ snd: "Sindhi",
588
+ som: "Somali",
589
+ sot: "Southern Sotho",
590
+ spa: "Spanish",
591
+ srd: "Sardinian",
592
+ srp: "Serbian",
593
+ ssw: "Swati",
594
+ sun: "Sundanese",
595
+ swe: "Swedish",
596
+ swh: "Swahili",
597
+ szl: "Silesian",
598
+ tam: "Tamil",
599
+ taq: "Tamasheq",
600
+ tat: "Tatar",
601
+ tel: "Telugu",
602
+ tgk: "Tajik",
603
+ tha: "Thai",
604
+ tir: "Tigrinya",
605
+ tpi: "Tok Pisin",
606
+ tsn: "Tswana",
607
+ tso: "Tsonga",
608
+ tuk: "Turkmen",
609
+ tum: "Tumbuka",
610
+ tur: "Turkish",
611
+ twi: "Twi",
612
+ tyv: "Tuvinian",
613
+ uig: "Uyghur",
614
+ ukr: "Ukrainian",
615
+ umb: "Umbundu",
616
+ urd: "Urdu",
617
+ uzn: "Northern Uzbek",
618
+ uzs: "Southern Uzbek",
619
+ vec: "Venetian",
620
+ vie: "Vietnamese",
621
+ vmw: "Makhuwa",
622
+ war: "Waray",
623
+ wol: "Wolof",
624
+ wuu: "Wu Chinese",
625
+ xho: "Xhosa",
626
+ ydd: "Eastern Yiddish",
627
+ yor: "Yoruba",
628
+ yue: "Cantonese",
629
+ zgh: "Standard Moroccan Tamazight",
630
+ zsm: "Standard Malay",
631
+ zul: "Zulu"
632
+ };
633
+ return langNames[code] ?? null;
634
+ }
635
+ function getLocaleLangName(code) {
636
+ const langNames = {
637
+ ace: "Bahsa Ac\xE8h",
638
+ acm: "\u0639\u0631\u0627\u0642\u064A",
639
+ acq: "\u0639\u062F\u0646\u064A",
640
+ aeb: "\u062A\u0648\u0646\u0633\u064A",
641
+ afr: "Afrikaans",
642
+ als: "Shqip",
643
+ amh: "\u12A0\u121B\u122D\u129B",
644
+ apc: "\u0634\u0627\u0645\u064A",
645
+ arb: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629",
646
+ arg: "Aragon\xE9s",
647
+ ars: "\u0646\u062C\u062F\u064A",
648
+ ary: "\u0627\u0644\u062F\u0627\u0631\u062C\u0629",
649
+ arz: "\u0645\u0635\u0631\u064A",
650
+ asm: "\u0985\u09B8\u09AE\u09C0\u09AF\u09BC\u09BE",
651
+ ast: "Asturianu",
652
+ awa: "\u0905\u0935\u0927\u0940",
653
+ ayr: "Aymar aru",
654
+ azb: "\u062A\u06C6\u0631\u06A9\u062C\u0647",
655
+ azj: "Az\u0259rbaycanca",
656
+ bak: "\u0411\u0430\u0448\u04A1\u043E\u0440\u0442\u0441\u0430",
657
+ bam: "Bamanankan",
658
+ ban: "Basa Bali",
659
+ bel: "\u0411\u0435\u043B\u0430\u0440\u0443\u0441\u043A\u0430\u044F",
660
+ bem: "Ichibemba",
661
+ ben: "\u09AC\u09BE\u0982\u09B2\u09BE",
662
+ bho: "\u092D\u094B\u091C\u092A\u0941\u0930\u0940",
663
+ bjn: "Bahasa Banjar",
664
+ bod: "\u0F56\u0F7C\u0F51\u0F0B\u0F66\u0F90\u0F51\u0F0D",
665
+ bos: "Bosanski",
666
+ brx: "\u092C\u0921\u093C\u094B",
667
+ bug: "Basa Ugi",
668
+ bul: "\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438",
669
+ cat: "Catal\xE0",
670
+ ceb: "Cebuano",
671
+ ces: "\u010Ce\u0161tina",
672
+ chv: "\u0427\u04D1\u0432\u0430\u0448\u043B\u0430",
673
+ cjk: "Tshilu\u0251\u0300",
674
+ ckb: "\u06A9\u0648\u0631\u062F\u06CC",
675
+ cmn: "\u666E\u901A\u8BDD",
676
+ crh: "Q\u0131r\u0131mtatarca",
677
+ cym: "Cymraeg",
678
+ dan: "Dansk",
679
+ dar: "\u0414\u0430\u0440\u0433\u0430\u043D",
680
+ deu: "Deutsch",
681
+ dgo: "\u0921\u094B\u0917\u0930\u0940",
682
+ dik: "Thu\u0254\u014Bj\xE4\u014B",
683
+ dyu: "Julakan",
684
+ dzo: "\u0F62\u0FAB\u0F7C\u0F44\u0F0B\u0F41",
685
+ ekk: "Eesti",
686
+ ell: "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",
687
+ eng: "English",
688
+ epo: "Esperanto",
689
+ eus: "Euskara",
690
+ ewe: "E\u028Begbe",
691
+ fao: "F\xF8royskt",
692
+ fij: "Vosa Vakaviti",
693
+ fil: "Filipino",
694
+ fin: "Suomi",
695
+ fon: "F\u0254\u0300ngb\xE8",
696
+ fra: "Fran\xE7ais",
697
+ fur: "Furlan",
698
+ fuv: "Fulfulde",
699
+ gaz: "Afaan Oromoo",
700
+ gla: "G\xE0idhlig",
701
+ gle: "Gaeilge",
702
+ glg: "Galego",
703
+ gom: "\u0915\u094B\u0902\u0915\u0923\u0940",
704
+ gug: "Ava\xF1e'\u1EBD",
705
+ guj: "\u0A97\u0AC1\u0A9C\u0AB0\u0ABE\u0AA4\u0AC0",
706
+ hat: "Krey\xF2l ayisyen",
707
+ hau: "Hausa",
708
+ heb: "\u05E2\u05D1\u05E8\u05D9\u05EA",
709
+ hin: "\u0939\u093F\u0928\u094D\u0926\u0940",
710
+ hne: "\u091B\u0924\u094D\u0924\u0940\u0938\u0917\u0922\u093C\u0940",
711
+ hrv: "Hrvatski",
712
+ hun: "Magyar",
713
+ hye: "\u0540\u0561\u0575\u0565\u0580\u0565\u0576",
714
+ ibo: "Igbo",
715
+ ilo: "Ilokano",
716
+ ind: "Bahasa Indonesia",
717
+ isl: "\xCDslenska",
718
+ ita: "Italiano",
719
+ jav: "Basa Jawa",
720
+ jpn: "\u65E5\u672C\u8A9E",
721
+ kaa: "Qaraqalpaqsha",
722
+ kab: "Taqbaylit",
723
+ kac: "Jingpho",
724
+ kam: "Kikamba",
725
+ kan: "\u0C95\u0CA8\u0CCD\u0CA8\u0CA1",
726
+ kas: "\u06A9\u0672\u0634\u064F\u0631",
727
+ kat: "\u10E5\u10D0\u10E0\u10D7\u10E3\u10DA\u10D8",
728
+ kaz: "\u049A\u0430\u0437\u0430\u049B\u0448\u0430",
729
+ kbp: "Kab\u0269y\u025B",
730
+ kea: "Kabuverdianu",
731
+ khk: "\u041C\u043E\u043D\u0433\u043E\u043B",
732
+ khm: "\u1797\u17B6\u179F\u17B6\u1781\u17D2\u1798\u17C2\u179A",
733
+ kik: "G\u0129k\u0169y\u0169",
734
+ kin: "Ikinyarwanda",
735
+ kir: "\u041A\u044B\u0440\u0433\u044B\u0437\u0447\u0430",
736
+ kmb: "Kimbundu",
737
+ kmr: "Kurd\xEE",
738
+ knc: "K\u0101n\u016Bri",
739
+ kor: "\uD55C\uAD6D\uC5B4",
740
+ ktu: "Kituba",
741
+ lao: "\u0E9E\u0EB2\u0EAA\u0EB2\u0EA5\u0EB2\u0EA7",
742
+ lij: "Ligure",
743
+ lim: "Limburgs",
744
+ lin: "Ling\xE1la",
745
+ lit: "Lietuvi\u0173",
746
+ lld: "Ladin",
747
+ lmo: "Lumbaart",
748
+ ltg: "Latgal\u012B\u0161u",
749
+ ltz: "L\xEBtzebuergesch",
750
+ lua: "Tshiluba",
751
+ lug: "Luganda",
752
+ luo: "Dholuo",
753
+ lus: "Mizo \u1E6Dawng",
754
+ lvs: "Latvie\u0161u",
755
+ mag: "\u092E\u0917\u0939\u0940",
756
+ mai: "\u092E\u0948\u0925\u093F\u0932\u0940",
757
+ mal: "\u0D2E\u0D32\u0D2F\u0D3E\u0D33\u0D02",
758
+ mar: "\u092E\u0930\u093E\u0920\u0940",
759
+ mfe: "Morisyen",
760
+ mhr: "\u041C\u0430\u0440\u0438\u0439 \u0439\u044B\u043B\u043C\u0435",
761
+ min: "Baso Minangkabau",
762
+ mkd: "\u041C\u0430\u043A\u0435\u0434\u043E\u043D\u0441\u043A\u0438",
763
+ mlt: "Malti",
764
+ mni: "\u09AE\u09C8\u09A4\u09C8\u09B2\u09CB\u09A8\u09CD",
765
+ mos: "Moor\xE9",
766
+ mri: "Te Reo M\u0101ori",
767
+ mya: "\u1019\u103C\u1014\u103A\u1019\u102C\u1018\u102C\u101E\u102C",
768
+ myv: "\u042D\u0440\u0437\u044F\u043D\u044C",
769
+ nld: "Nederlands",
770
+ nno: "Nynorsk",
771
+ nob: "Bokm\xE5l",
772
+ npi: "\u0928\u0947\u092A\u093E\u0932\u0940",
773
+ nqo: "\u07D2\u07DE\u07CF",
774
+ nso: "Sesotho sa Leboa",
775
+ nus: "Thok Nath",
776
+ nya: "Chichewa",
777
+ oci: "Occitan",
778
+ ory: "\u0B13\u0B21\u0B3C\u0B3F\u0B06",
779
+ pag: "Pangasinan",
780
+ pan: "\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40",
781
+ pap: "Papiamentu",
782
+ pbt: "\u067E\u069A\u062A\u0648",
783
+ pes: "\u0641\u0627\u0631\u0633\u06CC",
784
+ plt: "Malagasy",
785
+ pol: "Polski",
786
+ por: "Portugu\xEAs",
787
+ prs: "\u062F\u0631\u06CC",
788
+ quy: "Chaw Qusqu Qichwa",
789
+ ron: "Rom\xE2n\u0103",
790
+ run: "Ikirundi",
791
+ rus: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
792
+ sag: "S\xE4ng\xF6",
793
+ san: "\u0938\u0902\u0938\u094D\u0915\u0943\u0924\u092E\u094D",
794
+ sat: "\u1C65\u1C5F\u1C71\u1C5B\u1C5F\u1C72\u1C64",
795
+ scn: "Sicilianu",
796
+ shn: "\u101C\u102D\u1075\u103A\u1088\u1010\u1086\u1038",
797
+ sin: "\u0DC3\u0DD2\u0D82\u0DC4\u0DBD",
798
+ slk: "Sloven\u010Dina",
799
+ slv: "Sloven\u0161\u010Dina",
800
+ smo: "Gagana Samoa",
801
+ sna: "ChiShona",
802
+ snd: "\u0633\u0646\u068C\u064A",
803
+ som: "Soomaali",
804
+ sot: "Sesotho",
805
+ spa: "Espa\xF1ol",
806
+ srd: "Sardu",
807
+ srp: "\u0421\u0440\u043F\u0441\u043A\u0438",
808
+ ssw: "SiSwati",
809
+ sun: "Basa Sunda",
810
+ swe: "Svenska",
811
+ swh: "Kiswahili",
812
+ szl: "\u015Al\u014Dnsk\u014F",
813
+ tam: "\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD",
814
+ taq: "Tamasheq",
815
+ tat: "\u0422\u0430\u0442\u0430\u0440\u0447\u0430",
816
+ tel: "\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41",
817
+ tgk: "\u0422\u043E\u04B7\u0438\u043A\u04E3",
818
+ tha: "\u0E20\u0E32\u0E29\u0E32\u0E44\u0E17\u0E22",
819
+ tir: "\u1275\u130D\u122D\u129B",
820
+ tpi: "Tok Pisin",
821
+ tsn: "Setswana",
822
+ tso: "Xitsonga",
823
+ tuk: "T\xFCrkmen\xE7e",
824
+ tum: "chiTumbuka",
825
+ tur: "T\xFCrk\xE7e",
826
+ twi: "Twi",
827
+ tyv: "\u0422\u044B\u0432\u0430 \u0434\u044B\u043B",
828
+ uig: "\u0626\u06C7\u064A\u063A\u06C7\u0631\u0686\u06D5",
829
+ ukr: "\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430",
830
+ umb: "Umbundu",
831
+ urd: "\u0627\u0631\u062F\u0648",
832
+ uzn: "O\u02BBzbekcha",
833
+ uzs: "\u0627\u0648\u0632\u0628\u06CC\u06A9",
834
+ vec: "V\xE8neto",
835
+ vie: "Ti\u1EBFng Vi\u1EC7t",
836
+ vmw: "Emakhuwa",
837
+ war: "Winaray",
838
+ wol: "Wolof",
839
+ wuu: "\u5434\u8BED",
840
+ xho: "IsiXhosa",
841
+ ydd: "\u05D9\u05D9\u05B4\u05D3\u05D9\u05E9",
842
+ yor: "Yor\xF9b\xE1",
843
+ yue: "\u7CB5\u8A9E",
844
+ zgh: "\u2D5C\u2D30\u2D4E\u2D30\u2D63\u2D49\u2D56\u2D5C",
845
+ zsm: "Bahasa Melayu",
846
+ zul: "IsiZulu"
847
+ };
848
+ return langNames[code] ?? null;
849
+ }
850
+
851
+ // src/core/script_code.ts
852
+ function getScriptCode(code) {
853
+ return code.split("_")[1];
854
+ }
855
+ function stringToLangScriptCode(str) {
856
+ if (LANG_SCRIPT_CODES2.includes(str)) {
857
+ return str;
858
+ } else {
859
+ return null;
860
+ }
861
+ }
862
+ function stringToScriptCode(str) {
863
+ if (SCRIPT_CODES.includes(str)) {
864
+ return str;
865
+ } else {
866
+ return null;
867
+ }
868
+ }
869
+ var SCRIPT_DIRECTION = {
870
+ // RTL scripts
871
+ Arab: "rtl",
872
+ Hebr: "rtl",
873
+ Nkoo: "rtl",
874
+ Tfng: "rtl",
875
+ // LTR scripts
876
+ Latn: "ltr",
877
+ Cyrl: "ltr",
878
+ Deva: "ltr",
879
+ Beng: "ltr",
880
+ Hans: "ltr",
881
+ Hant: "ltr",
882
+ Ethi: "ltr",
883
+ Grek: "ltr",
884
+ Gujr: "ltr",
885
+ Armn: "ltr",
886
+ Jpan: "ltr",
887
+ Knda: "ltr",
888
+ Geor: "ltr",
889
+ Khmr: "ltr",
890
+ Hang: "ltr",
891
+ Laoo: "ltr",
892
+ Mlym: "ltr",
893
+ Mtei: "ltr",
894
+ Mymr: "ltr",
895
+ Orya: "ltr",
896
+ Guru: "ltr",
897
+ Olck: "ltr",
898
+ Sinh: "ltr",
899
+ Taml: "ltr",
900
+ Telu: "ltr",
901
+ Thai: "ltr",
902
+ Tibt: "ltr"
903
+ };
904
+ function getScriptDirection(script) {
905
+ return SCRIPT_DIRECTION[script];
906
+ }
907
+ function getLangScriptDirection(langScript) {
908
+ const script = getScriptCode(langScript);
909
+ return getScriptDirection(script);
910
+ }
911
+
912
+ // src/core/lang_script_obj.ts
913
+ var LangScriptObj = class {
914
+ /**
915
+ * The inner wrapped {@link LangScriptCode}
916
+ */
917
+ code;
918
+ constructor(code) {
919
+ this.code = code;
920
+ }
921
+ /**
922
+ * A helper function for getting the {@link LangCode} for the wrapped {@link LangScriptCode}
923
+ * @returns The {@link LangCode} for the wrapped {@link LangScriptCode}
924
+ */
925
+ getLangCode() {
926
+ return getLangCode(this.code);
927
+ }
928
+ /**
929
+ * A helper function for getting the {@link ScriptCode} for the wrapped {@link LangScriptCode}
930
+ * @returns The {@link ScriptCode} for the wrapped {@link LangScriptCode}
931
+ */
932
+ getScriptCode() {
933
+ return getScriptCode(this.code);
934
+ }
935
+ /**
936
+ * A helper function for getting the locale name for the wrapped {@link LangScriptCode}
937
+ * @returns The {@link LangCode} for the wrapped {@link LangScriptCode}
938
+ */
939
+ getName() {
940
+ return getLocaleLangName(this.getLangCode());
941
+ }
942
+ /**
943
+ * A helper function for getting the english name for the wrapped {@link LangScriptCode}
944
+ * @returns The {@link LangCode} for the wrapped {@link LangScriptCode}
945
+ */
946
+ getEnglishName() {
947
+ return getEnglishLangName(this.getLangCode());
948
+ }
949
+ /**
950
+ * A helper function for getting the {@link CountryCode} most associated with this {@link LangScriptCode}, or `null` if there is none
951
+ * @returns the {@link CountryCode} most associated with this `LangScriptCode, or `null` if there is none
952
+ */
953
+ getCountry() {
954
+ return getCountryCode(this.getLangCode());
955
+ }
956
+ /**
957
+ * A helper function that invokes the {@link CountryFlag} component, with the country code most associated with this {@link LangScriptCode}, or null if there is none
958
+ * @returns the {@link CountryFlag} component, with the country code most associated with this {@link LangScriptCode}, or null if there is none
959
+ */
960
+ getCountryFlag() {
961
+ let country = this.getCountry();
962
+ return country ? CountryFlag({ country }) : null;
963
+ }
964
+ /**
965
+ * A helper function for getting the {@link ScriptDirection} for wrapped {@link LangScriptCode}
966
+ * @returns the {@link ScriptDirection} for wrapped {@link LangScriptCode}
967
+ */
968
+ getScriptDirection() {
969
+ const script = this.getScriptCode();
970
+ return getScriptDirection(script);
971
+ }
972
+ };
973
+
974
+ // src/core/index.ts
975
+ var LANG_SCRIPT_CODES2 = [
976
+ "ace_Arab",
977
+ "ace_Latn",
978
+ "acm_Arab",
979
+ "acq_Arab",
980
+ "aeb_Arab",
981
+ "afr_Latn",
982
+ "als_Latn",
983
+ "amh_Ethi",
984
+ "apc_Arab",
985
+ "arb_Arab",
986
+ "arb_Latn",
987
+ "arg_Latn",
988
+ "ars_Arab",
989
+ "ary_Arab",
990
+ "arz_Arab",
991
+ "asm_Beng",
992
+ "ast_Latn",
993
+ "awa_Deva",
994
+ "ayr_Latn",
995
+ "azb_Arab",
996
+ "azj_Latn",
997
+ "bak_Cyrl",
998
+ "bam_Latn",
999
+ "ban_Latn",
1000
+ "bel_Cyrl",
1001
+ "bem_Latn",
1002
+ "ben_Beng",
1003
+ "bho_Deva",
1004
+ "bjn_Arab",
1005
+ "bjn_Latn",
1006
+ "bod_Tibt",
1007
+ "bos_Latn",
1008
+ "brx_Deva",
1009
+ "bug_Latn",
1010
+ "bul_Cyrl",
1011
+ "cat_Latn",
1012
+ "ceb_Latn",
1013
+ "ces_Latn",
1014
+ "chv_Cyrl",
1015
+ "cjk_Latn",
1016
+ "ckb_Arab",
1017
+ "cmn_Hans",
1018
+ "cmn_Hant",
1019
+ "crh_Latn",
1020
+ "cym_Latn",
1021
+ "dan_Latn",
1022
+ "dar_Cyrl",
1023
+ "deu_Latn",
1024
+ "dgo_Deva",
1025
+ "dik_Latn",
1026
+ "dyu_Latn",
1027
+ "dzo_Tibt",
1028
+ "ekk_Latn",
1029
+ "ell_Grek",
1030
+ "eng_Latn",
1031
+ "epo_Latn",
1032
+ "eus_Latn",
1033
+ "ewe_Latn",
1034
+ "fao_Latn",
1035
+ "fij_Latn",
1036
+ "fil_Latn",
1037
+ "fin_Latn",
1038
+ "fon_Latn",
1039
+ "fra_Latn",
1040
+ "fur_Latn",
1041
+ "fuv_Latn",
1042
+ "gaz_Latn",
1043
+ "gla_Latn",
1044
+ "gle_Latn",
1045
+ "glg_Latn",
1046
+ "gom_Deva",
1047
+ "gug_Latn",
1048
+ "guj_Gujr",
1049
+ "hat_Latn",
1050
+ "hau_Latn",
1051
+ "heb_Hebr",
1052
+ "hin_Deva",
1053
+ "hne_Deva",
1054
+ "hrv_Latn",
1055
+ "hun_Latn",
1056
+ "hye_Armn",
1057
+ "ibo_Latn",
1058
+ "ilo_Latn",
1059
+ "ind_Latn",
1060
+ "isl_Latn",
1061
+ "ita_Latn",
1062
+ "jav_Latn",
1063
+ "jpn_Jpan",
1064
+ "kaa_Latn",
1065
+ "kab_Latn",
1066
+ "kac_Latn",
1067
+ "kam_Latn",
1068
+ "kan_Knda",
1069
+ "kas_Arab",
1070
+ "kas_Deva",
1071
+ "kat_Geor",
1072
+ "kaz_Cyrl",
1073
+ "kbp_Latn",
1074
+ "kea_Latn",
1075
+ "khk_Cyrl",
1076
+ "khm_Khmr",
1077
+ "kik_Latn",
1078
+ "kin_Latn",
1079
+ "kir_Cyrl",
1080
+ "kmb_Latn",
1081
+ "kmr_Latn",
1082
+ "knc_Arab",
1083
+ "knc_Latn",
1084
+ "kor_Hang",
1085
+ "ktu_Latn",
1086
+ "lao_Laoo",
1087
+ "lij_Latn",
1088
+ "lim_Latn",
1089
+ "lin_Latn",
1090
+ "lit_Latn",
1091
+ "lld_Latn",
1092
+ "lmo_Latn",
1093
+ "ltg_Latn",
1094
+ "ltz_Latn",
1095
+ "lua_Latn",
1096
+ "lug_Latn",
1097
+ "luo_Latn",
1098
+ "lus_Latn",
1099
+ "lvs_Latn",
1100
+ "mag_Deva",
1101
+ "mai_Deva",
1102
+ "mal_Mlym",
1103
+ "mar_Deva",
1104
+ "mfe_Latn",
1105
+ "mhr_Cyrl",
1106
+ "min_Arab",
1107
+ "min_Latn",
1108
+ "mkd_Cyrl",
1109
+ "mlt_Latn",
1110
+ "mni_Beng",
1111
+ "mni_Mtei",
1112
+ "mos_Latn",
1113
+ "mri_Latn",
1114
+ "mya_Mymr",
1115
+ "myv_Cyrl",
1116
+ "nld_Latn",
1117
+ "nno_Latn",
1118
+ "nob_Latn",
1119
+ "npi_Deva",
1120
+ "nqo_Nkoo",
1121
+ "nso_Latn",
1122
+ "nus_Latn",
1123
+ "nya_Latn",
1124
+ "oci_Latn",
1125
+ "ory_Orya",
1126
+ "pag_Latn",
1127
+ "pan_Guru",
1128
+ "pap_Latn",
1129
+ "pbt_Arab",
1130
+ "pes_Arab",
1131
+ "plt_Latn",
1132
+ "pol_Latn",
1133
+ "por_Latn",
1134
+ "prs_Arab",
1135
+ "quy_Latn",
1136
+ "ron_Latn",
1137
+ "run_Latn",
1138
+ "rus_Cyrl",
1139
+ "sag_Latn",
1140
+ "san_Deva",
1141
+ "sat_Olck",
1142
+ "scn_Latn",
1143
+ "shn_Mymr",
1144
+ "sin_Sinh",
1145
+ "slk_Latn",
1146
+ "slv_Latn",
1147
+ "smo_Latn",
1148
+ "sna_Latn",
1149
+ "snd_Arab",
1150
+ "snd_Deva",
1151
+ "som_Latn",
1152
+ "sot_Latn",
1153
+ "spa_Latn",
1154
+ "srd_Latn",
1155
+ "srp_Cyrl",
1156
+ "ssw_Latn",
1157
+ "sun_Latn",
1158
+ "swe_Latn",
1159
+ "swh_Latn",
1160
+ "szl_Latn",
1161
+ "tam_Taml",
1162
+ "taq_Latn",
1163
+ "taq_Tfng",
1164
+ "tat_Cyrl",
1165
+ "tel_Telu",
1166
+ "tgk_Cyrl",
1167
+ "tha_Thai",
1168
+ "tir_Ethi",
1169
+ "tpi_Latn",
1170
+ "tsn_Latn",
1171
+ "tso_Latn",
1172
+ "tuk_Latn",
1173
+ "tum_Latn",
1174
+ "tur_Latn",
1175
+ "twi_Latn",
1176
+ "tyv_Cyrl",
1177
+ "uig_Arab",
1178
+ "ukr_Cyrl",
1179
+ "umb_Latn",
1180
+ "urd_Arab",
1181
+ "uzn_Latn",
1182
+ "uzs_Arab",
1183
+ "vec_Latn",
1184
+ "vie_Latn",
1185
+ "vmw_Latn",
1186
+ "war_Latn",
1187
+ "wol_Latn",
1188
+ "wuu_Hans",
1189
+ "xho_Latn",
1190
+ "ydd_Hebr",
1191
+ "yor_Latn",
1192
+ "yue_Hant",
1193
+ "zgh_Tfng",
1194
+ "zsm_Latn",
1195
+ "zul_Latn"
1196
+ ];
1197
+ var LANG_CODES = [
1198
+ ...new Set(LANG_SCRIPT_CODES2.map((code) => code.split("_")[0]))
1199
+ ];
1200
+ var SCRIPT_CODES = [
1201
+ ...new Set(LANG_SCRIPT_CODES2.map((code) => code.split("_")[1]))
1202
+ ];
1203
+ function formatLangScriptCode(lang, script) {
1204
+ return `${lang}_${script}`;
1205
+ }
1206
+
1207
+ // src/components/I18nProvider.tsx
1208
+ import { createContext, useContext, useEffect, useReducer, useState } from "react";
1209
+ import { jsx as jsx2 } from "react/jsx-runtime";
1210
+ var I18nContext = createContext(null);
1211
+ function I18nProvider({
1212
+ children,
1213
+ defaultLang = "eng_Latn",
1214
+ db: dbInit
1215
+ }) {
1216
+ const [localeState, setLocaleState] = useState(() => {
1217
+ setCurrentLocalRaw(defaultLang);
1218
+ return defaultLang;
1219
+ });
1220
+ const [databaseState, setDatabaseState] = useState(() => {
1221
+ setI18nDatabaseRaw(dbInit);
1222
+ return dbInit;
1223
+ });
1224
+ const setDatabase = (db) => {
1225
+ setI18nDatabaseRaw(db);
1226
+ setDatabaseState(db);
1227
+ };
1228
+ const setLocale = (locale) => {
1229
+ setCurrentLocalRaw(locale);
1230
+ setLocaleState(locale);
1231
+ };
1232
+ const [, forceUpdate] = useReducer((x) => x + 1, 0);
1233
+ useEffect(() => {
1234
+ const listener = () => forceUpdate();
1235
+ databaseState.addOnChangeListener(listener);
1236
+ return () => {
1237
+ databaseState.removeOnChangeListener(listener);
1238
+ };
1239
+ }, [databaseState]);
1240
+ useEffect(() => {
1241
+ setDatabase(dbInit);
1242
+ }, [dbInit]);
1243
+ const getLocales = () => databaseState.langs();
1244
+ const getLocaleObj = () => new LangScriptObj(localeState);
1245
+ return /* @__PURE__ */ jsx2(I18nContext.Provider, { value: { locale: localeState, getLocaleObj, database: databaseState, setLocale, setDatabase, getLocales }, children });
1246
+ }
1247
+ function useI18n() {
1248
+ const ctx = useContext(I18nContext);
1249
+ if (!ctx) throw new Error("useLanguage must be used inside of the LanguageContext or LanguageProvider");
1250
+ return ctx;
1251
+ }
1252
+
1253
+ // src/components/I18nFileProvider.tsx
1254
+ import { jsx as jsx3 } from "react/jsx-runtime";
1255
+ function I18nFileProvider({
1256
+ path,
1257
+ children,
1258
+ defaultLang = "eng_Latn"
1259
+ }) {
1260
+ const [db, setDb] = useState2(I18nDatabaseDefault);
1261
+ useEffect2(() => {
1262
+ let canceled = false;
1263
+ SimpleI18nDb.load(path).then((loaded) => {
1264
+ if (!canceled) {
1265
+ setDb(loaded);
1266
+ }
1267
+ });
1268
+ return () => {
1269
+ canceled = true;
1270
+ };
1271
+ }, [path]);
1272
+ return /* @__PURE__ */ jsx3(
1273
+ I18nProvider,
1274
+ {
1275
+ defaultLang,
1276
+ db,
1277
+ children
1278
+ }
1279
+ );
1280
+ }
1281
+
1282
+ // src/components/I18nMultiFileProvider.tsx
1283
+ import { useEffect as useEffect3, useState as useState3 } from "react";
1284
+ import { jsx as jsx4 } from "react/jsx-runtime";
1285
+ function I18nMultiFileProvider({
1286
+ path,
1287
+ children,
1288
+ defaultLang = "eng_Latn"
1289
+ }) {
1290
+ const [db, setDb] = useState3(I18nDatabaseDefault);
1291
+ useEffect3(() => {
1292
+ let canceled = false;
1293
+ CachedMultiFileI18nDb.load(path).then((loaded) => {
1294
+ if (!canceled) {
1295
+ setDb(loaded);
1296
+ }
1297
+ });
1298
+ return () => {
1299
+ canceled = true;
1300
+ };
1301
+ }, [path]);
1302
+ return /* @__PURE__ */ jsx4(
1303
+ I18nProvider,
1304
+ {
1305
+ defaultLang,
1306
+ db,
1307
+ children
1308
+ }
1309
+ );
1310
+ }
1311
+
1312
+ // src/index.ts
1313
+ var index_default = __t;
1314
+ export {
1315
+ CachedMultiFileI18nDb,
1316
+ CountryFlag,
1317
+ FOLDER_LANGUAGE_MANIFEST_NAME,
1318
+ I18nDatabaseDefault,
1319
+ I18nFileProvider,
1320
+ I18nMultiFileProvider,
1321
+ I18nProvider,
1322
+ LANG_CODES,
1323
+ LANG_SCRIPT_CODES2 as LANG_SCRIPT_CODES,
1324
+ LangScriptObj,
1325
+ SCRIPT_CODES,
1326
+ SimpleI18nDb,
1327
+ __t,
1328
+ __tv,
1329
+ index_default as default,
1330
+ formatLangScriptCode,
1331
+ getCountryCode,
1332
+ getCurrentLocalRaw,
1333
+ getEnglishLangName,
1334
+ getI18nDatabaseRaw,
1335
+ getLangCode,
1336
+ getLangScriptDirection,
1337
+ getLocaleLangName,
1338
+ getScriptCode,
1339
+ getScriptDirection,
1340
+ setCurrentLocalRaw,
1341
+ setI18nDatabaseRaw,
1342
+ stringToLangCode,
1343
+ stringToLangScriptCode,
1344
+ stringToScriptCode,
1345
+ useI18n
1346
+ };