@gtcx/i18n 0.1.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,355 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ CulturalContext: () => CulturalContext,
24
+ LANGUAGE_FAMILIES: () => LANGUAGE_FAMILIES,
25
+ SUPPORTED_LANGUAGES: () => SUPPORTED_LANGUAGES,
26
+ createTranslator: () => createTranslator,
27
+ formatCurrency: () => formatCurrency,
28
+ formatI18nDate: () => formatI18nDate,
29
+ formatNumber: () => formatNumber,
30
+ formatRelativeTime: () => formatRelativeTime,
31
+ getCulturalContext: () => getCulturalContext,
32
+ getDirection: () => getDirection,
33
+ isRTL: () => isRTL
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/cultural-context.ts
38
+ var CULTURAL_CONTEXTS = {
39
+ ghana: {
40
+ countryCode: "GH",
41
+ culturalValues: [
42
+ "community_harmony",
43
+ "respect_for_elders",
44
+ "traditional_authority",
45
+ "extended_family",
46
+ "hospitality"
47
+ ],
48
+ communicationStyle: "formal",
49
+ decisionMaking: "elder-consultation",
50
+ conflictResolution: "mediation_through_elders",
51
+ traditionalKnowledge: [
52
+ "chieftaincy_systems",
53
+ "communal_land_ownership",
54
+ "traditional_mining_practices"
55
+ ],
56
+ localExamples: ["galamsey_formalization", "community_mining_schemes", "chief_led_development"],
57
+ taboos: ["disrespect_to_chiefs", "public_confrontation"],
58
+ celebrations: ["homowo", "akwasidae", "damba"],
59
+ communityStructure: "chief_elder_family_hierarchy"
60
+ },
61
+ kenya: {
62
+ countryCode: "KE",
63
+ culturalValues: [
64
+ "harambee_collective_effort",
65
+ "family_unity",
66
+ "community_cooperation",
67
+ "environmental_stewardship"
68
+ ],
69
+ communicationStyle: "community-oriented",
70
+ decisionMaking: "consensus",
71
+ conflictResolution: "community_mediation",
72
+ traditionalKnowledge: [
73
+ "pastoral_land_management",
74
+ "community_savings_groups",
75
+ "age_set_systems"
76
+ ],
77
+ localExamples: ["chama_savings_groups", "community_conservancies", "table_banking"],
78
+ taboos: ["individualism_over_community", "elder_disrespect"],
79
+ celebrations: ["jamhuri_day", "madaraka_day"],
80
+ communityStructure: "clan_age_set_community"
81
+ },
82
+ peru: {
83
+ countryCode: "PE",
84
+ culturalValues: [
85
+ "ayni_reciprocity",
86
+ "pachamama_earth_respect",
87
+ "community_tradition",
88
+ "indigenous_rights"
89
+ ],
90
+ communicationStyle: "hierarchical",
91
+ decisionMaking: "community",
92
+ conflictResolution: "community_assembly",
93
+ traditionalKnowledge: [
94
+ "andean_mining_traditions",
95
+ "ayllu_community_systems",
96
+ "water_management"
97
+ ],
98
+ localExamples: [
99
+ "artisanal_mining_cooperatives",
100
+ "community_mining_titles",
101
+ "indigenous_consultation"
102
+ ],
103
+ taboos: ["pachamama_disrespect", "community_exclusion"],
104
+ celebrations: ["inti_raymi", "pachamama_day"],
105
+ communityStructure: "ayllu_community_assembly"
106
+ },
107
+ colombia: {
108
+ countryCode: "CO",
109
+ culturalValues: [
110
+ "cultural_diversity",
111
+ "community_resilience",
112
+ "environmental_protection",
113
+ "social_responsibility"
114
+ ],
115
+ communicationStyle: "formal",
116
+ decisionMaking: "consensus",
117
+ conflictResolution: "dialogue_and_mediation",
118
+ traditionalKnowledge: [
119
+ "indigenous_mining_rights",
120
+ "afro_colombian_traditions",
121
+ "community_councils"
122
+ ],
123
+ localExamples: [
124
+ "ethnic_mining_zones",
125
+ "community_mining_formalization",
126
+ "environmental_licensing"
127
+ ],
128
+ taboos: ["cultural_appropriation", "territorial_disrespect"],
129
+ celebrations: ["carnival_de_barranquilla", "dia_de_la_raza"],
130
+ communityStructure: "community_council_ethnic_authority"
131
+ },
132
+ tanzania: {
133
+ countryCode: "TZ",
134
+ culturalValues: ["ujamaa_familyhood", "unity_diversity", "self_reliance", "community_welfare"],
135
+ communicationStyle: "community-oriented",
136
+ decisionMaking: "consensus",
137
+ conflictResolution: "village_assembly",
138
+ traditionalKnowledge: [
139
+ "village_land_governance",
140
+ "cooperative_traditions",
141
+ "traditional_mining"
142
+ ],
143
+ localExamples: [
144
+ "village_mining_committees",
145
+ "cooperative_mining",
146
+ "community_development_agreements"
147
+ ],
148
+ taboos: ["community_division", "elder_disrespect"],
149
+ celebrations: ["uhuru_day", "union_day", "nyerere_day"],
150
+ communityStructure: "village_assembly_elder_council"
151
+ },
152
+ // Global hubs - more formal, less community-oriented
153
+ switzerland: {
154
+ countryCode: "CH",
155
+ culturalValues: ["precision", "neutrality", "quality", "privacy"],
156
+ communicationStyle: "formal",
157
+ decisionMaking: "individual",
158
+ conflictResolution: "legal_mediation",
159
+ traditionalKnowledge: [],
160
+ localExamples: ["swiss_refinery_standards", "responsible_gold_guidance"],
161
+ taboos: [],
162
+ celebrations: [],
163
+ communityStructure: "individual_institutional"
164
+ },
165
+ singapore: {
166
+ countryCode: "SG",
167
+ culturalValues: ["efficiency", "meritocracy", "rule_of_law", "multicultural_harmony"],
168
+ communicationStyle: "formal",
169
+ decisionMaking: "individual",
170
+ conflictResolution: "institutional",
171
+ traditionalKnowledge: [],
172
+ localExamples: ["commodity_trading_hub", "financial_center_standards"],
173
+ taboos: [],
174
+ celebrations: [],
175
+ communityStructure: "institutional_individual"
176
+ }
177
+ };
178
+ function getCulturalContext(countryCode) {
179
+ const normalized = countryCode.toLowerCase();
180
+ return CULTURAL_CONTEXTS[normalized] || null;
181
+ }
182
+ var CulturalContext = class {
183
+ config;
184
+ constructor(countryCode) {
185
+ const config = getCulturalContext(countryCode);
186
+ if (!config) {
187
+ throw new Error(`No cultural context found for country: ${countryCode}`);
188
+ }
189
+ this.config = config;
190
+ }
191
+ /**
192
+ * Check if formal communication style is expected
193
+ */
194
+ get usesFormalAddress() {
195
+ return this.config.communicationStyle === "formal" || this.config.communicationStyle === "hierarchical";
196
+ }
197
+ /**
198
+ * Check if community consultation is expected for decisions
199
+ */
200
+ get requiresCommunityConsultation() {
201
+ return this.config.decisionMaking === "consensus" || this.config.decisionMaking === "elder-consultation" || this.config.decisionMaking === "community";
202
+ }
203
+ /**
204
+ * Get local examples for explanations
205
+ */
206
+ getLocalExamples() {
207
+ return this.config.localExamples;
208
+ }
209
+ /**
210
+ * Check if a topic should be avoided
211
+ */
212
+ isTaboo(topic) {
213
+ return this.config.taboos.some((t) => topic.toLowerCase().includes(t.toLowerCase()));
214
+ }
215
+ /**
216
+ * Get traditional knowledge integration points
217
+ */
218
+ getTraditionalKnowledge() {
219
+ return this.config.traditionalKnowledge;
220
+ }
221
+ /**
222
+ * Get raw config
223
+ */
224
+ toJSON() {
225
+ return { ...this.config };
226
+ }
227
+ };
228
+
229
+ // src/translator.ts
230
+ function createTranslator(options) {
231
+ const { locale, fallbackLocale = "en", catalog } = options;
232
+ const chain = [locale];
233
+ const baseLang = locale.split("-")[0];
234
+ if (baseLang !== locale) chain.push(baseLang);
235
+ if (!chain.includes(fallbackLocale)) chain.push(fallbackLocale);
236
+ function resolve(key) {
237
+ for (const lang of chain) {
238
+ const map = catalog[lang];
239
+ if (!map) continue;
240
+ const value = map[key];
241
+ if (typeof value === "string") return value;
242
+ }
243
+ return void 0;
244
+ }
245
+ function t(key, opts) {
246
+ if (opts?.count !== void 0) {
247
+ const plural = opts.count === 0 ? resolve(`${key}_zero`) ?? resolve(`${key}_other`) : opts.count === 1 ? resolve(`${key}_one`) ?? resolve(key) : resolve(`${key}_other`) ?? resolve(key);
248
+ if (plural) return interpolate(plural, opts.values);
249
+ }
250
+ const raw = resolve(key);
251
+ if (raw === void 0) return key;
252
+ return interpolate(raw, opts?.values);
253
+ }
254
+ return { t, locale, fallbackLocale };
255
+ }
256
+ function interpolate(template, values) {
257
+ if (!values) return template;
258
+ return template.replace(
259
+ /\{(\w+)\}/g,
260
+ (_, k) => values[k] !== void 0 ? String(values[k]) : `{${k}}`
261
+ );
262
+ }
263
+
264
+ // src/formatters.ts
265
+ function formatNumber(value, locale, options) {
266
+ return new Intl.NumberFormat(locale, options).format(value);
267
+ }
268
+ function formatCurrency(value, locale, currency, options) {
269
+ return new Intl.NumberFormat(locale, {
270
+ style: "currency",
271
+ currency,
272
+ ...options
273
+ }).format(value);
274
+ }
275
+ function formatI18nDate(date, locale, options) {
276
+ const d = typeof date === "string" ? new Date(date) : date;
277
+ return new Intl.DateTimeFormat(locale, options).format(d);
278
+ }
279
+ function formatRelativeTime(value, unit, locale) {
280
+ return new Intl.RelativeTimeFormat(locale, { numeric: "auto" }).format(value, unit);
281
+ }
282
+
283
+ // src/constants.ts
284
+ var SUPPORTED_LANGUAGES = {
285
+ // Global
286
+ en: { name: "English", nativeName: "English", direction: "ltr" },
287
+ fr: { name: "French", nativeName: "Fran\xE7ais", direction: "ltr" },
288
+ es: { name: "Spanish", nativeName: "Espa\xF1ol", direction: "ltr" },
289
+ pt: { name: "Portuguese", nativeName: "Portugu\xEAs", direction: "ltr" },
290
+ ar: { name: "Arabic", nativeName: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629", direction: "rtl" },
291
+ zh: { name: "Chinese", nativeName: "\u4E2D\u6587", direction: "ltr" },
292
+ hi: { name: "Hindi", nativeName: "\u0939\u093F\u0928\u094D\u0926\u0940", direction: "ltr" },
293
+ // West Africa
294
+ tw: { name: "Twi", nativeName: "Twi", direction: "ltr" },
295
+ gaa: { name: "Ga", nativeName: "G\xE3", direction: "ltr" },
296
+ ee: { name: "Ewe", nativeName: "E\u028Begbe", direction: "ltr" },
297
+ dag: { name: "Dagbani", nativeName: "Dagbanli", direction: "ltr" },
298
+ yo: { name: "Yoruba", nativeName: "Yor\xF9b\xE1", direction: "ltr" },
299
+ ig: { name: "Igbo", nativeName: "Igbo", direction: "ltr" },
300
+ ha: { name: "Hausa", nativeName: "Hausa", direction: "ltr" },
301
+ wo: { name: "Wolof", nativeName: "Wolof", direction: "ltr" },
302
+ // East Africa
303
+ sw: { name: "Swahili", nativeName: "Kiswahili", direction: "ltr" },
304
+ ki: { name: "Kikuyu", nativeName: "G\u0129k\u0169y\u0169", direction: "ltr" },
305
+ luo: { name: "Luo", nativeName: "Dholuo", direction: "ltr" },
306
+ kam: { name: "Kamba", nativeName: "Kikamba", direction: "ltr" },
307
+ kln: { name: "Kalenjin", nativeName: "Kalenjin", direction: "ltr" },
308
+ suk: { name: "Sukuma", nativeName: "Kisukuma", direction: "ltr" },
309
+ hay: { name: "Haya", nativeName: "Kihaya", direction: "ltr" },
310
+ // Latin America (Indigenous)
311
+ qu: { name: "Quechua", nativeName: "Runasimi", direction: "ltr" },
312
+ ay: { name: "Aymara", nativeName: "Aymar aru", direction: "ltr" },
313
+ gn: { name: "Guarani", nativeName: "Ava\xF1e'\u1EBD", direction: "ltr" },
314
+ // South Asia
315
+ bn: { name: "Bengali", nativeName: "\u09AC\u09BE\u0982\u09B2\u09BE", direction: "ltr" },
316
+ ta: { name: "Tamil", nativeName: "\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD", direction: "ltr" },
317
+ te: { name: "Telugu", nativeName: "\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41", direction: "ltr" },
318
+ mr: { name: "Marathi", nativeName: "\u092E\u0930\u093E\u0920\u0940", direction: "ltr" }
319
+ };
320
+ var LANGUAGE_FAMILIES = {
321
+ niger_congo: ["tw", "gaa", "ee", "dag", "yo", "ig", "sw", "ki", "luo", "suk"],
322
+ afroasiatic: ["ha", "ar"],
323
+ indo_european: ["en", "fr", "es", "pt", "hi", "bn", "mr"],
324
+ quechuan: ["qu"],
325
+ aymaran: ["ay"],
326
+ sino_tibetan: ["zh"],
327
+ dravidian: ["ta", "te"],
328
+ tupian: ["gn"]
329
+ };
330
+
331
+ // src/rtl.ts
332
+ var RTL_LANGUAGES = /* @__PURE__ */ new Set(["ar", "he", "fa", "ur"]);
333
+ function isRTL(locale) {
334
+ const base = locale.split("-")[0];
335
+ const config = SUPPORTED_LANGUAGES[base];
336
+ if (config) return config.direction === "rtl";
337
+ return RTL_LANGUAGES.has(base);
338
+ }
339
+ function getDirection(locale) {
340
+ return isRTL(locale) ? "rtl" : "ltr";
341
+ }
342
+ // Annotate the CommonJS export names for ESM import in node:
343
+ 0 && (module.exports = {
344
+ CulturalContext,
345
+ LANGUAGE_FAMILIES,
346
+ SUPPORTED_LANGUAGES,
347
+ createTranslator,
348
+ formatCurrency,
349
+ formatI18nDate,
350
+ formatNumber,
351
+ formatRelativeTime,
352
+ getCulturalContext,
353
+ getDirection,
354
+ isRTL
355
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,318 @@
1
+ // src/cultural-context.ts
2
+ var CULTURAL_CONTEXTS = {
3
+ ghana: {
4
+ countryCode: "GH",
5
+ culturalValues: [
6
+ "community_harmony",
7
+ "respect_for_elders",
8
+ "traditional_authority",
9
+ "extended_family",
10
+ "hospitality"
11
+ ],
12
+ communicationStyle: "formal",
13
+ decisionMaking: "elder-consultation",
14
+ conflictResolution: "mediation_through_elders",
15
+ traditionalKnowledge: [
16
+ "chieftaincy_systems",
17
+ "communal_land_ownership",
18
+ "traditional_mining_practices"
19
+ ],
20
+ localExamples: ["galamsey_formalization", "community_mining_schemes", "chief_led_development"],
21
+ taboos: ["disrespect_to_chiefs", "public_confrontation"],
22
+ celebrations: ["homowo", "akwasidae", "damba"],
23
+ communityStructure: "chief_elder_family_hierarchy"
24
+ },
25
+ kenya: {
26
+ countryCode: "KE",
27
+ culturalValues: [
28
+ "harambee_collective_effort",
29
+ "family_unity",
30
+ "community_cooperation",
31
+ "environmental_stewardship"
32
+ ],
33
+ communicationStyle: "community-oriented",
34
+ decisionMaking: "consensus",
35
+ conflictResolution: "community_mediation",
36
+ traditionalKnowledge: [
37
+ "pastoral_land_management",
38
+ "community_savings_groups",
39
+ "age_set_systems"
40
+ ],
41
+ localExamples: ["chama_savings_groups", "community_conservancies", "table_banking"],
42
+ taboos: ["individualism_over_community", "elder_disrespect"],
43
+ celebrations: ["jamhuri_day", "madaraka_day"],
44
+ communityStructure: "clan_age_set_community"
45
+ },
46
+ peru: {
47
+ countryCode: "PE",
48
+ culturalValues: [
49
+ "ayni_reciprocity",
50
+ "pachamama_earth_respect",
51
+ "community_tradition",
52
+ "indigenous_rights"
53
+ ],
54
+ communicationStyle: "hierarchical",
55
+ decisionMaking: "community",
56
+ conflictResolution: "community_assembly",
57
+ traditionalKnowledge: [
58
+ "andean_mining_traditions",
59
+ "ayllu_community_systems",
60
+ "water_management"
61
+ ],
62
+ localExamples: [
63
+ "artisanal_mining_cooperatives",
64
+ "community_mining_titles",
65
+ "indigenous_consultation"
66
+ ],
67
+ taboos: ["pachamama_disrespect", "community_exclusion"],
68
+ celebrations: ["inti_raymi", "pachamama_day"],
69
+ communityStructure: "ayllu_community_assembly"
70
+ },
71
+ colombia: {
72
+ countryCode: "CO",
73
+ culturalValues: [
74
+ "cultural_diversity",
75
+ "community_resilience",
76
+ "environmental_protection",
77
+ "social_responsibility"
78
+ ],
79
+ communicationStyle: "formal",
80
+ decisionMaking: "consensus",
81
+ conflictResolution: "dialogue_and_mediation",
82
+ traditionalKnowledge: [
83
+ "indigenous_mining_rights",
84
+ "afro_colombian_traditions",
85
+ "community_councils"
86
+ ],
87
+ localExamples: [
88
+ "ethnic_mining_zones",
89
+ "community_mining_formalization",
90
+ "environmental_licensing"
91
+ ],
92
+ taboos: ["cultural_appropriation", "territorial_disrespect"],
93
+ celebrations: ["carnival_de_barranquilla", "dia_de_la_raza"],
94
+ communityStructure: "community_council_ethnic_authority"
95
+ },
96
+ tanzania: {
97
+ countryCode: "TZ",
98
+ culturalValues: ["ujamaa_familyhood", "unity_diversity", "self_reliance", "community_welfare"],
99
+ communicationStyle: "community-oriented",
100
+ decisionMaking: "consensus",
101
+ conflictResolution: "village_assembly",
102
+ traditionalKnowledge: [
103
+ "village_land_governance",
104
+ "cooperative_traditions",
105
+ "traditional_mining"
106
+ ],
107
+ localExamples: [
108
+ "village_mining_committees",
109
+ "cooperative_mining",
110
+ "community_development_agreements"
111
+ ],
112
+ taboos: ["community_division", "elder_disrespect"],
113
+ celebrations: ["uhuru_day", "union_day", "nyerere_day"],
114
+ communityStructure: "village_assembly_elder_council"
115
+ },
116
+ // Global hubs - more formal, less community-oriented
117
+ switzerland: {
118
+ countryCode: "CH",
119
+ culturalValues: ["precision", "neutrality", "quality", "privacy"],
120
+ communicationStyle: "formal",
121
+ decisionMaking: "individual",
122
+ conflictResolution: "legal_mediation",
123
+ traditionalKnowledge: [],
124
+ localExamples: ["swiss_refinery_standards", "responsible_gold_guidance"],
125
+ taboos: [],
126
+ celebrations: [],
127
+ communityStructure: "individual_institutional"
128
+ },
129
+ singapore: {
130
+ countryCode: "SG",
131
+ culturalValues: ["efficiency", "meritocracy", "rule_of_law", "multicultural_harmony"],
132
+ communicationStyle: "formal",
133
+ decisionMaking: "individual",
134
+ conflictResolution: "institutional",
135
+ traditionalKnowledge: [],
136
+ localExamples: ["commodity_trading_hub", "financial_center_standards"],
137
+ taboos: [],
138
+ celebrations: [],
139
+ communityStructure: "institutional_individual"
140
+ }
141
+ };
142
+ function getCulturalContext(countryCode) {
143
+ const normalized = countryCode.toLowerCase();
144
+ return CULTURAL_CONTEXTS[normalized] || null;
145
+ }
146
+ var CulturalContext = class {
147
+ config;
148
+ constructor(countryCode) {
149
+ const config = getCulturalContext(countryCode);
150
+ if (!config) {
151
+ throw new Error(`No cultural context found for country: ${countryCode}`);
152
+ }
153
+ this.config = config;
154
+ }
155
+ /**
156
+ * Check if formal communication style is expected
157
+ */
158
+ get usesFormalAddress() {
159
+ return this.config.communicationStyle === "formal" || this.config.communicationStyle === "hierarchical";
160
+ }
161
+ /**
162
+ * Check if community consultation is expected for decisions
163
+ */
164
+ get requiresCommunityConsultation() {
165
+ return this.config.decisionMaking === "consensus" || this.config.decisionMaking === "elder-consultation" || this.config.decisionMaking === "community";
166
+ }
167
+ /**
168
+ * Get local examples for explanations
169
+ */
170
+ getLocalExamples() {
171
+ return this.config.localExamples;
172
+ }
173
+ /**
174
+ * Check if a topic should be avoided
175
+ */
176
+ isTaboo(topic) {
177
+ return this.config.taboos.some((t) => topic.toLowerCase().includes(t.toLowerCase()));
178
+ }
179
+ /**
180
+ * Get traditional knowledge integration points
181
+ */
182
+ getTraditionalKnowledge() {
183
+ return this.config.traditionalKnowledge;
184
+ }
185
+ /**
186
+ * Get raw config
187
+ */
188
+ toJSON() {
189
+ return { ...this.config };
190
+ }
191
+ };
192
+
193
+ // src/translator.ts
194
+ function createTranslator(options) {
195
+ const { locale, fallbackLocale = "en", catalog } = options;
196
+ const chain = [locale];
197
+ const baseLang = locale.split("-")[0];
198
+ if (baseLang !== locale) chain.push(baseLang);
199
+ if (!chain.includes(fallbackLocale)) chain.push(fallbackLocale);
200
+ function resolve(key) {
201
+ for (const lang of chain) {
202
+ const map = catalog[lang];
203
+ if (!map) continue;
204
+ const value = map[key];
205
+ if (typeof value === "string") return value;
206
+ }
207
+ return void 0;
208
+ }
209
+ function t(key, opts) {
210
+ if (opts?.count !== void 0) {
211
+ const plural = opts.count === 0 ? resolve(`${key}_zero`) ?? resolve(`${key}_other`) : opts.count === 1 ? resolve(`${key}_one`) ?? resolve(key) : resolve(`${key}_other`) ?? resolve(key);
212
+ if (plural) return interpolate(plural, opts.values);
213
+ }
214
+ const raw = resolve(key);
215
+ if (raw === void 0) return key;
216
+ return interpolate(raw, opts?.values);
217
+ }
218
+ return { t, locale, fallbackLocale };
219
+ }
220
+ function interpolate(template, values) {
221
+ if (!values) return template;
222
+ return template.replace(
223
+ /\{(\w+)\}/g,
224
+ (_, k) => values[k] !== void 0 ? String(values[k]) : `{${k}}`
225
+ );
226
+ }
227
+
228
+ // src/formatters.ts
229
+ function formatNumber(value, locale, options) {
230
+ return new Intl.NumberFormat(locale, options).format(value);
231
+ }
232
+ function formatCurrency(value, locale, currency, options) {
233
+ return new Intl.NumberFormat(locale, {
234
+ style: "currency",
235
+ currency,
236
+ ...options
237
+ }).format(value);
238
+ }
239
+ function formatI18nDate(date, locale, options) {
240
+ const d = typeof date === "string" ? new Date(date) : date;
241
+ return new Intl.DateTimeFormat(locale, options).format(d);
242
+ }
243
+ function formatRelativeTime(value, unit, locale) {
244
+ return new Intl.RelativeTimeFormat(locale, { numeric: "auto" }).format(value, unit);
245
+ }
246
+
247
+ // src/constants.ts
248
+ var SUPPORTED_LANGUAGES = {
249
+ // Global
250
+ en: { name: "English", nativeName: "English", direction: "ltr" },
251
+ fr: { name: "French", nativeName: "Fran\xE7ais", direction: "ltr" },
252
+ es: { name: "Spanish", nativeName: "Espa\xF1ol", direction: "ltr" },
253
+ pt: { name: "Portuguese", nativeName: "Portugu\xEAs", direction: "ltr" },
254
+ ar: { name: "Arabic", nativeName: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629", direction: "rtl" },
255
+ zh: { name: "Chinese", nativeName: "\u4E2D\u6587", direction: "ltr" },
256
+ hi: { name: "Hindi", nativeName: "\u0939\u093F\u0928\u094D\u0926\u0940", direction: "ltr" },
257
+ // West Africa
258
+ tw: { name: "Twi", nativeName: "Twi", direction: "ltr" },
259
+ gaa: { name: "Ga", nativeName: "G\xE3", direction: "ltr" },
260
+ ee: { name: "Ewe", nativeName: "E\u028Begbe", direction: "ltr" },
261
+ dag: { name: "Dagbani", nativeName: "Dagbanli", direction: "ltr" },
262
+ yo: { name: "Yoruba", nativeName: "Yor\xF9b\xE1", direction: "ltr" },
263
+ ig: { name: "Igbo", nativeName: "Igbo", direction: "ltr" },
264
+ ha: { name: "Hausa", nativeName: "Hausa", direction: "ltr" },
265
+ wo: { name: "Wolof", nativeName: "Wolof", direction: "ltr" },
266
+ // East Africa
267
+ sw: { name: "Swahili", nativeName: "Kiswahili", direction: "ltr" },
268
+ ki: { name: "Kikuyu", nativeName: "G\u0129k\u0169y\u0169", direction: "ltr" },
269
+ luo: { name: "Luo", nativeName: "Dholuo", direction: "ltr" },
270
+ kam: { name: "Kamba", nativeName: "Kikamba", direction: "ltr" },
271
+ kln: { name: "Kalenjin", nativeName: "Kalenjin", direction: "ltr" },
272
+ suk: { name: "Sukuma", nativeName: "Kisukuma", direction: "ltr" },
273
+ hay: { name: "Haya", nativeName: "Kihaya", direction: "ltr" },
274
+ // Latin America (Indigenous)
275
+ qu: { name: "Quechua", nativeName: "Runasimi", direction: "ltr" },
276
+ ay: { name: "Aymara", nativeName: "Aymar aru", direction: "ltr" },
277
+ gn: { name: "Guarani", nativeName: "Ava\xF1e'\u1EBD", direction: "ltr" },
278
+ // South Asia
279
+ bn: { name: "Bengali", nativeName: "\u09AC\u09BE\u0982\u09B2\u09BE", direction: "ltr" },
280
+ ta: { name: "Tamil", nativeName: "\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD", direction: "ltr" },
281
+ te: { name: "Telugu", nativeName: "\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41", direction: "ltr" },
282
+ mr: { name: "Marathi", nativeName: "\u092E\u0930\u093E\u0920\u0940", direction: "ltr" }
283
+ };
284
+ var LANGUAGE_FAMILIES = {
285
+ niger_congo: ["tw", "gaa", "ee", "dag", "yo", "ig", "sw", "ki", "luo", "suk"],
286
+ afroasiatic: ["ha", "ar"],
287
+ indo_european: ["en", "fr", "es", "pt", "hi", "bn", "mr"],
288
+ quechuan: ["qu"],
289
+ aymaran: ["ay"],
290
+ sino_tibetan: ["zh"],
291
+ dravidian: ["ta", "te"],
292
+ tupian: ["gn"]
293
+ };
294
+
295
+ // src/rtl.ts
296
+ var RTL_LANGUAGES = /* @__PURE__ */ new Set(["ar", "he", "fa", "ur"]);
297
+ function isRTL(locale) {
298
+ const base = locale.split("-")[0];
299
+ const config = SUPPORTED_LANGUAGES[base];
300
+ if (config) return config.direction === "rtl";
301
+ return RTL_LANGUAGES.has(base);
302
+ }
303
+ function getDirection(locale) {
304
+ return isRTL(locale) ? "rtl" : "ltr";
305
+ }
306
+ export {
307
+ CulturalContext,
308
+ LANGUAGE_FAMILIES,
309
+ SUPPORTED_LANGUAGES,
310
+ createTranslator,
311
+ formatCurrency,
312
+ formatI18nDate,
313
+ formatNumber,
314
+ formatRelativeTime,
315
+ getCulturalContext,
316
+ getDirection,
317
+ isRTL
318
+ };