@lucaapp/service-utils 4.14.1 → 5.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.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -35,4 +35,5 @@ __exportStar(require("./lib/http"), exports);
|
|
|
35
35
|
__exportStar(require("./lib/jobs"), exports);
|
|
36
36
|
__exportStar(require("./lib/validation"), exports);
|
|
37
37
|
__exportStar(require("./lib/s3"), exports);
|
|
38
|
+
__exportStar(require("./lib/iso3166"), exports);
|
|
38
39
|
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './iso3166Mapping';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./iso3166Mapping"), exports);
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comprehensive mapping of ISO 3166-1 alpha-2 country codes to their ACTUAL primary language
|
|
3
|
+
* This maps each country to its real primary language, regardless of whether we support it
|
|
4
|
+
* Use this for accurate language detection and future language support planning
|
|
5
|
+
* https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
6
|
+
*/
|
|
7
|
+
export declare const COUNTRY_TO_LANGUAGE_MAP: Record<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Gets the ACTUAL primary language for a given country code
|
|
10
|
+
* Returns the real language spoken in that country, even if we don't support it yet
|
|
11
|
+
* Use this for language detection and planning future language support
|
|
12
|
+
*
|
|
13
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code (e.g., 'DE', 'FR', 'US')
|
|
14
|
+
* @returns The actual primary language code for the country, or 'en' if not mapped
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* getLanguageFromCountry('DE') // returns 'de'
|
|
19
|
+
* getLanguageFromCountry('FR') // returns 'fr'
|
|
20
|
+
* getLanguageFromCountry(null) // returns 'en' (no country)
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const getLanguageFromCountry: (countryCode?: string | null) => string;
|
|
24
|
+
/**
|
|
25
|
+
* Comprehensive mapping of ISO 3166-1 alpha-2 country codes to all language locales
|
|
26
|
+
* Format: language-COUNTRY (e.g., ['en-US'], ['nl-BE', 'fr-BE', 'de-BE'])
|
|
27
|
+
* First locale in array is the primary/most common language
|
|
28
|
+
* Multi-language countries have multiple locales in order of prevalence
|
|
29
|
+
*/
|
|
30
|
+
export declare const COUNTRY_TO_LOCALES_MAP: Record<string, string[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Gets all language locales for a given country code
|
|
33
|
+
* Returns an array of all official or widely-spoken language variants
|
|
34
|
+
* First locale in array is the primary/most common language
|
|
35
|
+
*
|
|
36
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
37
|
+
* @returns Array of language-country locale codes
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* getLocalesFromCountry('BE') // returns ['nl-BE', 'fr-BE', 'de-BE']
|
|
42
|
+
* getLocalesFromCountry('CA') // returns ['en-CA', 'fr-CA']
|
|
43
|
+
* getLocalesFromCountry('CH') // returns ['de-CH', 'fr-CH', 'it-CH', 'rm-CH']
|
|
44
|
+
* getLocalesFromCountry('US') // returns ['en-US']
|
|
45
|
+
* getLocalesFromCountry('DE') // returns ['de-DE']
|
|
46
|
+
* getLocalesFromCountry('XX') // returns ['en'] (fallback)
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const getLocalesFromCountry: (countryCode?: string | null) => string[];
|
|
50
|
+
/**
|
|
51
|
+
* Gets the primary language locale for a given country code
|
|
52
|
+
* Returns the first (primary) locale from the country's locale array
|
|
53
|
+
* Returns format: language-COUNTRY (e.g., en-US, en-GB, fr-CA, es-MX)
|
|
54
|
+
*
|
|
55
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code (e.g., 'US', 'GB', 'MX')
|
|
56
|
+
* @returns The primary language-country locale code
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* getLocaleFromCountry('US') // returns 'en-US'
|
|
61
|
+
* getLocaleFromCountry('GB') // returns 'en-GB'
|
|
62
|
+
* getLocaleFromCountry('DE') // returns 'de-DE'
|
|
63
|
+
* getLocaleFromCountry('BE') // returns 'nl-BE' (primary language)
|
|
64
|
+
* getLocaleFromCountry('XX') // returns 'en' (fallback)
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare const getLocaleFromCountry: (countryCode?: string | null) => string;
|
|
68
|
+
/**
|
|
69
|
+
* Comprehensive mapping of language codes to their English names
|
|
70
|
+
* Includes currently supported languages and potential future additions
|
|
71
|
+
*/
|
|
72
|
+
export declare const ENGLISH_LANGUAGE_NAMES: Record<string, string>;
|
|
73
|
+
/**
|
|
74
|
+
* Gets the language name in English for a given language code
|
|
75
|
+
*
|
|
76
|
+
* @param lang - Language code (ISO 639-1)
|
|
77
|
+
* @returns The English name of the language
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* getLanguageName('de') // returns 'German'
|
|
82
|
+
* getLanguageName('fr') // returns 'French'
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare const getLanguageName: (lang: string) => string | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Comprehensive mapping of language codes to their native names
|
|
88
|
+
* Includes currently supported languages and potential future additions
|
|
89
|
+
*/
|
|
90
|
+
export declare const NATIVE_LANGUAGE_NAMES: Record<string, string>;
|
|
91
|
+
/**
|
|
92
|
+
* Gets the native language name for a given language code
|
|
93
|
+
*
|
|
94
|
+
* @param lang - Language code (ISO 639-1)
|
|
95
|
+
* @returns The native name of the language
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* getNativeLanguageName('de') // returns 'Deutsch'
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare const getNativeLanguageName: (lang: string) => string | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Comprehensive mapping of ISO 3166-1 alpha-2 country codes to English country names
|
|
105
|
+
*/
|
|
106
|
+
export declare const COUNTRY_NAMES: Record<string, string>;
|
|
107
|
+
/**
|
|
108
|
+
* Gets the country name for a given country code
|
|
109
|
+
*
|
|
110
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
111
|
+
* @returns The English name of the country, or the country code if unknown
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* getCountryName('DE') // returns 'Germany'
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare const getCountryName: (countryCode: string) => string | undefined;
|
|
@@ -0,0 +1,989 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCountryName = exports.COUNTRY_NAMES = exports.getNativeLanguageName = exports.NATIVE_LANGUAGE_NAMES = exports.getLanguageName = exports.ENGLISH_LANGUAGE_NAMES = exports.getLocaleFromCountry = exports.getLocalesFromCountry = exports.COUNTRY_TO_LOCALES_MAP = exports.getLanguageFromCountry = exports.COUNTRY_TO_LANGUAGE_MAP = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Comprehensive mapping of ISO 3166-1 alpha-2 country codes to their ACTUAL primary language
|
|
6
|
+
* This maps each country to its real primary language, regardless of whether we support it
|
|
7
|
+
* Use this for accurate language detection and future language support planning
|
|
8
|
+
* https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
|
|
9
|
+
*/
|
|
10
|
+
exports.COUNTRY_TO_LANGUAGE_MAP = {
|
|
11
|
+
// Europe
|
|
12
|
+
AD: 'ca', // Andorra - Catalan
|
|
13
|
+
AL: 'sq', // Albania - Albanian
|
|
14
|
+
AT: 'de', // Austria - German
|
|
15
|
+
AX: 'sv', // Åland Islands - Swedish
|
|
16
|
+
BA: 'bs', // Bosnia and Herzegovina - Bosnian
|
|
17
|
+
BE: 'nl', // Belgium - Dutch (also French)
|
|
18
|
+
BG: 'bg', // Bulgaria - Bulgarian
|
|
19
|
+
BY: 'be', // Belarus - Belarusian
|
|
20
|
+
CH: 'de', // Switzerland - German (also French, Italian, Romansh)
|
|
21
|
+
CY: 'el', // Cyprus - Greek
|
|
22
|
+
CZ: 'cs', // Czechia - Czech
|
|
23
|
+
DE: 'de', // Germany - German
|
|
24
|
+
DK: 'da', // Denmark - Danish
|
|
25
|
+
EE: 'et', // Estonia - Estonian
|
|
26
|
+
ES: 'es', // Spain - Spanish
|
|
27
|
+
FI: 'fi', // Finland - Finnish
|
|
28
|
+
FO: 'fo', // Faroe Islands - Faroese
|
|
29
|
+
FR: 'fr', // France - French
|
|
30
|
+
GB: 'en', // United Kingdom - English
|
|
31
|
+
GG: 'en', // Guernsey - English
|
|
32
|
+
GI: 'en', // Gibraltar - English
|
|
33
|
+
GL: 'kl', // Greenland - Greenlandic
|
|
34
|
+
GR: 'el', // Greece - Greek
|
|
35
|
+
HR: 'hr', // Croatia - Croatian
|
|
36
|
+
HU: 'hu', // Hungary - Hungarian
|
|
37
|
+
IE: 'en', // Ireland - English
|
|
38
|
+
IM: 'en', // Isle of Man - English
|
|
39
|
+
IS: 'is', // Iceland - Icelandic
|
|
40
|
+
IT: 'it', // Italy - Italian
|
|
41
|
+
JE: 'en', // Jersey - English
|
|
42
|
+
LI: 'de', // Liechtenstein - German
|
|
43
|
+
LT: 'lt', // Lithuania - Lithuanian
|
|
44
|
+
LU: 'lb', // Luxembourg - Luxembourgish
|
|
45
|
+
LV: 'lv', // Latvia - Latvian
|
|
46
|
+
MC: 'fr', // Monaco - French
|
|
47
|
+
MD: 'ro', // Moldova - Romanian
|
|
48
|
+
ME: 'sr', // Montenegro - Serbian
|
|
49
|
+
MK: 'mk', // North Macedonia - Macedonian
|
|
50
|
+
MT: 'mt', // Malta - Maltese
|
|
51
|
+
NL: 'nl', // Netherlands - Dutch
|
|
52
|
+
NO: 'no', // Norway - Norwegian
|
|
53
|
+
PL: 'pl', // Poland - Polish
|
|
54
|
+
PT: 'pt', // Portugal - Portuguese
|
|
55
|
+
RO: 'ro', // Romania - Romanian
|
|
56
|
+
RS: 'sr', // Serbia - Serbian
|
|
57
|
+
RU: 'ru', // Russia - Russian
|
|
58
|
+
SE: 'sv', // Sweden - Swedish
|
|
59
|
+
SI: 'sl', // Slovenia - Slovenian
|
|
60
|
+
SJ: 'no', // Svalbard and Jan Mayen - Norwegian
|
|
61
|
+
SK: 'sk', // Slovakia - Slovak
|
|
62
|
+
SM: 'it', // San Marino - Italian
|
|
63
|
+
TR: 'tr', // Turkey - Turkish
|
|
64
|
+
UA: 'uk', // Ukraine - Ukrainian
|
|
65
|
+
VA: 'it', // Vatican City - Italian
|
|
66
|
+
XK: 'sq', // Kosovo - Albanian
|
|
67
|
+
// Americas
|
|
68
|
+
AG: 'en', // Antigua and Barbuda - English
|
|
69
|
+
AI: 'en', // Anguilla - English
|
|
70
|
+
AR: 'es', // Argentina - Spanish
|
|
71
|
+
AS: 'en', // American Samoa - English
|
|
72
|
+
AW: 'nl', // Aruba - Dutch
|
|
73
|
+
BB: 'en', // Barbados - English
|
|
74
|
+
BL: 'fr', // Saint Barthélemy - French
|
|
75
|
+
BM: 'en', // Bermuda - English
|
|
76
|
+
BO: 'es', // Bolivia - Spanish
|
|
77
|
+
BQ: 'nl', // Bonaire, Sint Eustatius and Saba - Dutch
|
|
78
|
+
BR: 'pt', // Brazil - Portuguese
|
|
79
|
+
BS: 'en', // Bahamas - English
|
|
80
|
+
BZ: 'en', // Belize - English
|
|
81
|
+
CA: 'en', // Canada - English (also French)
|
|
82
|
+
CL: 'es', // Chile - Spanish
|
|
83
|
+
CO: 'es', // Colombia - Spanish
|
|
84
|
+
CR: 'es', // Costa Rica - Spanish
|
|
85
|
+
CU: 'es', // Cuba - Spanish
|
|
86
|
+
CW: 'nl', // Curaçao - Dutch
|
|
87
|
+
DM: 'en', // Dominica - English
|
|
88
|
+
DO: 'es', // Dominican Republic - Spanish
|
|
89
|
+
EC: 'es', // Ecuador - Spanish
|
|
90
|
+
FK: 'en', // Falkland Islands - English
|
|
91
|
+
GD: 'en', // Grenada - English
|
|
92
|
+
GF: 'fr', // French Guiana - French
|
|
93
|
+
GP: 'fr', // Guadeloupe - French
|
|
94
|
+
GT: 'es', // Guatemala - Spanish
|
|
95
|
+
GY: 'en', // Guyana - English
|
|
96
|
+
HN: 'es', // Honduras - Spanish
|
|
97
|
+
HT: 'ht', // Haiti - Haitian Creole
|
|
98
|
+
JM: 'en', // Jamaica - English
|
|
99
|
+
KN: 'en', // Saint Kitts and Nevis - English
|
|
100
|
+
KY: 'en', // Cayman Islands - English
|
|
101
|
+
LC: 'en', // Saint Lucia - English
|
|
102
|
+
MF: 'fr', // Saint Martin - French
|
|
103
|
+
MQ: 'fr', // Martinique - French
|
|
104
|
+
MS: 'en', // Montserrat - English
|
|
105
|
+
MX: 'es', // Mexico - Spanish
|
|
106
|
+
NI: 'es', // Nicaragua - Spanish
|
|
107
|
+
PA: 'es', // Panama - Spanish
|
|
108
|
+
PE: 'es', // Peru - Spanish
|
|
109
|
+
PM: 'fr', // Saint Pierre and Miquelon - French
|
|
110
|
+
PR: 'es', // Puerto Rico - Spanish
|
|
111
|
+
PY: 'es', // Paraguay - Spanish
|
|
112
|
+
SR: 'nl', // Suriname - Dutch
|
|
113
|
+
SV: 'es', // El Salvador - Spanish
|
|
114
|
+
SX: 'nl', // Sint Maarten - Dutch
|
|
115
|
+
TC: 'en', // Turks and Caicos Islands - English
|
|
116
|
+
TT: 'en', // Trinidad and Tobago - English
|
|
117
|
+
US: 'en', // United States - English
|
|
118
|
+
UY: 'es', // Uruguay - Spanish
|
|
119
|
+
VC: 'en', // Saint Vincent and the Grenadines - English
|
|
120
|
+
VE: 'es', // Venezuela - Spanish
|
|
121
|
+
VG: 'en', // British Virgin Islands - English
|
|
122
|
+
VI: 'en', // U.S. Virgin Islands - English
|
|
123
|
+
// Asia & Middle East & Oceania
|
|
124
|
+
AE: 'ar', // United Arab Emirates - Arabic
|
|
125
|
+
AF: 'ps', // Afghanistan - Pashto
|
|
126
|
+
AM: 'hy', // Armenia - Armenian
|
|
127
|
+
AU: 'en', // Australia - English
|
|
128
|
+
AZ: 'az', // Azerbaijan - Azerbaijani
|
|
129
|
+
BD: 'bn', // Bangladesh - Bengali
|
|
130
|
+
BH: 'ar', // Bahrain - Arabic
|
|
131
|
+
BN: 'ms', // Brunei - Malay
|
|
132
|
+
BT: 'dz', // Bhutan - Dzongkha
|
|
133
|
+
CC: 'en', // Cocos Islands - English
|
|
134
|
+
CN: 'zh', // China - Chinese
|
|
135
|
+
CX: 'en', // Christmas Island - English
|
|
136
|
+
GE: 'ka', // Georgia - Georgian
|
|
137
|
+
HK: 'zh', // Hong Kong - Chinese
|
|
138
|
+
ID: 'id', // Indonesia - Indonesian
|
|
139
|
+
IL: 'he', // Israel - Hebrew
|
|
140
|
+
IN: 'hi', // India - Hindi
|
|
141
|
+
IO: 'en', // British Indian Ocean Territory - English
|
|
142
|
+
IQ: 'ar', // Iraq - Arabic
|
|
143
|
+
IR: 'fa', // Iran - Persian
|
|
144
|
+
JO: 'ar', // Jordan - Arabic
|
|
145
|
+
JP: 'ja', // Japan - Japanese
|
|
146
|
+
KG: 'ky', // Kyrgyzstan - Kyrgyz
|
|
147
|
+
KH: 'km', // Cambodia - Khmer
|
|
148
|
+
KP: 'ko', // North Korea - Korean
|
|
149
|
+
KR: 'ko', // South Korea - Korean
|
|
150
|
+
KW: 'ar', // Kuwait - Arabic
|
|
151
|
+
KZ: 'kk', // Kazakhstan - Kazakh
|
|
152
|
+
LA: 'lo', // Laos - Lao
|
|
153
|
+
LB: 'ar', // Lebanon - Arabic
|
|
154
|
+
LK: 'si', // Sri Lanka - Sinhala
|
|
155
|
+
MM: 'my', // Myanmar - Burmese
|
|
156
|
+
MN: 'mn', // Mongolia - Mongolian
|
|
157
|
+
MO: 'zh', // Macau - Chinese
|
|
158
|
+
MV: 'dv', // Maldives - Dhivehi
|
|
159
|
+
MY: 'ms', // Malaysia - Malay
|
|
160
|
+
NP: 'ne', // Nepal - Nepali
|
|
161
|
+
NZ: 'en', // New Zealand - English
|
|
162
|
+
OM: 'ar', // Oman - Arabic
|
|
163
|
+
PH: 'tl', // Philippines - Tagalog
|
|
164
|
+
PK: 'ur', // Pakistan - Urdu
|
|
165
|
+
PS: 'ar', // Palestine - Arabic
|
|
166
|
+
QA: 'ar', // Qatar - Arabic
|
|
167
|
+
SA: 'ar', // Saudi Arabia - Arabic
|
|
168
|
+
SG: 'en', // Singapore - English
|
|
169
|
+
SY: 'ar', // Syria - Arabic
|
|
170
|
+
TH: 'th', // Thailand - Thai
|
|
171
|
+
TJ: 'tg', // Tajikistan - Tajik
|
|
172
|
+
TL: 'pt', // Timor-Leste - Portuguese
|
|
173
|
+
TM: 'tk', // Turkmenistan - Turkmen
|
|
174
|
+
TW: 'zh', // Taiwan - Chinese
|
|
175
|
+
UZ: 'uz', // Uzbekistan - Uzbek
|
|
176
|
+
VN: 'vi', // Vietnam - Vietnamese
|
|
177
|
+
YE: 'ar', // Yemen - Arabic
|
|
178
|
+
// Africa
|
|
179
|
+
AO: 'pt', // Angola - Portuguese
|
|
180
|
+
BF: 'fr', // Burkina Faso - French
|
|
181
|
+
BI: 'fr', // Burundi - French
|
|
182
|
+
BJ: 'fr', // Benin - French
|
|
183
|
+
BW: 'en', // Botswana - English
|
|
184
|
+
CD: 'fr', // Democratic Republic of the Congo - French
|
|
185
|
+
CF: 'fr', // Central African Republic - French
|
|
186
|
+
CG: 'fr', // Congo - French
|
|
187
|
+
CI: 'fr', // Côte d'Ivoire - French
|
|
188
|
+
CM: 'fr', // Cameroon - French
|
|
189
|
+
CV: 'pt', // Cape Verde - Portuguese
|
|
190
|
+
DJ: 'fr', // Djibouti - French
|
|
191
|
+
DZ: 'ar', // Algeria - Arabic
|
|
192
|
+
EG: 'ar', // Egypt - Arabic
|
|
193
|
+
ER: 'ti', // Eritrea - Tigrinya
|
|
194
|
+
ET: 'am', // Ethiopia - Amharic
|
|
195
|
+
GA: 'fr', // Gabon - French
|
|
196
|
+
GH: 'en', // Ghana - English
|
|
197
|
+
GM: 'en', // Gambia - English
|
|
198
|
+
GN: 'fr', // Guinea - French
|
|
199
|
+
GQ: 'es', // Equatorial Guinea - Spanish
|
|
200
|
+
GW: 'pt', // Guinea-Bissau - Portuguese
|
|
201
|
+
KE: 'sw', // Kenya - Swahili
|
|
202
|
+
KM: 'ar', // Comoros - Arabic
|
|
203
|
+
LR: 'en', // Liberia - English
|
|
204
|
+
LS: 'en', // Lesotho - English
|
|
205
|
+
LY: 'ar', // Libya - Arabic
|
|
206
|
+
MA: 'ar', // Morocco - Arabic
|
|
207
|
+
MG: 'mg', // Madagascar - Malagasy
|
|
208
|
+
ML: 'fr', // Mali - French
|
|
209
|
+
MR: 'ar', // Mauritania - Arabic
|
|
210
|
+
MU: 'en', // Mauritius - English
|
|
211
|
+
MW: 'en', // Malawi - English
|
|
212
|
+
MZ: 'pt', // Mozambique - Portuguese
|
|
213
|
+
NA: 'en', // Namibia - English
|
|
214
|
+
NE: 'fr', // Niger - French
|
|
215
|
+
NG: 'en', // Nigeria - English
|
|
216
|
+
RE: 'fr', // Réunion - French
|
|
217
|
+
RW: 'rw', // Rwanda - Kinyarwanda
|
|
218
|
+
SC: 'en', // Seychelles - English
|
|
219
|
+
SD: 'ar', // Sudan - Arabic
|
|
220
|
+
SH: 'en', // Saint Helena, Ascension and Tristan da Cunha - English
|
|
221
|
+
SL: 'en', // Sierra Leone - English
|
|
222
|
+
SN: 'fr', // Senegal - French
|
|
223
|
+
SO: 'so', // Somalia - Somali
|
|
224
|
+
SS: 'en', // South Sudan - English
|
|
225
|
+
ST: 'pt', // São Tomé and Príncipe - Portuguese
|
|
226
|
+
SZ: 'en', // Eswatini - English
|
|
227
|
+
TD: 'fr', // Chad - French
|
|
228
|
+
TG: 'fr', // Togo - French
|
|
229
|
+
TN: 'ar', // Tunisia - Arabic
|
|
230
|
+
TZ: 'sw', // Tanzania - Swahili
|
|
231
|
+
UG: 'en', // Uganda - English
|
|
232
|
+
YT: 'fr', // Mayotte - French
|
|
233
|
+
ZA: 'en', // South Africa - English
|
|
234
|
+
ZM: 'en', // Zambia - English
|
|
235
|
+
ZW: 'en', // Zimbabwe - English
|
|
236
|
+
// Oceania
|
|
237
|
+
CK: 'en', // Cook Islands - English
|
|
238
|
+
FJ: 'en', // Fiji - English
|
|
239
|
+
FM: 'en', // Micronesia - English
|
|
240
|
+
GU: 'en', // Guam - English
|
|
241
|
+
KI: 'en', // Kiribati - English
|
|
242
|
+
MH: 'en', // Marshall Islands - English
|
|
243
|
+
MP: 'en', // Northern Mariana Islands - English
|
|
244
|
+
NC: 'fr', // New Caledonia - French
|
|
245
|
+
NF: 'en', // Norfolk Island - English
|
|
246
|
+
NR: 'en', // Nauru - English
|
|
247
|
+
NU: 'en', // Niue - English
|
|
248
|
+
PF: 'fr', // French Polynesia - French
|
|
249
|
+
PG: 'en', // Papua New Guinea - English
|
|
250
|
+
PN: 'en', // Pitcairn Islands - English
|
|
251
|
+
PW: 'en', // Palau - English
|
|
252
|
+
SB: 'en', // Solomon Islands - English
|
|
253
|
+
TK: 'en', // Tokelau - English
|
|
254
|
+
TO: 'to', // Tonga - Tongan
|
|
255
|
+
TV: 'en', // Tuvalu - English
|
|
256
|
+
UM: 'en', // U.S. Minor Outlying Islands - English
|
|
257
|
+
VU: 'en', // Vanuatu - English
|
|
258
|
+
WF: 'fr', // Wallis and Futuna - French
|
|
259
|
+
WS: 'sm', // Samoa - Samoan
|
|
260
|
+
// Antarctica
|
|
261
|
+
AQ: 'en', // Antarctica - English
|
|
262
|
+
BV: 'no', // Bouvet Island - Norwegian
|
|
263
|
+
GS: 'en', // South Georgia and the South Sandwich Islands - English
|
|
264
|
+
HM: 'en', // Heard Island and McDonald Islands - English
|
|
265
|
+
TF: 'fr', // French Southern Territories - French
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Gets the ACTUAL primary language for a given country code
|
|
269
|
+
* Returns the real language spoken in that country, even if we don't support it yet
|
|
270
|
+
* Use this for language detection and planning future language support
|
|
271
|
+
*
|
|
272
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code (e.g., 'DE', 'FR', 'US')
|
|
273
|
+
* @returns The actual primary language code for the country, or 'en' if not mapped
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* getLanguageFromCountry('DE') // returns 'de'
|
|
278
|
+
* getLanguageFromCountry('FR') // returns 'fr'
|
|
279
|
+
* getLanguageFromCountry(null) // returns 'en' (no country)
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
const getLanguageFromCountry = (countryCode) => {
|
|
283
|
+
if (!countryCode) {
|
|
284
|
+
return 'en';
|
|
285
|
+
}
|
|
286
|
+
return exports.COUNTRY_TO_LANGUAGE_MAP[countryCode.toUpperCase()] || 'en';
|
|
287
|
+
};
|
|
288
|
+
exports.getLanguageFromCountry = getLanguageFromCountry;
|
|
289
|
+
/**
|
|
290
|
+
* Comprehensive mapping of ISO 3166-1 alpha-2 country codes to all language locales
|
|
291
|
+
* Format: language-COUNTRY (e.g., ['en-US'], ['nl-BE', 'fr-BE', 'de-BE'])
|
|
292
|
+
* First locale in array is the primary/most common language
|
|
293
|
+
* Multi-language countries have multiple locales in order of prevalence
|
|
294
|
+
*/
|
|
295
|
+
exports.COUNTRY_TO_LOCALES_MAP = {
|
|
296
|
+
// Single-language countries - English
|
|
297
|
+
US: ['en-US'], // United States
|
|
298
|
+
GB: ['en-GB'], // United Kingdom
|
|
299
|
+
AU: ['en-AU'], // Australia
|
|
300
|
+
NZ: ['en-NZ'], // New Zealand
|
|
301
|
+
JM: ['en-JM'], // Jamaica
|
|
302
|
+
TT: ['en-TT'], // Trinidad and Tobago
|
|
303
|
+
BS: ['en-BS'], // Bahamas
|
|
304
|
+
BB: ['en-BB'], // Barbados
|
|
305
|
+
BZ: ['en-BZ'], // Belize
|
|
306
|
+
GY: ['en-GY'], // Guyana
|
|
307
|
+
// Multi-language countries - English primary
|
|
308
|
+
CA: ['en-CA', 'fr-CA'], // Canada: English, French
|
|
309
|
+
SG: ['en-SG', 'zh-SG', 'ms-SG', 'ta-SG'], // Singapore: English, Chinese, Malay, Tamil
|
|
310
|
+
IN: ['hi-IN', 'en-IN'], // India: Hindi, English (+ many regional)
|
|
311
|
+
PH: ['tl-PH', 'en-PH'], // Philippines: Tagalog, English
|
|
312
|
+
HK: ['zh-HK', 'en-HK'], // Hong Kong: Chinese, English
|
|
313
|
+
ZA: ['en-ZA', 'af-ZA', 'zu-ZA', 'xh-ZA'], // South Africa: English, Afrikaans, Zulu, Xhosa
|
|
314
|
+
IE: ['en-IE', 'ga-IE'], // Ireland: English, Irish
|
|
315
|
+
MT: ['mt-MT', 'en-MT'], // Malta: Maltese, English
|
|
316
|
+
// Spanish variants
|
|
317
|
+
ES: ['es-ES'], // Spain
|
|
318
|
+
MX: ['es-MX'], // Mexico
|
|
319
|
+
AR: ['es-AR'], // Argentina
|
|
320
|
+
CO: ['es-CO'], // Colombia
|
|
321
|
+
CL: ['es-CL'], // Chile
|
|
322
|
+
PE: ['es-PE'], // Peru
|
|
323
|
+
VE: ['es-VE'], // Venezuela
|
|
324
|
+
CR: ['es-CR'], // Costa Rica
|
|
325
|
+
CU: ['es-CU'], // Cuba
|
|
326
|
+
DO: ['es-DO'], // Dominican Republic
|
|
327
|
+
EC: ['es-EC'], // Ecuador
|
|
328
|
+
GT: ['es-GT'], // Guatemala
|
|
329
|
+
HN: ['es-HN'], // Honduras
|
|
330
|
+
NI: ['es-NI'], // Nicaragua
|
|
331
|
+
PA: ['es-PA'], // Panama
|
|
332
|
+
PR: ['es-PR'], // Puerto Rico
|
|
333
|
+
PY: ['es-PY'], // Paraguay
|
|
334
|
+
SV: ['es-SV'], // El Salvador
|
|
335
|
+
UY: ['es-UY'], // Uruguay
|
|
336
|
+
BO: ['es-BO'], // Bolivia
|
|
337
|
+
GQ: ['es-GQ'], // Equatorial Guinea
|
|
338
|
+
// French variants
|
|
339
|
+
FR: ['fr-FR'], // France
|
|
340
|
+
MC: ['fr-MC'], // Monaco
|
|
341
|
+
// Multi-language - French/Dutch/German
|
|
342
|
+
BE: ['nl-BE', 'fr-BE', 'de-BE'], // Belgium: Dutch, French, German
|
|
343
|
+
CH: ['de-CH', 'fr-CH', 'it-CH', 'rm-CH'], // Switzerland: German, French, Italian, Romansh
|
|
344
|
+
LU: ['lb-LU', 'fr-LU', 'de-LU'], // Luxembourg: Luxembourgish, French, German
|
|
345
|
+
// Portuguese variants
|
|
346
|
+
PT: ['pt-PT'], // Portugal
|
|
347
|
+
BR: ['pt-BR'], // Brazil
|
|
348
|
+
AO: ['pt-AO'], // Angola
|
|
349
|
+
MZ: ['pt-MZ'], // Mozambique
|
|
350
|
+
CV: ['pt-CV'], // Cape Verde
|
|
351
|
+
GW: ['pt-GW'], // Guinea-Bissau
|
|
352
|
+
ST: ['pt-ST'], // São Tomé and Príncipe
|
|
353
|
+
TL: ['pt-TL'], // Timor-Leste
|
|
354
|
+
// German variants
|
|
355
|
+
DE: ['de-DE'], // Germany
|
|
356
|
+
AT: ['de-AT'], // Austria
|
|
357
|
+
LI: ['de-LI'], // Liechtenstein
|
|
358
|
+
// Dutch variants
|
|
359
|
+
NL: ['nl-NL'], // Netherlands
|
|
360
|
+
SR: ['nl-SR'], // Suriname
|
|
361
|
+
AW: ['nl-AW'], // Aruba
|
|
362
|
+
CW: ['nl-CW'], // Curaçao
|
|
363
|
+
BQ: ['nl-BQ'], // Bonaire, Sint Eustatius and Saba
|
|
364
|
+
SX: ['nl-SX'], // Sint Maarten
|
|
365
|
+
// Chinese variants
|
|
366
|
+
CN: ['zh-CN'], // China (Simplified)
|
|
367
|
+
TW: ['zh-TW'], // Taiwan (Traditional)
|
|
368
|
+
MO: ['zh-MO'], // Macau (Traditional)
|
|
369
|
+
// Arabic variants
|
|
370
|
+
SA: ['ar-SA'], // Saudi Arabia
|
|
371
|
+
EG: ['ar-EG'], // Egypt
|
|
372
|
+
AE: ['ar-AE'], // United Arab Emirates
|
|
373
|
+
DZ: ['ar-DZ'], // Algeria
|
|
374
|
+
MA: ['ar-MA'], // Morocco
|
|
375
|
+
TN: ['ar-TN'], // Tunisia
|
|
376
|
+
IQ: ['ar-IQ'], // Iraq
|
|
377
|
+
JO: ['ar-JO'], // Jordan
|
|
378
|
+
KW: ['ar-KW'], // Kuwait
|
|
379
|
+
LB: ['ar-LB'], // Lebanon
|
|
380
|
+
LY: ['ar-LY'], // Libya
|
|
381
|
+
OM: ['ar-OM'], // Oman
|
|
382
|
+
PS: ['ar-PS'], // Palestine
|
|
383
|
+
QA: ['ar-QA'], // Qatar
|
|
384
|
+
SY: ['ar-SY'], // Syria
|
|
385
|
+
YE: ['ar-YE'], // Yemen
|
|
386
|
+
BH: ['ar-BH'], // Bahrain
|
|
387
|
+
SD: ['ar-SD'], // Sudan
|
|
388
|
+
MR: ['ar-MR'], // Mauritania
|
|
389
|
+
KM: ['ar-KM'], // Comoros
|
|
390
|
+
// Other major languages with regional variants
|
|
391
|
+
IT: ['it-IT'], // Italy
|
|
392
|
+
SM: ['it-SM'], // San Marino
|
|
393
|
+
VA: ['it-VA'], // Vatican City
|
|
394
|
+
RU: ['ru-RU'], // Russia
|
|
395
|
+
JP: ['ja-JP'], // Japan
|
|
396
|
+
KR: ['ko-KR'], // South Korea
|
|
397
|
+
KP: ['ko-KP'], // North Korea
|
|
398
|
+
TR: ['tr-TR'], // Turkey
|
|
399
|
+
PL: ['pl-PL'], // Poland
|
|
400
|
+
SE: ['sv-SE'], // Sweden
|
|
401
|
+
AX: ['sv-AX'], // Åland Islands
|
|
402
|
+
FI: ['fi-FI', 'sv-FI'], // Finland: Finnish, Swedish
|
|
403
|
+
NO: ['no-NO'], // Norway
|
|
404
|
+
DK: ['da-DK'], // Denmark
|
|
405
|
+
GR: ['el-GR'], // Greece
|
|
406
|
+
CY: ['el-CY', 'tr-CY'], // Cyprus: Greek, Turkish
|
|
407
|
+
CZ: ['cs-CZ'], // Czech Republic
|
|
408
|
+
HU: ['hu-HU'], // Hungary
|
|
409
|
+
RO: ['ro-RO'], // Romania
|
|
410
|
+
MD: ['ro-MD'], // Moldova
|
|
411
|
+
HR: ['hr-HR'], // Croatia
|
|
412
|
+
TH: ['th-TH'], // Thailand
|
|
413
|
+
VN: ['vi-VN'], // Vietnam
|
|
414
|
+
ID: ['id-ID'], // Indonesia
|
|
415
|
+
MY: ['ms-MY'], // Malaysia
|
|
416
|
+
BN: ['ms-BN'], // Brunei
|
|
417
|
+
UA: ['uk-UA'], // Ukraine
|
|
418
|
+
BG: ['bg-BG'], // Bulgaria
|
|
419
|
+
SK: ['sk-SK'], // Slovakia
|
|
420
|
+
SI: ['sl-SI'], // Slovenia
|
|
421
|
+
LT: ['lt-LT'], // Lithuania
|
|
422
|
+
LV: ['lv-LV'], // Latvia
|
|
423
|
+
EE: ['et-EE'], // Estonia
|
|
424
|
+
IS: ['is-IS'], // Iceland
|
|
425
|
+
RS: ['sr-RS'], // Serbia
|
|
426
|
+
ME: ['sr-ME'], // Montenegro
|
|
427
|
+
BA: ['bs-BA'], // Bosnia and Herzegovina
|
|
428
|
+
MK: ['mk-MK'], // North Macedonia
|
|
429
|
+
AL: ['sq-AL'], // Albania
|
|
430
|
+
XK: ['sq-XK'], // Kosovo
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* Gets all language locales for a given country code
|
|
434
|
+
* Returns an array of all official or widely-spoken language variants
|
|
435
|
+
* First locale in array is the primary/most common language
|
|
436
|
+
*
|
|
437
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
438
|
+
* @returns Array of language-country locale codes
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```typescript
|
|
442
|
+
* getLocalesFromCountry('BE') // returns ['nl-BE', 'fr-BE', 'de-BE']
|
|
443
|
+
* getLocalesFromCountry('CA') // returns ['en-CA', 'fr-CA']
|
|
444
|
+
* getLocalesFromCountry('CH') // returns ['de-CH', 'fr-CH', 'it-CH', 'rm-CH']
|
|
445
|
+
* getLocalesFromCountry('US') // returns ['en-US']
|
|
446
|
+
* getLocalesFromCountry('DE') // returns ['de-DE']
|
|
447
|
+
* getLocalesFromCountry('XX') // returns ['en'] (fallback)
|
|
448
|
+
* ```
|
|
449
|
+
*/
|
|
450
|
+
const getLocalesFromCountry = (countryCode) => {
|
|
451
|
+
if (!countryCode) {
|
|
452
|
+
return ['en'];
|
|
453
|
+
}
|
|
454
|
+
// Check if we have a locale mapping
|
|
455
|
+
if (exports.COUNTRY_TO_LOCALES_MAP[countryCode.toUpperCase()]) {
|
|
456
|
+
return exports.COUNTRY_TO_LOCALES_MAP[countryCode.toUpperCase()];
|
|
457
|
+
}
|
|
458
|
+
return ['en'];
|
|
459
|
+
};
|
|
460
|
+
exports.getLocalesFromCountry = getLocalesFromCountry;
|
|
461
|
+
/**
|
|
462
|
+
* Gets the primary language locale for a given country code
|
|
463
|
+
* Returns the first (primary) locale from the country's locale array
|
|
464
|
+
* Returns format: language-COUNTRY (e.g., en-US, en-GB, fr-CA, es-MX)
|
|
465
|
+
*
|
|
466
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code (e.g., 'US', 'GB', 'MX')
|
|
467
|
+
* @returns The primary language-country locale code
|
|
468
|
+
*
|
|
469
|
+
* @example
|
|
470
|
+
* ```typescript
|
|
471
|
+
* getLocaleFromCountry('US') // returns 'en-US'
|
|
472
|
+
* getLocaleFromCountry('GB') // returns 'en-GB'
|
|
473
|
+
* getLocaleFromCountry('DE') // returns 'de-DE'
|
|
474
|
+
* getLocaleFromCountry('BE') // returns 'nl-BE' (primary language)
|
|
475
|
+
* getLocaleFromCountry('XX') // returns 'en' (fallback)
|
|
476
|
+
* ```
|
|
477
|
+
*/
|
|
478
|
+
const getLocaleFromCountry = (countryCode) => {
|
|
479
|
+
const locales = (0, exports.getLocalesFromCountry)(countryCode);
|
|
480
|
+
return locales[0];
|
|
481
|
+
};
|
|
482
|
+
exports.getLocaleFromCountry = getLocaleFromCountry;
|
|
483
|
+
/**
|
|
484
|
+
* Comprehensive mapping of language codes to their English names
|
|
485
|
+
* Includes currently supported languages and potential future additions
|
|
486
|
+
*/
|
|
487
|
+
exports.ENGLISH_LANGUAGE_NAMES = {
|
|
488
|
+
de: 'German',
|
|
489
|
+
en: 'English',
|
|
490
|
+
fr: 'French',
|
|
491
|
+
it: 'Italian',
|
|
492
|
+
es: 'Spanish',
|
|
493
|
+
nl: 'Dutch',
|
|
494
|
+
pl: 'Polish',
|
|
495
|
+
cs: 'Czech',
|
|
496
|
+
hu: 'Hungarian',
|
|
497
|
+
hr: 'Croatian',
|
|
498
|
+
ro: 'Romanian',
|
|
499
|
+
el: 'Greek',
|
|
500
|
+
pt: 'Portuguese',
|
|
501
|
+
ar: 'Arabic',
|
|
502
|
+
zh: 'Chinese',
|
|
503
|
+
ja: 'Japanese',
|
|
504
|
+
ko: 'Korean',
|
|
505
|
+
ru: 'Russian',
|
|
506
|
+
tr: 'Turkish',
|
|
507
|
+
hi: 'Hindi',
|
|
508
|
+
// Nordic & Regional
|
|
509
|
+
sv: 'Swedish',
|
|
510
|
+
no: 'Norwegian',
|
|
511
|
+
da: 'Danish',
|
|
512
|
+
fi: 'Finnish',
|
|
513
|
+
uk: 'Ukrainian',
|
|
514
|
+
he: 'Hebrew',
|
|
515
|
+
// Asian Markets
|
|
516
|
+
th: 'Thai',
|
|
517
|
+
vi: 'Vietnamese',
|
|
518
|
+
id: 'Indonesian',
|
|
519
|
+
ms: 'Malay',
|
|
520
|
+
tl: 'Tagalog',
|
|
521
|
+
// European Languages
|
|
522
|
+
is: 'Icelandic',
|
|
523
|
+
et: 'Estonian',
|
|
524
|
+
lv: 'Latvian',
|
|
525
|
+
lt: 'Lithuanian',
|
|
526
|
+
sk: 'Slovak',
|
|
527
|
+
sl: 'Slovenian',
|
|
528
|
+
sq: 'Albanian',
|
|
529
|
+
mk: 'Macedonian',
|
|
530
|
+
sr: 'Serbian',
|
|
531
|
+
bs: 'Bosnian',
|
|
532
|
+
bg: 'Bulgarian',
|
|
533
|
+
be: 'Belarusian',
|
|
534
|
+
mt: 'Maltese',
|
|
535
|
+
ga: 'Irish',
|
|
536
|
+
cy: 'Welsh',
|
|
537
|
+
gd: 'Scottish Gaelic',
|
|
538
|
+
fo: 'Faroese',
|
|
539
|
+
lb: 'Luxembourgish',
|
|
540
|
+
// Asian & Middle Eastern Languages
|
|
541
|
+
bn: 'Bengali',
|
|
542
|
+
ur: 'Urdu',
|
|
543
|
+
fa: 'Persian',
|
|
544
|
+
ps: 'Pashto',
|
|
545
|
+
ku: 'Kurdish',
|
|
546
|
+
hy: 'Armenian',
|
|
547
|
+
ka: 'Georgian',
|
|
548
|
+
az: 'Azerbaijani',
|
|
549
|
+
kk: 'Kazakh',
|
|
550
|
+
uz: 'Uzbek',
|
|
551
|
+
tk: 'Turkmen',
|
|
552
|
+
ky: 'Kyrgyz',
|
|
553
|
+
tg: 'Tajik',
|
|
554
|
+
mn: 'Mongolian',
|
|
555
|
+
km: 'Khmer',
|
|
556
|
+
lo: 'Lao',
|
|
557
|
+
my: 'Burmese',
|
|
558
|
+
ne: 'Nepali',
|
|
559
|
+
si: 'Sinhala',
|
|
560
|
+
ta: 'Tamil',
|
|
561
|
+
dv: 'Dhivehi',
|
|
562
|
+
dz: 'Dzongkha',
|
|
563
|
+
// African Languages
|
|
564
|
+
sw: 'Swahili',
|
|
565
|
+
am: 'Amharic',
|
|
566
|
+
ti: 'Tigrinya',
|
|
567
|
+
so: 'Somali',
|
|
568
|
+
ha: 'Hausa',
|
|
569
|
+
yo: 'Yoruba',
|
|
570
|
+
ig: 'Igbo',
|
|
571
|
+
zu: 'Zulu',
|
|
572
|
+
xh: 'Xhosa',
|
|
573
|
+
af: 'Afrikaans',
|
|
574
|
+
mg: 'Malagasy',
|
|
575
|
+
// Oceania Languages
|
|
576
|
+
mi: 'Māori',
|
|
577
|
+
sm: 'Samoan',
|
|
578
|
+
to: 'Tongan',
|
|
579
|
+
fj: 'Fijian',
|
|
580
|
+
// Additional
|
|
581
|
+
ht: 'Haitian Creole',
|
|
582
|
+
};
|
|
583
|
+
/**
|
|
584
|
+
* Gets the language name in English for a given language code
|
|
585
|
+
*
|
|
586
|
+
* @param lang - Language code (ISO 639-1)
|
|
587
|
+
* @returns The English name of the language
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* ```typescript
|
|
591
|
+
* getLanguageName('de') // returns 'German'
|
|
592
|
+
* getLanguageName('fr') // returns 'French'
|
|
593
|
+
* ```
|
|
594
|
+
*/
|
|
595
|
+
const getLanguageName = (lang) => {
|
|
596
|
+
return exports.ENGLISH_LANGUAGE_NAMES[lang.toLowerCase()] || undefined;
|
|
597
|
+
};
|
|
598
|
+
exports.getLanguageName = getLanguageName;
|
|
599
|
+
/**
|
|
600
|
+
* Comprehensive mapping of language codes to their native names
|
|
601
|
+
* Includes currently supported languages and potential future additions
|
|
602
|
+
*/
|
|
603
|
+
exports.NATIVE_LANGUAGE_NAMES = {
|
|
604
|
+
de: 'Deutsch', // German
|
|
605
|
+
en: 'English', // English
|
|
606
|
+
fr: 'Français', // French
|
|
607
|
+
it: 'Italiano', // Italian
|
|
608
|
+
es: 'Español', // Spanish
|
|
609
|
+
nl: 'Nederlands', // Dutch
|
|
610
|
+
pl: 'Polski', // Polish
|
|
611
|
+
cs: 'Čeština', // Czech
|
|
612
|
+
hu: 'Magyar', // Hungarian
|
|
613
|
+
hr: 'Hrvatski', // Croatian
|
|
614
|
+
ro: 'Română', // Romanian
|
|
615
|
+
el: 'Ελληνικά', // Greek
|
|
616
|
+
// High Priority - Phase 2 (8 languages)
|
|
617
|
+
pt: 'Português', // Portuguese
|
|
618
|
+
ar: 'العربية', // Arabic
|
|
619
|
+
zh: '中文', // Chinese
|
|
620
|
+
ja: '日本語', // Japanese
|
|
621
|
+
ko: '한국어', // Korean
|
|
622
|
+
ru: 'Русский', // Russian
|
|
623
|
+
tr: 'Türkçe', // Turkish
|
|
624
|
+
hi: 'हिन्दी', // Hindi
|
|
625
|
+
// Medium Priority - Phase 3 (Nordic & Regional)
|
|
626
|
+
sv: 'Svenska', // Swedish
|
|
627
|
+
no: 'Norsk', // Norwegian
|
|
628
|
+
da: 'Dansk', // Danish
|
|
629
|
+
fi: 'Suomi', // Finnish
|
|
630
|
+
uk: 'Українська', // Ukrainian
|
|
631
|
+
he: 'עברית', // Hebrew
|
|
632
|
+
// Medium Priority - Phase 4 (Asian Markets)
|
|
633
|
+
th: 'ไทย', // Thai
|
|
634
|
+
vi: 'Tiếng Việt', // Vietnamese
|
|
635
|
+
id: 'Bahasa Indonesia', // Indonesian
|
|
636
|
+
ms: 'Bahasa Melayu', // Malay
|
|
637
|
+
tl: 'Tagalog', // Tagalog/Filipino
|
|
638
|
+
// Additional European Languages
|
|
639
|
+
is: 'Íslenska', // Icelandic
|
|
640
|
+
et: 'Eesti', // Estonian
|
|
641
|
+
lv: 'Latviešu', // Latvian
|
|
642
|
+
lt: 'Lietuvių', // Lithuanian
|
|
643
|
+
sk: 'Slovenčina', // Slovak
|
|
644
|
+
sl: 'Slovenščina', // Slovenian
|
|
645
|
+
sq: 'Shqip', // Albanian
|
|
646
|
+
mk: 'Македонски', // Macedonian
|
|
647
|
+
sr: 'Српски', // Serbian
|
|
648
|
+
bs: 'Bosanski', // Bosnian
|
|
649
|
+
bg: 'Български', // Bulgarian
|
|
650
|
+
be: 'Беларуская', // Belarusian
|
|
651
|
+
mt: 'Malti', // Maltese
|
|
652
|
+
ga: 'Gaeilge', // Irish
|
|
653
|
+
cy: 'Cymraeg', // Welsh
|
|
654
|
+
gd: 'Gàidhlig', // Scottish Gaelic
|
|
655
|
+
fo: 'Føroyskt', // Faroese
|
|
656
|
+
lb: 'Lëtzebuergesch', // Luxembourgish
|
|
657
|
+
// Additional Asian & Middle Eastern Languages
|
|
658
|
+
bn: 'বাংলা', // Bengali
|
|
659
|
+
ur: 'اردو', // Urdu
|
|
660
|
+
fa: 'فارسی', // Persian
|
|
661
|
+
ps: 'پښتو', // Pashto
|
|
662
|
+
ku: 'Kurdî', // Kurdish
|
|
663
|
+
hy: 'Հայերեն', // Armenian
|
|
664
|
+
ka: 'ქართული', // Georgian
|
|
665
|
+
az: 'Azərbaycan', // Azerbaijani
|
|
666
|
+
kk: 'Қазақша', // Kazakh
|
|
667
|
+
uz: 'Oʻzbek', // Uzbek
|
|
668
|
+
tk: 'Türkmen', // Turkmen
|
|
669
|
+
ky: 'Кыргызча', // Kyrgyz
|
|
670
|
+
tg: 'Тоҷикӣ', // Tajik
|
|
671
|
+
mn: 'Монгол', // Mongolian
|
|
672
|
+
km: 'ខ្មែរ', // Khmer
|
|
673
|
+
lo: 'ລາວ', // Lao
|
|
674
|
+
my: 'မြန်မာ', // Burmese
|
|
675
|
+
ne: 'नेपाली', // Nepali
|
|
676
|
+
si: 'සිංහල', // Sinhala
|
|
677
|
+
ta: 'தமிழ்', // Tamil
|
|
678
|
+
dv: 'ދިވެހި', // Dhivehi
|
|
679
|
+
dz: 'རྫོང་ཁ', // Dzongkha
|
|
680
|
+
// African Languages
|
|
681
|
+
sw: 'Kiswahili', // Swahili
|
|
682
|
+
am: 'አማርኛ', // Amharic
|
|
683
|
+
ti: 'ትግርኛ', // Tigrinya
|
|
684
|
+
so: 'Soomaali', // Somali
|
|
685
|
+
ha: 'Hausa', // Hausa
|
|
686
|
+
yo: 'Yorùbá', // Yoruba
|
|
687
|
+
ig: 'Igbo', // Igbo
|
|
688
|
+
zu: 'isiZulu', // Zulu
|
|
689
|
+
xh: 'isiXhosa', // Xhosa
|
|
690
|
+
af: 'Afrikaans', // Afrikaans
|
|
691
|
+
mg: 'Malagasy', // Malagasy
|
|
692
|
+
// Oceania Languages
|
|
693
|
+
mi: 'Te Reo Māori', // Māori
|
|
694
|
+
sm: 'Gagana Samoa', // Samoan
|
|
695
|
+
to: 'Lea Faka-Tonga', // Tongan
|
|
696
|
+
fj: 'Na Vosa Vakaviti', // Fijian
|
|
697
|
+
// Additional
|
|
698
|
+
ht: 'Kreyòl', // Haitian Creole
|
|
699
|
+
};
|
|
700
|
+
/**
|
|
701
|
+
* Gets the native language name for a given language code
|
|
702
|
+
*
|
|
703
|
+
* @param lang - Language code (ISO 639-1)
|
|
704
|
+
* @returns The native name of the language
|
|
705
|
+
*
|
|
706
|
+
* @example
|
|
707
|
+
* ```typescript
|
|
708
|
+
* getNativeLanguageName('de') // returns 'Deutsch'
|
|
709
|
+
* ```
|
|
710
|
+
*/
|
|
711
|
+
const getNativeLanguageName = (lang) => {
|
|
712
|
+
return exports.NATIVE_LANGUAGE_NAMES[lang] || undefined;
|
|
713
|
+
};
|
|
714
|
+
exports.getNativeLanguageName = getNativeLanguageName;
|
|
715
|
+
/**
|
|
716
|
+
* Comprehensive mapping of ISO 3166-1 alpha-2 country codes to English country names
|
|
717
|
+
*/
|
|
718
|
+
exports.COUNTRY_NAMES = {
|
|
719
|
+
// Europe
|
|
720
|
+
AD: 'Andorra',
|
|
721
|
+
AL: 'Albania',
|
|
722
|
+
AT: 'Austria',
|
|
723
|
+
AX: 'Åland Islands',
|
|
724
|
+
BA: 'Bosnia and Herzegovina',
|
|
725
|
+
BE: 'Belgium',
|
|
726
|
+
BG: 'Bulgaria',
|
|
727
|
+
BY: 'Belarus',
|
|
728
|
+
CH: 'Switzerland',
|
|
729
|
+
CY: 'Cyprus',
|
|
730
|
+
CZ: 'Czechia',
|
|
731
|
+
DE: 'Germany',
|
|
732
|
+
DK: 'Denmark',
|
|
733
|
+
EE: 'Estonia',
|
|
734
|
+
ES: 'Spain',
|
|
735
|
+
FI: 'Finland',
|
|
736
|
+
FO: 'Faroe Islands',
|
|
737
|
+
FR: 'France',
|
|
738
|
+
GB: 'United Kingdom',
|
|
739
|
+
GG: 'Guernsey',
|
|
740
|
+
GI: 'Gibraltar',
|
|
741
|
+
GL: 'Greenland',
|
|
742
|
+
GR: 'Greece',
|
|
743
|
+
HR: 'Croatia',
|
|
744
|
+
HU: 'Hungary',
|
|
745
|
+
IE: 'Ireland',
|
|
746
|
+
IM: 'Isle of Man',
|
|
747
|
+
IS: 'Iceland',
|
|
748
|
+
IT: 'Italy',
|
|
749
|
+
JE: 'Jersey',
|
|
750
|
+
LI: 'Liechtenstein',
|
|
751
|
+
LT: 'Lithuania',
|
|
752
|
+
LU: 'Luxembourg',
|
|
753
|
+
LV: 'Latvia',
|
|
754
|
+
MC: 'Monaco',
|
|
755
|
+
MD: 'Moldova',
|
|
756
|
+
ME: 'Montenegro',
|
|
757
|
+
MK: 'North Macedonia',
|
|
758
|
+
MT: 'Malta',
|
|
759
|
+
NL: 'Netherlands',
|
|
760
|
+
NO: 'Norway',
|
|
761
|
+
PL: 'Poland',
|
|
762
|
+
PT: 'Portugal',
|
|
763
|
+
RO: 'Romania',
|
|
764
|
+
RS: 'Serbia',
|
|
765
|
+
RU: 'Russia',
|
|
766
|
+
SE: 'Sweden',
|
|
767
|
+
SI: 'Slovenia',
|
|
768
|
+
SJ: 'Svalbard and Jan Mayen',
|
|
769
|
+
SK: 'Slovakia',
|
|
770
|
+
SM: 'San Marino',
|
|
771
|
+
TR: 'Turkey',
|
|
772
|
+
UA: 'Ukraine',
|
|
773
|
+
VA: 'Vatican City',
|
|
774
|
+
XK: 'Kosovo',
|
|
775
|
+
// Americas
|
|
776
|
+
AG: 'Antigua and Barbuda',
|
|
777
|
+
AI: 'Anguilla',
|
|
778
|
+
AR: 'Argentina',
|
|
779
|
+
AS: 'American Samoa',
|
|
780
|
+
AW: 'Aruba',
|
|
781
|
+
BB: 'Barbados',
|
|
782
|
+
BL: 'Saint Barthélemy',
|
|
783
|
+
BM: 'Bermuda',
|
|
784
|
+
BO: 'Bolivia',
|
|
785
|
+
BQ: 'Bonaire, Sint Eustatius and Saba',
|
|
786
|
+
BR: 'Brazil',
|
|
787
|
+
BS: 'Bahamas',
|
|
788
|
+
BZ: 'Belize',
|
|
789
|
+
CA: 'Canada',
|
|
790
|
+
CL: 'Chile',
|
|
791
|
+
CO: 'Colombia',
|
|
792
|
+
CR: 'Costa Rica',
|
|
793
|
+
CU: 'Cuba',
|
|
794
|
+
CW: 'Curaçao',
|
|
795
|
+
DM: 'Dominica',
|
|
796
|
+
DO: 'Dominican Republic',
|
|
797
|
+
EC: 'Ecuador',
|
|
798
|
+
FK: 'Falkland Islands',
|
|
799
|
+
GD: 'Grenada',
|
|
800
|
+
GF: 'French Guiana',
|
|
801
|
+
GP: 'Guadeloupe',
|
|
802
|
+
GT: 'Guatemala',
|
|
803
|
+
GY: 'Guyana',
|
|
804
|
+
HN: 'Honduras',
|
|
805
|
+
HT: 'Haiti',
|
|
806
|
+
JM: 'Jamaica',
|
|
807
|
+
KN: 'Saint Kitts and Nevis',
|
|
808
|
+
KY: 'Cayman Islands',
|
|
809
|
+
LC: 'Saint Lucia',
|
|
810
|
+
MF: 'Saint Martin',
|
|
811
|
+
MQ: 'Martinique',
|
|
812
|
+
MS: 'Montserrat',
|
|
813
|
+
MX: 'Mexico',
|
|
814
|
+
NI: 'Nicaragua',
|
|
815
|
+
PA: 'Panama',
|
|
816
|
+
PE: 'Peru',
|
|
817
|
+
PM: 'Saint Pierre and Miquelon',
|
|
818
|
+
PR: 'Puerto Rico',
|
|
819
|
+
PY: 'Paraguay',
|
|
820
|
+
SR: 'Suriname',
|
|
821
|
+
SV: 'El Salvador',
|
|
822
|
+
SX: 'Sint Maarten',
|
|
823
|
+
TC: 'Turks and Caicos Islands',
|
|
824
|
+
TT: 'Trinidad and Tobago',
|
|
825
|
+
US: 'United States',
|
|
826
|
+
UY: 'Uruguay',
|
|
827
|
+
VC: 'Saint Vincent and the Grenadines',
|
|
828
|
+
VE: 'Venezuela',
|
|
829
|
+
VG: 'British Virgin Islands',
|
|
830
|
+
VI: 'U.S. Virgin Islands',
|
|
831
|
+
// Asia & Oceania
|
|
832
|
+
AE: 'United Arab Emirates',
|
|
833
|
+
AF: 'Afghanistan',
|
|
834
|
+
AM: 'Armenia',
|
|
835
|
+
AU: 'Australia',
|
|
836
|
+
AZ: 'Azerbaijan',
|
|
837
|
+
BD: 'Bangladesh',
|
|
838
|
+
BH: 'Bahrain',
|
|
839
|
+
BN: 'Brunei',
|
|
840
|
+
BT: 'Bhutan',
|
|
841
|
+
CC: 'Cocos Islands',
|
|
842
|
+
CN: 'China',
|
|
843
|
+
CX: 'Christmas Island',
|
|
844
|
+
GE: 'Georgia',
|
|
845
|
+
HK: 'Hong Kong',
|
|
846
|
+
ID: 'Indonesia',
|
|
847
|
+
IL: 'Israel',
|
|
848
|
+
IN: 'India',
|
|
849
|
+
IO: 'British Indian Ocean Territory',
|
|
850
|
+
IQ: 'Iraq',
|
|
851
|
+
IR: 'Iran',
|
|
852
|
+
JO: 'Jordan',
|
|
853
|
+
JP: 'Japan',
|
|
854
|
+
KG: 'Kyrgyzstan',
|
|
855
|
+
KH: 'Cambodia',
|
|
856
|
+
KP: 'North Korea',
|
|
857
|
+
KR: 'South Korea',
|
|
858
|
+
KW: 'Kuwait',
|
|
859
|
+
KZ: 'Kazakhstan',
|
|
860
|
+
LA: 'Laos',
|
|
861
|
+
LB: 'Lebanon',
|
|
862
|
+
LK: 'Sri Lanka',
|
|
863
|
+
MM: 'Myanmar',
|
|
864
|
+
MN: 'Mongolia',
|
|
865
|
+
MO: 'Macau',
|
|
866
|
+
MV: 'Maldives',
|
|
867
|
+
MY: 'Malaysia',
|
|
868
|
+
NP: 'Nepal',
|
|
869
|
+
NZ: 'New Zealand',
|
|
870
|
+
OM: 'Oman',
|
|
871
|
+
PH: 'Philippines',
|
|
872
|
+
PK: 'Pakistan',
|
|
873
|
+
PS: 'Palestine',
|
|
874
|
+
QA: 'Qatar',
|
|
875
|
+
SA: 'Saudi Arabia',
|
|
876
|
+
SG: 'Singapore',
|
|
877
|
+
SY: 'Syria',
|
|
878
|
+
TH: 'Thailand',
|
|
879
|
+
TJ: 'Tajikistan',
|
|
880
|
+
TL: 'Timor-Leste',
|
|
881
|
+
TM: 'Turkmenistan',
|
|
882
|
+
TW: 'Taiwan',
|
|
883
|
+
UZ: 'Uzbekistan',
|
|
884
|
+
VN: 'Vietnam',
|
|
885
|
+
YE: 'Yemen',
|
|
886
|
+
// Africa
|
|
887
|
+
AO: 'Angola',
|
|
888
|
+
BF: 'Burkina Faso',
|
|
889
|
+
BI: 'Burundi',
|
|
890
|
+
BJ: 'Benin',
|
|
891
|
+
BW: 'Botswana',
|
|
892
|
+
CD: 'Democratic Republic of the Congo',
|
|
893
|
+
CF: 'Central African Republic',
|
|
894
|
+
CG: 'Congo',
|
|
895
|
+
CI: "Côte d'Ivoire",
|
|
896
|
+
CM: 'Cameroon',
|
|
897
|
+
CV: 'Cape Verde',
|
|
898
|
+
DJ: 'Djibouti',
|
|
899
|
+
DZ: 'Algeria',
|
|
900
|
+
EG: 'Egypt',
|
|
901
|
+
ER: 'Eritrea',
|
|
902
|
+
ET: 'Ethiopia',
|
|
903
|
+
GA: 'Gabon',
|
|
904
|
+
GH: 'Ghana',
|
|
905
|
+
GM: 'Gambia',
|
|
906
|
+
GN: 'Guinea',
|
|
907
|
+
GQ: 'Equatorial Guinea',
|
|
908
|
+
GW: 'Guinea-Bissau',
|
|
909
|
+
KE: 'Kenya',
|
|
910
|
+
KM: 'Comoros',
|
|
911
|
+
LR: 'Liberia',
|
|
912
|
+
LS: 'Lesotho',
|
|
913
|
+
LY: 'Libya',
|
|
914
|
+
MA: 'Morocco',
|
|
915
|
+
MG: 'Madagascar',
|
|
916
|
+
ML: 'Mali',
|
|
917
|
+
MR: 'Mauritania',
|
|
918
|
+
MU: 'Mauritius',
|
|
919
|
+
MW: 'Malawi',
|
|
920
|
+
MZ: 'Mozambique',
|
|
921
|
+
NA: 'Namibia',
|
|
922
|
+
NE: 'Niger',
|
|
923
|
+
NG: 'Nigeria',
|
|
924
|
+
RE: 'Réunion',
|
|
925
|
+
RW: 'Rwanda',
|
|
926
|
+
SC: 'Seychelles',
|
|
927
|
+
SD: 'Sudan',
|
|
928
|
+
SH: 'Saint Helena, Ascension and Tristan da Cunha',
|
|
929
|
+
SL: 'Sierra Leone',
|
|
930
|
+
SN: 'Senegal',
|
|
931
|
+
SO: 'Somalia',
|
|
932
|
+
SS: 'South Sudan',
|
|
933
|
+
ST: 'São Tomé and Príncipe',
|
|
934
|
+
SZ: 'Eswatini',
|
|
935
|
+
TD: 'Chad',
|
|
936
|
+
TG: 'Togo',
|
|
937
|
+
TN: 'Tunisia',
|
|
938
|
+
TZ: 'Tanzania',
|
|
939
|
+
UG: 'Uganda',
|
|
940
|
+
YT: 'Mayotte',
|
|
941
|
+
ZA: 'South Africa',
|
|
942
|
+
ZM: 'Zambia',
|
|
943
|
+
ZW: 'Zimbabwe',
|
|
944
|
+
// Oceania
|
|
945
|
+
CK: 'Cook Islands',
|
|
946
|
+
FJ: 'Fiji',
|
|
947
|
+
FM: 'Micronesia',
|
|
948
|
+
GU: 'Guam',
|
|
949
|
+
KI: 'Kiribati',
|
|
950
|
+
MH: 'Marshall Islands',
|
|
951
|
+
MP: 'Northern Mariana Islands',
|
|
952
|
+
NC: 'New Caledonia',
|
|
953
|
+
NF: 'Norfolk Island',
|
|
954
|
+
NR: 'Nauru',
|
|
955
|
+
NU: 'Niue',
|
|
956
|
+
PF: 'French Polynesia',
|
|
957
|
+
PG: 'Papua New Guinea',
|
|
958
|
+
PN: 'Pitcairn Islands',
|
|
959
|
+
PW: 'Palau',
|
|
960
|
+
SB: 'Solomon Islands',
|
|
961
|
+
TK: 'Tokelau',
|
|
962
|
+
TO: 'Tonga',
|
|
963
|
+
TV: 'Tuvalu',
|
|
964
|
+
UM: 'U.S. Minor Outlying Islands',
|
|
965
|
+
VU: 'Vanuatu',
|
|
966
|
+
WF: 'Wallis and Futuna',
|
|
967
|
+
WS: 'Samoa',
|
|
968
|
+
// Antarctica
|
|
969
|
+
AQ: 'Antarctica',
|
|
970
|
+
BV: 'Bouvet Island',
|
|
971
|
+
GS: 'South Georgia and the South Sandwich Islands',
|
|
972
|
+
HM: 'Heard Island and McDonald Islands',
|
|
973
|
+
TF: 'French Southern Territories',
|
|
974
|
+
};
|
|
975
|
+
/**
|
|
976
|
+
* Gets the country name for a given country code
|
|
977
|
+
*
|
|
978
|
+
* @param countryCode - ISO 3166-1 alpha-2 country code
|
|
979
|
+
* @returns The English name of the country, or the country code if unknown
|
|
980
|
+
*
|
|
981
|
+
* @example
|
|
982
|
+
* ```typescript
|
|
983
|
+
* getCountryName('DE') // returns 'Germany'
|
|
984
|
+
* ```
|
|
985
|
+
*/
|
|
986
|
+
const getCountryName = (countryCode) => {
|
|
987
|
+
return exports.COUNTRY_NAMES[countryCode.toUpperCase()] || undefined;
|
|
988
|
+
};
|
|
989
|
+
exports.getCountryName = getCountryName;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lucaapp/service-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"swagger-ui-express": "5.0.1",
|
|
56
56
|
"url-value-parser": "^2.2.0",
|
|
57
57
|
"uuid": "^9.0.0",
|
|
58
|
-
"validator": "
|
|
58
|
+
"validator": "13.15.23",
|
|
59
59
|
"zod": "3.22.3"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
@@ -95,8 +95,6 @@
|
|
|
95
95
|
"axios": "^1.12.2",
|
|
96
96
|
"vite": "6.2.5",
|
|
97
97
|
"tar-fs": "2.1.4",
|
|
98
|
-
"js-yaml": "4.1.1"
|
|
99
|
-
"brace-expansion": "2.0.2",
|
|
100
|
-
"validator": "^13.15.20"
|
|
98
|
+
"js-yaml": "4.1.1"
|
|
101
99
|
}
|
|
102
100
|
}
|