generaltranslation 2.0.55 → 2.0.57

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. package/dist/{cjs/codes → codes}/codes.js +71 -67
  2. package/dist/{cjs/codes → codes}/getLanguageDirection.js +5 -5
  3. package/dist/format/_format.js +62 -0
  4. package/dist/{cjs/index.d.ts → index.d.ts} +48 -27
  5. package/dist/index.js +243 -0
  6. package/dist/translation/_translate.js +109 -0
  7. package/dist/{mjs/translation/_bundleTranslation.d.ts → translation/_translateBundle.d.ts} +2 -9
  8. package/dist/translation/_translateBundle.js +95 -0
  9. package/dist/translation/_translateReact.js +107 -0
  10. package/dist/{cjs/translation/_updateRemoteDictionary.d.ts → translation/_updateProjectDictionary.d.ts} +1 -1
  11. package/dist/translation/_updateProjectDictionary.js +83 -0
  12. package/package.json +7 -7
  13. package/dist/cjs/index.js +0 -143
  14. package/dist/cjs/translation/_bundleTranslation.d.ts +0 -22
  15. package/dist/cjs/translation/_bundleTranslation.js +0 -42
  16. package/dist/cjs/translation/_intl.js +0 -52
  17. package/dist/cjs/translation/_translate.js +0 -51
  18. package/dist/cjs/translation/_translateReactChildren.js +0 -56
  19. package/dist/cjs/translation/_updateRemoteDictionary.js +0 -30
  20. package/dist/mjs/codes/15924/CodeToScript.json +0 -215
  21. package/dist/mjs/codes/15924/ScriptToCode.json +0 -215
  22. package/dist/mjs/codes/3166/CodeToRegion.json +0 -296
  23. package/dist/mjs/codes/3166/RegionToCode.json +0 -296
  24. package/dist/mjs/codes/639-1/CodeToLanguage.json +0 -185
  25. package/dist/mjs/codes/639-1/LanguageToCode.json +0 -227
  26. package/dist/mjs/codes/639-3/CodeToLanguageTriletter.json +0 -186
  27. package/dist/mjs/codes/639-3/LanguageToCodeTriletter.json +0 -228
  28. package/dist/mjs/codes/codes.d.ts +0 -8
  29. package/dist/mjs/codes/codes.js +0 -305
  30. package/dist/mjs/codes/getLanguageDirection.d.ts +0 -1
  31. package/dist/mjs/codes/getLanguageDirection.js +0 -68
  32. package/dist/mjs/codes/predefined/Predefined.json +0 -28
  33. package/dist/mjs/index.d.ts +0 -153
  34. package/dist/mjs/index.js +0 -130
  35. package/dist/mjs/translation/_bundleTranslation.js +0 -39
  36. package/dist/mjs/translation/_intl.d.ts +0 -1
  37. package/dist/mjs/translation/_intl.js +0 -49
  38. package/dist/mjs/translation/_translate.d.ts +0 -1
  39. package/dist/mjs/translation/_translate.js +0 -48
  40. package/dist/mjs/translation/_translateReactChildren.d.ts +0 -1
  41. package/dist/mjs/translation/_translateReactChildren.js +0 -53
  42. package/dist/mjs/translation/_updateRemoteDictionary.d.ts +0 -17
  43. package/dist/mjs/translation/_updateRemoteDictionary.js +0 -27
  44. /package/dist/{cjs/codes → codes}/15924/CodeToScript.json +0 -0
  45. /package/dist/{cjs/codes → codes}/15924/ScriptToCode.json +0 -0
  46. /package/dist/{cjs/codes → codes}/3166/CodeToRegion.json +0 -0
  47. /package/dist/{cjs/codes → codes}/3166/RegionToCode.json +0 -0
  48. /package/dist/{cjs/codes → codes}/639-1/CodeToLanguage.json +0 -0
  49. /package/dist/{cjs/codes → codes}/639-1/LanguageToCode.json +0 -0
  50. /package/dist/{cjs/codes → codes}/639-3/CodeToLanguageTriletter.json +0 -0
  51. /package/dist/{cjs/codes → codes}/639-3/LanguageToCodeTriletter.json +0 -0
  52. /package/dist/{cjs/codes → codes}/codes.d.ts +0 -0
  53. /package/dist/{cjs/codes → codes}/getLanguageDirection.d.ts +0 -0
  54. /package/dist/{cjs/codes → codes}/predefined/Predefined.json +0 -0
  55. /package/dist/{cjs/translation/_intl.d.ts → format/_format.d.ts} +0 -0
  56. /package/dist/{cjs/translation → translation}/_translate.d.ts +0 -0
  57. /package/dist/{cjs/translation/_translateReactChildren.d.ts → translation/_translateReact.d.ts} +0 -0
@@ -1,228 +0,0 @@
1
- {
2
- "abkhazian": "abk",
3
- "afar": "aar",
4
- "afrikaans": "afr",
5
- "akan": "aka",
6
- "albanian": "sqi",
7
- "amharic": "amh",
8
- "ancient greek": "grc",
9
- "arabic": "ara",
10
- "aragonese": "arg",
11
- "armenian": "hye",
12
- "assamese": "asm",
13
- "avaric": "ava",
14
- "avestan": "ave",
15
- "aymara": "aym",
16
- "azerbaijani": "aze",
17
- "bambara": "bam",
18
- "bashkir": "bak",
19
- "basque": "eus",
20
- "belarusian": "bel",
21
- "bengali": "ben",
22
- "bislama": "bis",
23
- "bosnian": "bos",
24
- "breton": "bre",
25
- "bulgarian": "bul",
26
- "burmese": "mya",
27
- "catalan": "cat",
28
- "valencian": "cat",
29
- "chamorro": "cha",
30
- "chechen": "che",
31
- "chichewa": "nya",
32
- "chewa": "nya",
33
- "nyanja": "nya",
34
- "chinese": "zho",
35
- "mandarin": "zho",
36
- "church slavonic": "chu",
37
- "old slavonic": "chu",
38
- "old church slavonic": "chu",
39
- "slavonic": "chu",
40
- "chuvash": "chv",
41
- "cornish": "cor",
42
- "corsican": "cos",
43
- "cree": "cre",
44
- "croatian": "hrv",
45
- "czech": "ces",
46
- "danish": "dan",
47
- "divehi": "div",
48
- "dhivehi": "div",
49
- "maldivian": "div",
50
- "dutch": "nld",
51
- "flemish": "nld",
52
- "dzongkha": "dzo",
53
- "english": "eng",
54
- "esperanto": "epo",
55
- "estonian": "est",
56
- "ewe": "ewe",
57
- "faroese": "fao",
58
- "fijian": "fij",
59
- "finnish": "fin",
60
- "french": "fra",
61
- "western frisian": "fry",
62
- "frisian": "fry",
63
- "fulah": "ful",
64
- "gaelic": "gla",
65
- "scottish gaelic": "gla",
66
- "galician": "glg",
67
- "ganda": "lug",
68
- "georgian": "kat",
69
- "german": "deu",
70
- "greek": "ell",
71
- "modern greek": "ell",
72
- "kalaallisut": "kal",
73
- "greenlandic": "kal",
74
- "guarani": "grn",
75
- "gujarati": "guj",
76
- "haitian": "hat",
77
- "haitian creole": "hat",
78
- "hausa": "hau",
79
- "hebrew": "heb",
80
- "herero": "her",
81
- "hindi": "hin",
82
- "hiri motu": "hmo",
83
- "hungarian": "hun",
84
- "icelandic": "isl",
85
- "ido": "ido",
86
- "igbo": "ibo",
87
- "indonesian": "ind",
88
- "interlingua": "ina",
89
- "interlingue": "ile",
90
- "occidental": "ile",
91
- "inuktitut": "iku",
92
- "inupiaq": "ipk",
93
- "irish": "gle",
94
- "italian": "ita",
95
- "japanese": "jpn",
96
- "javanese": "jav",
97
- "kannada": "kan",
98
- "kanuri": "kau",
99
- "kashmiri": "kas",
100
- "kazakh": "kaz",
101
- "central khmer": "khm",
102
- "kikuyu": "kik",
103
- "gikuyu": "kik",
104
- "kinyarwanda": "kin",
105
- "kirghiz": "kir",
106
- "kyrgyz": "kir",
107
- "komi": "kom",
108
- "kongo": "kon",
109
- "korean": "kor",
110
- "kuanyama": "kua",
111
- "kwanyama": "kua",
112
- "kurdish": "kur",
113
- "lao": "lao",
114
- "latin": "lat",
115
- "latvian": "lav",
116
- "limburgan": "lim",
117
- "limburger": "lim",
118
- "limburgish": "lim",
119
- "lingala": "lin",
120
- "lithuanian": "lit",
121
- "luba-katanga": "lub",
122
- "luxembourgish": "ltz",
123
- "letzeburgesch": "ltz",
124
- "macedonian": "mkd",
125
- "malagasy": "mlg",
126
- "malay": "msa",
127
- "malayalam": "mal",
128
- "maltese": "mlt",
129
- "manx": "glv",
130
- "maori": "mri",
131
- "marathi": "mar",
132
- "marshallese": "mah",
133
- "mongolian": "mon",
134
- "nauru": "nau",
135
- "navajo": "nav",
136
- "navaho": "nav",
137
- "north ndebele": "nde",
138
- "south ndebele": "nbl",
139
- "northern ndebele": "nde",
140
- "southern ndebele": "nbl",
141
- "ndonga": "ndo",
142
- "nepali": "nep",
143
- "norwegian": "nor",
144
- "norwegian bokmål": "nob",
145
- "norwegian nynorsk": "nno",
146
- "sichuan yi": "iii",
147
- "nuosu": "iii",
148
- "occitan": "oci",
149
- "ojibwa": "oji",
150
- "ojibwe": "oji",
151
- "oriya": "ori",
152
- "odia": "ori",
153
- "oromo": "orm",
154
- "ossetian": "oss",
155
- "ossetic": "oss",
156
- "pali": "pli",
157
- "pashto": "pus",
158
- "pushto": "pus",
159
- "persian": "fas",
160
- "polish": "pol",
161
- "portuguese": "por",
162
- "punjabi": "pan",
163
- "panjabi": "pan",
164
- "quechua": "que",
165
- "romanian": "ron",
166
- "moldavian": "ron",
167
- "moldovan": "ron",
168
- "romansh": "roh",
169
- "rundi": "run",
170
- "kirundi": "run",
171
- "russian": "rus",
172
- "northern sami": "sme",
173
- "sami": "sme",
174
- "samoan": "smo",
175
- "sango": "sag",
176
- "sanskrit": "san",
177
- "sardinian": "srd",
178
- "serbian": "srp",
179
- "shona": "sna",
180
- "sindhi": "snd",
181
- "sinhala": "sin",
182
- "sinhalese": "sin",
183
- "slovak": "slk",
184
- "slovenian": "slv",
185
- "slovene": "slv",
186
- "somali": "som",
187
- "southern sotho": "sot",
188
- "sotho": "sot",
189
- "spanish": "spa",
190
- "castilian": "spa",
191
- "sundanese": "sun",
192
- "swahili": "swa",
193
- "swati": "ssw",
194
- "swedish": "swe",
195
- "tagalog": "tgl",
196
- "tahitian": "tah",
197
- "tajik": "tgk",
198
- "tamil": "tam",
199
- "tatar": "tat",
200
- "telugu": "tel",
201
- "thai": "tha",
202
- "tibetan": "bod",
203
- "tigrinya": "tir",
204
- "tonga": "ton",
205
- "tongan": "ton",
206
- "tsonga": "tso",
207
- "tswana": "tsn",
208
- "turkish": "tur",
209
- "turkmen": "tuk",
210
- "twi": "twi",
211
- "uighur": "uig",
212
- "uyghur": "uig",
213
- "ukrainian": "ukr",
214
- "urdu": "urd",
215
- "uzbek": "uzb",
216
- "venda": "ven",
217
- "vietnamese": "vie",
218
- "volapük": "vol",
219
- "walloon": "wln",
220
- "welsh": "cym",
221
- "wolof": "wol",
222
- "xhosa": "xho",
223
- "yiddish": "yid",
224
- "yoruba": "yor",
225
- "zhuang": "zha",
226
- "chuang": "zha",
227
- "zulu": "zul"
228
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Represents a language object with optional script and region.
3
- */
4
- export type LanguageObject = {
5
- language: string;
6
- script?: string;
7
- region?: string;
8
- };
@@ -1,305 +0,0 @@
1
- // ----- IMPORTS ----- //
2
- // Import modules for mapping ISO 639 codes to language names and vice versa
3
- import CodeToLanguageJSON from './639-1/CodeToLanguage.json';
4
- import LanguageToCodeJSON from './639-1/LanguageToCode.json';
5
- const CodeToLanguage = CodeToLanguageJSON;
6
- const LanguageToCode = LanguageToCodeJSON;
7
- // Import modules for mapping ISO 639-3 codes (for languages without two-letter codes)
8
- import CodeToLanguageTriletterJSON from './639-3/CodeToLanguageTriletter.json';
9
- import LanguageToCodeTriletterJSON from './639-3/LanguageToCodeTriletter.json';
10
- const CodeToLanguageTriletter = CodeToLanguageTriletterJSON;
11
- const LanguageToCodeTriletter = LanguageToCodeTriletterJSON;
12
- // Import module for mapping ISO 15924 script codes to script names
13
- import ScriptToCodeJSON from './15924/ScriptToCode.json';
14
- import CodeToScriptJSON from './15924/CodeToScript.json';
15
- const ScriptToCode = ScriptToCodeJSON;
16
- const CodeToScript = CodeToScriptJSON;
17
- // Import module for mapping ISO 3166 region codes to region names
18
- import RegionToCodeJSON from './3166/RegionToCode.json';
19
- import CodeToRegionJSON from './3166/CodeToRegion.json';
20
- const RegionToCode = RegionToCodeJSON;
21
- const CodeToRegion = CodeToRegionJSON;
22
- // Import predefined common regions
23
- import PredefinedJSON from './predefined/Predefined.json';
24
- const Predefined = PredefinedJSON;
25
- // ----- VALIDITY CHECKS ----- //
26
- /**
27
- * Ensures correct capitalization and formatting of a language code.
28
- * @param {string} code - The language-country-script code to standardize.
29
- * @returns {string} A BCP 47 language tag.
30
- * @internal
31
- */
32
- export function _standardizeLanguageCode(code) {
33
- if (!_isValidLanguageCode(code))
34
- return '';
35
- const codeParts = code.split('-');
36
- let result = `${codeParts[0].toLowerCase()}`;
37
- if (codeParts[1]) {
38
- if (codeParts[1].length === 4) {
39
- result += `-${_capitalize(codeParts[1])}`;
40
- if (codeParts[2] && codeParts[2].length === 2) {
41
- result += `-${codeParts[2].toUpperCase()}`;
42
- }
43
- }
44
- else if (codeParts[1].length === 2) {
45
- result += `-${codeParts[1].toUpperCase()}`;
46
- }
47
- }
48
- return result;
49
- }
50
- /**
51
- * Check if a given language-country-script code is valid.
52
- * @param {string} code - The language-country-script code to validate.
53
- * @returns {boolean} - Returns true if valid, false otherwise.
54
- * @internal
55
- */
56
- export function _isValidLanguageCode(code) {
57
- if (!code || typeof code !== 'string')
58
- return false;
59
- const codeParts = code.split('-');
60
- if (!_mapCodeToLanguage(codeParts[0]))
61
- return false;
62
- if (codeParts[1]) {
63
- if (codeParts[1].length === 4) {
64
- if (!_mapCodeToScript(codeParts[1]))
65
- return false;
66
- if (codeParts[2] && codeParts[2].length === 2) {
67
- if (!_mapCodeToRegion(codeParts[2]))
68
- return false;
69
- }
70
- }
71
- else if (codeParts[1].length === 2) {
72
- if (!_mapCodeToRegion(codeParts[1]))
73
- return false;
74
- }
75
- }
76
- return true;
77
- }
78
- // ----- FORMATTING HELPER FUNCTIONS ----- //
79
- /**
80
- * Capitalizes the first letter of a code and converts the rest to lowercase.
81
- * @param {string} code - The code to capitalize.
82
- * @returns {string} The capitalized code.
83
- */
84
- const _capitalize = (code) => {
85
- if (code.length === 0)
86
- return code;
87
- return code.charAt(0).toUpperCase() + code.slice(1).toLowerCase();
88
- };
89
- // ----- MAPPING FUNCTIONS ----- //
90
- /**
91
- * Returns the name of a language from an ISO 639 code.
92
- * @param {string} code - The ISO 639 code.
93
- * @returns {string} The language name.
94
- */
95
- const _mapCodeToLanguage = (code) => {
96
- code = code?.toLowerCase();
97
- if (code?.length === 2) {
98
- return CodeToLanguage[code];
99
- }
100
- if (code?.length === 3) {
101
- return CodeToLanguageTriletter[code];
102
- }
103
- return '';
104
- };
105
- /**
106
- * Returns a BCP 47 language tag from a language name.
107
- * Preferentially returns two-letter codes.
108
- * @param {string} language - The language name.
109
- * @returns {string} BCP 47 language tag.
110
- */
111
- const _mapLanguageToCode = (language) => {
112
- language = language?.toLowerCase();
113
- return LanguageToCode[language] || LanguageToCodeTriletter[language] || '';
114
- };
115
- /**
116
- * Returns the name of a script from an ISO 15924 code.
117
- * @param {string} code - The ISO 15924 code.
118
- * @returns {string} The script name.
119
- */
120
- const _mapCodeToScript = (code) => {
121
- code = _capitalize(code);
122
- return CodeToScript[code] || '';
123
- };
124
- /**
125
- * Returns an ISO 15924 code from a script name.
126
- * @param {string} script - The script name.
127
- * @returns {string} The ISO 15924 code.
128
- */
129
- const _mapScriptToCode = (script) => {
130
- script = script?.toLowerCase();
131
- return ScriptToCode[script] || '';
132
- };
133
- /**
134
- * Returns the name of a region from an ISO 3166 code.
135
- * @param {string} code - The ISO 3166 code.
136
- * @returns {string} The region name.
137
- */
138
- const _mapCodeToRegion = (code) => {
139
- code = code?.toUpperCase();
140
- return CodeToRegion[code] || '';
141
- };
142
- /**
143
- * Returns an ISO 3166 code from a region name.
144
- * @param {string} region - The region name.
145
- * @returns {string} The ISO 3166 code.
146
- */
147
- const _mapRegionToCode = (region) => {
148
- region = region?.toLowerCase();
149
- return RegionToCode[region] || '';
150
- };
151
- /**
152
- * @internal
153
- */
154
- export function _getLanguageObject(codes) {
155
- return Array.isArray(codes) ? codes.map(_handleGetLanguageObject) : _handleGetLanguageObject(codes);
156
- }
157
- /**
158
- * Helper function to create a language object from a code.
159
- * @param {string} code - The language code.
160
- * @returns {LanguageObject|null} The language object.
161
- */
162
- const _handleGetLanguageObject = (code) => {
163
- if (!_isValidLanguageCode(code))
164
- return null;
165
- const codeParts = code.split('-');
166
- let languageObject = {
167
- language: _mapCodeToLanguage(codeParts[0]),
168
- };
169
- if (codeParts[1]) {
170
- if (codeParts[1].length === 4) {
171
- languageObject.script = _mapCodeToScript(codeParts[1]);
172
- if (codeParts[2] && codeParts[2].length === 2) {
173
- languageObject.region = _mapCodeToRegion(codeParts[2]);
174
- }
175
- }
176
- else if (codeParts[1].length === 2) {
177
- languageObject.region = _mapCodeToRegion(codeParts[1]);
178
- }
179
- }
180
- return languageObject;
181
- };
182
- // ----- LANGUAGE NAMES FROM CODES ----- //
183
- /**
184
- * Returns the language name(s) from an array of codes or a single code.
185
- * @param {string|string[]} codes - The code or array of codes.
186
- * @returns {string|string[]} The language name(s).
187
- * @internal
188
- */
189
- export const _getLanguageName = (codes) => {
190
- return Array.isArray(codes) ? codes.map(_handleGetLanguageName) : _handleGetLanguageName(codes);
191
- };
192
- /**
193
- * Helper function to get the language name from a code.
194
- * @param {string} code - The language code.
195
- * @returns {string} The language name.
196
- */
197
- const _handleGetLanguageName = (code) => {
198
- if (!_isValidLanguageCode(code))
199
- return '';
200
- if (Predefined[code])
201
- return Predefined[code];
202
- const languageObject = _handleGetLanguageObject(code);
203
- if (!languageObject)
204
- return '';
205
- let result = languageObject.language;
206
- if (languageObject.script) {
207
- result += `, ${languageObject.script}`;
208
- }
209
- if (languageObject.region) {
210
- result += `, ${languageObject.region}`;
211
- }
212
- return result;
213
- };
214
- // ----- LANGUAGE CODES FROM NAMES ----- //
215
- /**
216
- * Returns the language code(s) from an array of language names or a single name.
217
- * @param {string|string[]} languages - The language name or array of language names.
218
- * @returns {string|string[]} The language code(s).
219
- * @internal
220
- */
221
- export const _getLanguageCode = (languages) => {
222
- return Array.isArray(languages) ? languages.map(_handleGetLanguageCode) : _handleGetLanguageCode(languages);
223
- };
224
- /**
225
- * Helper function to get the language code from a language name.
226
- * @param {string|LanguageObject} language - The language name or object.
227
- * @returns {string} The language code.
228
- */
229
- const _handleGetLanguageCode = (language) => {
230
- if (typeof language === 'string')
231
- return _handleGetLanguageCodeFromString(language);
232
- return _handleGetLanguageCodeFromObject(language);
233
- };
234
- /**
235
- * Helper function to get the language code from a language name string.
236
- * @param {string} language - The language name.
237
- * @returns {string} The language code.
238
- */
239
- const _handleGetLanguageCodeFromString = (language) => {
240
- const subtagStrings = language.split(',').map(string => string.trim());
241
- let code = _mapLanguageToCode(subtagStrings[0]);
242
- if (code) {
243
- if (subtagStrings.length === 3) {
244
- code += `-${_mapScriptToCode(subtagStrings[1])}`;
245
- code += `-${_mapRegionToCode(subtagStrings[2])}`;
246
- }
247
- else if (subtagStrings.length === 2) {
248
- let tag = _mapScriptToCode(subtagStrings[1]);
249
- if (!tag)
250
- tag = _mapRegionToCode(subtagStrings[1]);
251
- if (tag)
252
- code += `-${tag}`;
253
- }
254
- }
255
- if (!code) {
256
- for (const key in Predefined) {
257
- if (Predefined[key] === language) {
258
- return key;
259
- }
260
- }
261
- }
262
- return code;
263
- };
264
- /**
265
- * Helper function to get the language code from a language object.
266
- * @param {LanguageObject} languageObject - The language object.
267
- * @returns {string} The language code.
268
- */
269
- const _handleGetLanguageCodeFromObject = (languageObject) => {
270
- if (!languageObject?.language)
271
- return '';
272
- let code = languageObject.language.toLowerCase();
273
- if (languageObject.script) {
274
- code += `-${_capitalize(languageObject.script)}`;
275
- }
276
- if (languageObject.region) {
277
- code += `-${languageObject.region.toUpperCase()}`;
278
- }
279
- return _isValidLanguageCode(code) ? code : '';
280
- };
281
- /**
282
- * @internal
283
- */
284
- export function _isSameLanguage(...codes) {
285
- // Flatten the array in case the codes are provided as an array
286
- if (codes.length === 1 && Array.isArray(codes[0])) {
287
- codes = codes[0];
288
- }
289
- if (codes.length < 2)
290
- return false;
291
- let language = null;
292
- for (let i = 0; i < codes.length; i++) {
293
- if (typeof codes[i] !== 'string')
294
- return false;
295
- const languageCode = codes[i].split('-')[0];
296
- const currentLanguage = _mapCodeToLanguage(languageCode);
297
- if (language === null) {
298
- language = currentLanguage;
299
- }
300
- else if (language !== currentLanguage) {
301
- return false;
302
- }
303
- }
304
- return true;
305
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,68 +0,0 @@
1
- /* ----- BEGIN YAHOO COPYRIGHT ----- */
2
- /*
3
-
4
- Copyright 2015 Yahoo Inc. All rights reserved.
5
-
6
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7
-
8
- * Redistributions of source code must retain the above copyright
9
- notice, this list of conditions and the following disclaimer.
10
-
11
- * Redistributions in binary form must reproduce the above copyright
12
- notice, this list of conditions and the following disclaimer in the
13
- documentation and/or other materials provided with the distribution.
14
-
15
- * Neither the name of the Yahoo Inc. nor the
16
- names of its contributors may be used to endorse or promote products
17
- derived from this software without specific prior written permission.
18
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL YAHOO! INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
-
20
- */
21
- /**
22
- * List of languages that are written from right to left.
23
- * Each entry contains the language code and the language name.
24
- *
25
- * @type {string[]}
26
- */
27
- const rtlLanguages = [
28
- 'ae', /* Avestan */
29
- 'ar', /* 'العربية', Arabic */
30
- 'arc', /* Aramaic */
31
- 'bcc', /* 'بلوچی مکرانی', Southern Balochi */
32
- 'bqi', /* 'بختياري', Bakthiari */
33
- 'ckb', /* 'Soranî / کوردی', Sorani */
34
- 'dv', /* Dhivehi */
35
- 'fa', /* 'فارسی', Persian */
36
- 'glk', /* 'گیلکی', Gilaki */
37
- 'he', /* 'עברית', Hebrew */
38
- 'ku', /* 'Kurdî / كوردی', Kurdish */
39
- 'mzn', /* 'مازِرونی', Mazanderani */
40
- 'nqo', /* N'Ko */
41
- 'pnb', /* 'پنجابی', Western Punjabi */
42
- 'prs', /* 'دری', Darī */
43
- 'ps', /* 'پښتو', Pashto, */
44
- 'sd', /* 'سنڌي', Sindhi */
45
- 'ug', /* 'Uyghurche / ئۇيغۇرچە', Uyghur */
46
- 'ur', /* 'اردو', Urdu */
47
- 'yi' /* 'ייִדיש', Yiddish */
48
- ];
49
- /* ----- END YAHOO COPYRIGHT ----- */
50
- import { _getLanguageObject, _isSameLanguage } from "./codes.js";
51
- /**
52
- * Get the text direction for a given language code.
53
- *
54
- * @param {string} code - The language code to check.
55
- * @returns {string} - 'rtl' if the language is right-to-left, otherwise 'ltr'.
56
- * @internal
57
- */
58
- export default function _getLanguageDirection(code) {
59
- return rtlLanguages.some(language => {
60
- const lo = _getLanguageObject(language);
61
- const clo = _getLanguageObject(code);
62
- if (!lo || !clo)
63
- return false;
64
- if (lo.script && clo.script && lo.script !== clo.script)
65
- return false;
66
- return _isSameLanguage(code, language);
67
- }) ? 'rtl' : 'ltr';
68
- }
@@ -1,28 +0,0 @@
1
- {
2
- "en-US": "English",
3
- "en-GB": "British English",
4
- "en-CA": "Canadian English",
5
- "en-AU": "Australian English",
6
- "es-ES": "Spanish",
7
- "es-MX": "Mexican Spanish",
8
- "es-AR": "Argentinian Spanish",
9
- "es-CO": "Colombian Spanish",
10
- "fr-FR": "French",
11
- "fr-CA": "Canadian French",
12
- "fr-BE": "Belgian French",
13
- "fr-CH": "Swiss French",
14
- "zh-CN": "Mandarin Chinese",
15
- "zh-TW": "Traditional Chinese",
16
- "zh-HK": "Hong Kong Chinese",
17
- "pt-PT": "Portuguese",
18
- "pt-BR": "Brazilian Portuguese",
19
- "de-DE": "German",
20
- "de-AT": "Austrian German",
21
- "de-CH": "Swiss German",
22
- "ar-SA": "Saudi Arabic",
23
- "ar-EG": "Egyptian Arabic",
24
- "ar-AE": "Emirati Arabic",
25
- "ar-MA": "Moroccan Arabic",
26
- "nl-BE": "Belgian Dutch",
27
- "it-CH": "Swiss Italian"
28
- }