Debian Codegraph @

lib/3rdParty/composer/nesbot/carbon/src/Carbon/AbstractTranslator.php

raw symbols SCIP
1 <?php
2
3 declare(strict_types=1);
4
5 /**
6 * This file is part of the Carbon package.
7 *
8 * (c) Brian Nesbitt <[email protected]>
9 *
10 * For the full copyright and license information, please view the LICENSE
11 * file that was distributed with this source code.
12 */
13
14 namespace Carbon;
15
16 use Carbon\MessageFormatter\MessageFormatterMapper;
17 use Closure;
18 use ReflectionException;
19 use ReflectionFunction;
20 use ReflectionProperty;
21 use Symfony\Component\Translation\Formatter\MessageFormatterInterface;
22 use Symfony\Component\Translation\Loader\ArrayLoader;
23 use Symfony\Component\Translation\Translator as SymfonyTranslator;
24 use Throwable;
25
26 abstract class AbstractTranslator extends SymfonyTranslator
27 {
28 public const REGION_CODE_LENGTH = 2;
29
30 /**
31 * Translator singletons for each language.
32 *
33 * @var array
34 */
35 protected static array $singletons = [];
36
37 /**
38 * List of custom localized messages.
39 *
40 * @var array
41 */
42 protected array $messages = [];
43
44 /**
45 * List of custom directories that contain translation files.
46 *
47 * @var string[]
48 */
49 protected array $directories = [];
50
51 /**
52 * Set to true while constructing.
53 */
54 protected bool $initializing = false;
55
56 /**
57 * List of locales aliases.
58 *
59 * @var array<string, string>
60 */
61 protected array $aliases = [
62 'me' => 'sr_Latn_ME',
63 'scr' => 'sh',
64 ];
65
66 /**
67 * Return a singleton instance of Translator.
68 *
69 * @param string|null $locale optional initial locale ("en" - english by default)
70 *
71 * @return static
72 */
73 public static function get(?string $locale = null): static
74 {
75 $locale = $locale ?: 'en';
76 $key = static::class === Translator::class ? $locale : static::class.'|'.$locale;
77 $count = \count(static::$singletons);
78
79 // Remember only the last 10 translators created
80 if ($count > 10) {
81 foreach (\array_slice(array_keys(static::$singletons), 0, $count - 10) as $index) {
82 unset(static::$singletons[$index]);
83 }
84 }
85
86 static::$singletons[$key] ??= new static($locale);
87
88 return static::$singletons[$key];
89 }
90
91 public function __construct($locale, ?MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false)
92 {
93 $this->initialize($locale, $formatter, $cacheDir, $debug);
94 }
95
96 /**
97 * Returns the list of directories translation files are searched in.
98 */
99 public function getDirectories(): array
100 {
101 return $this->directories;
102 }
103
104 /**
105 * Set list of directories translation files are searched in.
106 *
107 * @param array $directories new directories list
108 *
109 * @return $this
110 */
111 public function setDirectories(array $directories): static
112 {
113 $this->directories = $directories;
114
115 return $this;
116 }
117
118 /**
119 * Add a directory to the list translation files are searched in.
120 *
121 * @param string $directory new directory
122 *
123 * @return $this
124 */
125 public function addDirectory(string $directory): static
126 {
127 $this->directories[] = $directory;
128
129 return $this;
130 }
131
132 /**
133 * Remove a directory from the list translation files are searched in.
134 *
135 * @param string $directory directory path
136 *
137 * @return $this
138 */
139 public function removeDirectory(string $directory): static
140 {
141 $search = rtrim(strtr($directory, '\\', '/'), '/');
142
143 return $this->setDirectories(array_filter(
144 $this->getDirectories(),
145 static fn ($item) => rtrim(strtr($item, '\\', '/'), '/') !== $search,
146 ));
147 }
148
149 /**
150 * Reset messages of a locale (all locale if no locale passed).
151 * Remove custom messages and reload initial messages from matching
152 * file in Lang directory.
153 */
154 public function resetMessages(?string $locale = null): bool
155 {
156 if ($locale === null) {
157 $this->messages = [];
158 $this->catalogues = [];
159 $this->modifyResources(static function (array $resources): array {
160 foreach ($resources as &$list) {
161 array_splice($list, 1);
162 }
163
164 return $resources;
165 });
166
167 return true;
168 }
169
170 $this->assertValidLocale($locale);
171
172 foreach ($this->getDirectories() as $directory) {
173 $file = \sprintf('%s/%s.php', rtrim($directory, '\\/'), $locale);
174 $data = @include $file;
175
176 if ($data !== false) {
177 $this->messages[$locale] = $data;
178 unset($this->catalogues[$locale]);
179 $this->modifyResources(static function (array $resources) use ($locale): array {
180 unset($resources[$locale]);
181
182 return $resources;
183 });
184 $this->addResource('array', $this->messages[$locale], $locale);
185
186 return true;
187 }
188 }
189
190 return false;
191 }
192
193 /**
194 * Returns the list of files matching a given locale prefix (or all if empty).
195 *
196 * @param string $prefix prefix required to filter result
197 *
198 * @return array
199 */
200 public function getLocalesFiles(string $prefix = ''): array
201 {
202 $files = [];
203
204 foreach ($this->getDirectories() as $directory) {
205 foreach (self::getPhpFilesInDirectory(rtrim($directory, '\\/'), $prefix) as $file) {
206 $files[] = $file;
207 }
208 }
209
210 return array_unique($files);
211 }
212
213 /**
214 * Returns the list of internally available locales and already loaded custom locales.
215 * (It will ignore custom translator dynamic loading.)
216 *
217 * @param string $prefix prefix required to filter result
218 *
219 * @return array
220 */
221 public function getAvailableLocales(string $prefix = ''): array
222 {
223 return array_unique(array_merge(
224 array_map(
225 static fn (string $file) => substr($file, strrpos($file, '/') + 1, -4),
226 $this->getLocalesFiles($prefix),
227 ),
228 array_keys($this->messages),
229 ));
230 }
231
232 protected function translate(?string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
233 {
234 $domain ??= 'messages';
235 $catalogue = $this->getCatalogue($locale);
236 $format = $this instanceof TranslatorStrongTypeInterface
237 ? $this->getFromCatalogue($catalogue, (string) $id, $domain)
238 : $this->getCatalogue($locale)->get((string) $id, $domain); // @codeCoverageIgnore
239
240 if ($format instanceof Closure) {
241 // @codeCoverageIgnoreStart
242 try {
243 $count = (new ReflectionFunction($format))->getNumberOfRequiredParameters();
244 } catch (ReflectionException) {
245 $count = 0;
246 }
247 // @codeCoverageIgnoreEnd
248
249 return $format(
250 ...array_values($parameters),
251 ...array_fill(0, max(0, $count - \count($parameters)), null)
252 );
253 }
254
255 return parent::trans($id, $parameters, $domain, $locale);
256 }
257
258 /**
259 * Init messages language from matching file in Lang directory.
260 *
261 * @param string $locale
262 *
263 * @return bool
264 */
265 protected function loadMessagesFromFile(string $locale): bool
266 {
267 return isset($this->messages[$locale]) || $this->resetMessages($locale);
268 }
269
270 /**
271 * Set messages of a locale and take file first if present.
272 *
273 * @param string $locale
274 * @param array $messages
275 *
276 * @return $this
277 */
278 public function setMessages(string $locale, array $messages): static
279 {
280 $this->loadMessagesFromFile($locale);
281 $this->addResource('array', $messages, $locale);
282 $this->messages[$locale] = array_merge(
283 $this->messages[$locale] ?? [],
284 $messages
285 );
286
287 return $this;
288 }
289
290 /**
291 * Set messages of the current locale and take file first if present.
292 *
293 * @param array $messages
294 *
295 * @return $this
296 */
297 public function setTranslations(array $messages): static
298 {
299 return $this->setMessages($this->getLocale(), $messages);
300 }
301
302 /**
303 * Get messages of a locale, if none given, return all the
304 * languages.
305 */
306 public function getMessages(?string $locale = null): array
307 {
308 return $locale === null ? $this->messages : $this->messages[$locale];
309 }
310
311 /**
312 * Set the current translator locale and indicate if the source locale file exists
313 *
314 * @param string $locale locale ex. en
315 */
316 public function setLocale($locale): void
317 {
318 $locale = preg_replace_callback('/[-_]([a-z]{2,}|\d{2,})/', function ($matches) {
319 // _2-letters or YUE is a region, _3+-letters is a variant
320 $upper = strtoupper($matches[1]);
321
322 if ($upper === 'YUE' || $upper === 'ISO' || \strlen($upper) <= static::REGION_CODE_LENGTH) {
323 return "_$upper";
324 }
325
326 return '_'.ucfirst($matches[1]);
327 }, strtolower($locale));
328
329 $previousLocale = $this->getLocale();
330
331 if ($previousLocale === $locale && isset($this->messages[$locale])) {
332 return;
333 }
334
335 unset(static::$singletons[$previousLocale]);
336
337 if ($locale === 'auto') {
338 $completeLocale = setlocale(LC_TIME, '0');
339 $locale = preg_replace('/^([^_.-]+).*$/', '$1', $completeLocale);
340 $locales = $this->getAvailableLocales($locale);
341
342 $completeLocaleChunks = preg_split('/[_.-]+/', $completeLocale);
343
344 $getScore = static fn ($language) => self::compareChunkLists(
345 $completeLocaleChunks,
346 preg_split('/[_.-]+/', $language),
347 );
348
349 usort($locales, static fn ($first, $second) => $getScore($second) <=> $getScore($first));
350
351 $locale = $locales[0] ?? 'en';
352 }
353
354 if (isset($this->aliases[$locale])) {
355 $locale = $this->aliases[$locale];
356 }
357
358 // If the language is not provided by a Carbon file
359 // and the tag contains a region (ex: en_CA), then
360 // first load the macro (ex: en) to have a fallback
361 if (
362 str_contains($locale, '_')
363 && !\in_array($locale, self::getInternallySupportedLocales(), true)
364 && $this->loadMessagesFromFile($macroLocale = preg_replace('/^([^_]+).*$/', '$1', $locale))
365 ) {
366 parent::setLocale($macroLocale);
367 }
368
369 if (!$this->loadMessagesFromFile($locale) && !$this->initializing) {
370 return;
371 }
372
373 parent::setLocale($locale);
374 }
375
376 /**
377 * Show locale on var_dump().
378 *
379 * @return array
380 */
381 public function __debugInfo()
382 {
383 return [
384 'locale' => $this->getLocale(),
385 ];
386 }
387
388 public function __serialize(): array
389 {
390 return [
391 'locale' => $this->getLocale(),
392 ];
393 }
394
395 public function __unserialize(array $data): void
396 {
397 $this->initialize($data['locale'] ?? 'en');
398 }
399
400 private function initialize($locale, ?MessageFormatterInterface $formatter = null, $cacheDir = null, $debug = false): void
401 {
402 parent::setLocale($locale);
403 $this->initializing = true;
404 $this->directories = [self::getDefaultLangDirectory()];
405 $this->addLoader('array', new ArrayLoader());
406 parent::__construct($locale, new MessageFormatterMapper($formatter), $cacheDir, $debug);
407 $this->initializing = false;
408 }
409
410 private static function compareChunkLists($referenceChunks, $chunks)
411 {
412 $score = 0;
413
414 foreach ($referenceChunks as $index => $chunk) {
415 if (!isset($chunks[$index])) {
416 $score++;
417
418 continue;
419 }
420
421 if (strtolower($chunks[$index]) === strtolower($chunk)) {
422 $score += 10;
423 }
424 }
425
426 return $score;
427 }
428
429 /** @codeCoverageIgnore */
430 private function modifyResources(callable $callback): void
431 {
432 try {
433 $resourcesProperty = new ReflectionProperty(SymfonyTranslator::class, 'resources');
434 $resources = $resourcesProperty->getValue($this);
435 $resourcesProperty->setValue($this, $callback($resources));
436 } catch (Throwable) {
437 // Clear resources if available, if not, then nothing to clean
438 }
439 }
440
441 private static function getPhpFilesInDirectory(string $directory, string $prefix): array
442 {
443 if ($directory !== self::getDefaultLangDirectory()) {
444 return glob("$directory/$prefix*.php") ?: [];
445 }
446
447 // If it's the internal Carbon directory we use a static list
448 // which is faster than scanning the folder with glob()
449 $locales = self::getInternallySupportedLocales();
450
451 if ($prefix !== '') {
452 $locales = array_values(array_filter(
453 self::getInternallySupportedLocales(),
454 static fn (string $locale) => str_starts_with($locale, $prefix),
455 ));
456 }
457
458 return array_map(
459 static fn (string $locale) => "$directory/$locale.php",
460 $locales,
461 );
462 }
463
464 private static function getDefaultLangDirectory(): string
465 {
466 return __DIR__.'/Lang';
467 }
468
469 /** @return list<string> */
470 private static function getInternallySupportedLocales(): array
471 {
472 return [
473 'aa',
474 'aa_DJ',
475 'aa_ER',
476 'aa_ER@saaho',
477 'aa_ET',
478 'af',
479 'af_NA',
480 'af_ZA',
481 'agq',
482 'agr',
483 'agr_PE',
484 'ak',
485 'ak_GH',
486 'am',
487 'am_ET',
488 'an',
489 'an_ES',
490 'anp',
491 'anp_IN',
492 'ar',
493 'ar_AE',
494 'ar_BH',
495 'ar_DJ',
496 'ar_DZ',
497 'ar_EG',
498 'ar_EH',
499 'ar_ER',
500 'ar_IL',
501 'ar_IN',
502 'ar_IQ',
503 'ar_JO',
504 'ar_KM',
505 'ar_KW',
506 'ar_LB',
507 'ar_LY',
508 'ar_MA',
509 'ar_MR',
510 'ar_OM',
511 'ar_PS',
512 'ar_QA',
513 'ar_SA',
514 'ar_SD',
515 'ar_SO',
516 'ar_SS',
517 'ar_SY',
518 'ar_Shakl',
519 'ar_TD',
520 'ar_TN',
521 'ar_YE',
522 'as',
523 'as_IN',
524 'asa',
525 'ast',
526 'ast_ES',
527 'ayc',
528 'ayc_PE',
529 'az',
530 'az_AZ',
531 'az_Arab',
532 'az_Cyrl',
533 'az_IR',
534 'az_Latn',
535 'bas',
536 'be',
537 'be_BY',
538 'be_BY@latin',
539 'bem',
540 'bem_ZM',
541 'ber',
542 'ber_DZ',
543 'ber_MA',
544 'bez',
545 'bg',
546 'bg_BG',
547 'bhb',
548 'bhb_IN',
549 'bho',
550 'bho_IN',
551 'bi',
552 'bi_VU',
553 'bm',
554 'bn',
555 'bn_BD',
556 'bn_IN',
557 'bo',
558 'bo_CN',
559 'bo_IN',
560 'br',
561 'br_FR',
562 'brx',
563 'brx_IN',
564 'bs',
565 'bs_BA',
566 'bs_Cyrl',
567 'bs_Latn',
568 'byn',
569 'byn_ER',
570 'ca',
571 'ca_AD',
572 'ca_ES',
573 'ca_ES_Valencia',
574 'ca_FR',
575 'ca_IT',
576 'ccp',
577 'ccp_IN',
578 'ce',
579 'ce_RU',
580 'cgg',
581 'chr',
582 'chr_US',
583 'ckb',
584 'cmn',
585 'cmn_TW',
586 'crh',
587 'crh_UA',
588 'cs',
589 'cs_CZ',
590 'csb',
591 'csb_PL',
592 'cu',
593 'cv',
594 'cv_RU',
595 'cy',
596 'cy_GB',
597 'da',
598 'da_DK',
599 'da_GL',
600 'dav',
601 'de',
602 'de_AT',
603 'de_BE',
604 'de_CH',
605 'de_DE',
606 'de_IT',
607 'de_LI',
608 'de_LU',
609 'dje',
610 'doi',
611 'doi_IN',
612 'dsb',
613 'dsb_DE',
614 'dua',
615 'dv',
616 'dv_MV',
617 'dyo',
618 'dz',
619 'dz_BT',
620 'ebu',
621 'ee',
622 'ee_TG',
623 'el',
624 'el_CY',
625 'el_GR',
626 'en',
627 'en_001',
628 'en_150',
629 'en_AG',
630 'en_AI',
631 'en_AS',
632 'en_AT',
633 'en_AU',
634 'en_BB',
635 'en_BE',
636 'en_BI',
637 'en_BM',
638 'en_BS',
639 'en_BW',
640 'en_BZ',
641 'en_CA',
642 'en_CC',
643 'en_CH',
644 'en_CK',
645 'en_CM',
646 'en_CX',
647 'en_CY',
648 'en_DE',
649 'en_DG',
650 'en_DK',
651 'en_DM',
652 'en_ER',
653 'en_FI',
654 'en_FJ',
655 'en_FK',
656 'en_FM',
657 'en_GB',
658 'en_GD',
659 'en_GG',
660 'en_GH',
661 'en_GI',
662 'en_GM',
663 'en_GU',
664 'en_GY',
665 'en_HK',
666 'en_IE',
667 'en_IL',
668 'en_IM',
669 'en_IN',
670 'en_IO',
671 'en_ISO',
672 'en_JE',
673 'en_JM',
674 'en_KE',
675 'en_KI',
676 'en_KN',
677 'en_KY',
678 'en_LC',
679 'en_LR',
680 'en_LS',
681 'en_MG',
682 'en_MH',
683 'en_MO',
684 'en_MP',
685 'en_MS',
686 'en_MT',
687 'en_MU',
688 'en_MW',
689 'en_MY',
690 'en_NA',
691 'en_NF',
692 'en_NG',
693 'en_NL',
694 'en_NR',
695 'en_NU',
696 'en_NZ',
697 'en_PG',
698 'en_PH',
699 'en_PK',
700 'en_PN',
701 'en_PR',
702 'en_PW',
703 'en_RW',
704 'en_SB',
705 'en_SC',
706 'en_SD',
707 'en_SE',
708 'en_SG',
709 'en_SH',
710 'en_SI',
711 'en_SL',
712 'en_SS',
713 'en_SX',
714 'en_SZ',
715 'en_TC',
716 'en_TK',
717 'en_TO',
718 'en_TT',
719 'en_TV',
720 'en_TZ',
721 'en_UG',
722 'en_UM',
723 'en_US',
724 'en_US_Posix',
725 'en_VC',
726 'en_VG',
727 'en_VI',
728 'en_VU',
729 'en_WS',
730 'en_ZA',
731 'en_ZM',
732 'en_ZW',
733 'eo',
734 'es',
735 'es_419',
736 'es_AR',
737 'es_BO',
738 'es_BR',
739 'es_BZ',
740 'es_CL',
741 'es_CO',
742 'es_CR',
743 'es_CU',
744 'es_DO',
745 'es_EA',
746 'es_EC',
747 'es_ES',
748 'es_GQ',
749 'es_GT',
750 'es_HN',
751 'es_IC',
752 'es_MX',
753 'es_NI',
754 'es_PA',
755 'es_PE',
756 'es_PH',
757 'es_PR',
758 'es_PY',
759 'es_SV',
760 'es_US',
761 'es_UY',
762 'es_VE',
763 'et',
764 'et_EE',
765 'eu',
766 'eu_ES',
767 'ewo',
768 'fa',
769 'fa_AF',
770 'fa_IR',
771 'ff',
772 'ff_CM',
773 'ff_GN',
774 'ff_MR',
775 'ff_SN',
776 'fi',
777 'fi_FI',
778 'fil',
779 'fil_PH',
780 'fo',
781 'fo_DK',
782 'fo_FO',
783 'fr',
784 'fr_BE',
785 'fr_BF',
786 'fr_BI',
787 'fr_BJ',
788 'fr_BL',
789 'fr_CA',
790 'fr_CD',
791 'fr_CF',
792 'fr_CG',
793 'fr_CH',
794 'fr_CI',
795 'fr_CM',
796 'fr_DJ',
797 'fr_DZ',
798 'fr_FR',
799 'fr_GA',
800 'fr_GF',
801 'fr_GN',
802 'fr_GP',
803 'fr_GQ',
804 'fr_HT',
805 'fr_KM',
806 'fr_LU',
807 'fr_MA',
808 'fr_MC',
809 'fr_MF',
810 'fr_MG',
811 'fr_ML',
812 'fr_MQ',
813 'fr_MR',
814 'fr_MU',
815 'fr_NC',
816 'fr_NE',
817 'fr_PF',
818 'fr_PM',
819 'fr_RE',
820 'fr_RW',
821 'fr_SC',
822 'fr_SN',
823 'fr_SY',
824 'fr_TD',
825 'fr_TG',
826 'fr_TN',
827 'fr_VU',
828 'fr_WF',
829 'fr_YT',
830 'fur',
831 'fur_IT',
832 'fy',
833 'fy_DE',
834 'fy_NL',
835 'ga',
836 'ga_IE',
837 'gd',
838 'gd_GB',
839 'gez',
840 'gez_ER',
841 'gez_ET',
842 'gl',
843 'gl_ES',
844 'gom',
845 'gom_Latn',
846 'gsw',
847 'gsw_CH',
848 'gsw_FR',
849 'gsw_LI',
850 'gu',
851 'gu_IN',
852 'guz',
853 'gv',
854 'gv_GB',
855 'ha',
856 'ha_GH',
857 'ha_NE',
858 'ha_NG',
859 'hak',
860 'hak_TW',
861 'haw',
862 'he',
863 'he_IL',
864 'hi',
865 'hi_IN',
866 'hif',
867 'hif_FJ',
868 'hne',
869 'hne_IN',
870 'hr',
871 'hr_BA',
872 'hr_HR',
873 'hsb',
874 'hsb_DE',
875 'ht',
876 'ht_HT',
877 'hu',
878 'hu_HU',
879 'hy',
880 'hy_AM',
881 'i18n',
882 'ia',
883 'ia_FR',
884 'id',
885 'id_ID',
886 'ig',
887 'ig_NG',
888 'ii',
889 'ik',
890 'ik_CA',
891 'in',
892 'is',
893 'is_IS',
894 'it',
895 'it_CH',
896 'it_IT',
897 'it_SM',
898 'it_VA',
899 'iu',
900 'iu_CA',
901 'iw',
902 'ja',
903 'ja_JP',
904 'jgo',
905 'jmc',
906 'jv',
907 'ka',
908 'ka_GE',
909 'kab',
910 'kab_DZ',
911 'kam',
912 'kde',
913 'kea',
914 'khq',
915 'ki',
916 'kk',
917 'kk_KZ',
918 'kkj',
919 'kl',
920 'kl_GL',
921 'kln',
922 'km',
923 'km_KH',
924 'kn',
925 'kn_IN',
926 'ko',
927 'ko_KP',
928 'ko_KR',
929 'kok',
930 'kok_IN',
931 'ks',
932 'ks_IN',
933 'ks_IN@devanagari',
934 'ksb',
935 'ksf',
936 'ksh',
937 'ku',
938 'ku_TR',
939 'kw',
940 'kw_GB',
941 'ky',
942 'ky_KG',
943 'lag',
944 'lb',
945 'lb_LU',
946 'lg',
947 'lg_UG',
948 'li',
949 'li_NL',
950 'lij',
951 'lij_IT',
952 'lkt',
953 'ln',
954 'ln_AO',
955 'ln_CD',
956 'ln_CF',
957 'ln_CG',
958 'lo',
959 'lo_LA',
960 'lrc',
961 'lrc_IQ',
962 'lt',
963 'lt_LT',
964 'lu',
965 'luo',
966 'luy',
967 'lv',
968 'lv_LV',
969 'lzh',
970 'lzh_TW',
971 'mag',
972 'mag_IN',
973 'mai',
974 'mai_IN',
975 'mas',
976 'mas_TZ',
977 'mer',
978 'mfe',
979 'mfe_MU',
980 'mg',
981 'mg_MG',
982 'mgh',
983 'mgo',
984 'mhr',
985 'mhr_RU',
986 'mi',
987 'mi_NZ',
988 'miq',
989 'miq_NI',
990 'mjw',
991 'mjw_IN',
992 'mk',
993 'mk_MK',
994 'ml',
995 'ml_IN',
996 'mn',
997 'mn_MN',
998 'mni',
999 'mni_IN',
1000 'mo',
1001 'mr',
1002 'mr_IN',
1003 'ms',
1004 'ms_BN',
1005 'ms_MY',
1006 'ms_SG',
1007 'mt',
1008 'mt_MT',
1009 'mua',
1010 'my',
1011 'my_MM',
1012 'mzn',
1013 'nan',
1014 'nan_TW',
1015 'nan_TW@latin',
1016 'naq',
1017 'nb',
1018 'nb_NO',
1019 'nb_SJ',
1020 'nd',
1021 'nds',
1022 'nds_DE',
1023 'nds_NL',
1024 'ne',
1025 'ne_IN',
1026 'ne_NP',
1027 'nhn',
1028 'nhn_MX',
1029 'niu',
1030 'niu_NU',
1031 'nl',
1032 'nl_AW',
1033 'nl_BE',
1034 'nl_BQ',
1035 'nl_CW',
1036 'nl_NL',
1037 'nl_SR',
1038 'nl_SX',
1039 'nmg',
1040 'nn',
1041 'nn_NO',
1042 'nnh',
1043 'no',
1044 'nr',
1045 'nr_ZA',
1046 'nso',
1047 'nso_ZA',
1048 'nus',
1049 'nyn',
1050 'oc',
1051 'oc_FR',
1052 'om',
1053 'om_ET',
1054 'om_KE',
1055 'or',
1056 'or_IN',
1057 'os',
1058 'os_RU',
1059 'pa',
1060 'pa_Arab',
1061 'pa_Guru',
1062 'pa_IN',
1063 'pa_PK',
1064 'pap',
1065 'pap_AW',
1066 'pap_CW',
1067 'pl',
1068 'pl_PL',
1069 'prg',
1070 'ps',
1071 'ps_AF',
1072 'pt',
1073 'pt_AO',
1074 'pt_BR',
1075 'pt_CH',
1076 'pt_CV',
1077 'pt_GQ',
1078 'pt_GW',
1079 'pt_LU',
1080 'pt_MO',
1081 'pt_MZ',
1082 'pt_PT',
1083 'pt_ST',
1084 'pt_TL',
1085 'qu',
1086 'qu_BO',
1087 'qu_EC',
1088 'quz',
1089 'quz_PE',
1090 'raj',
1091 'raj_IN',
1092 'rm',
1093 'rn',
1094 'ro',
1095 'ro_MD',
1096 'ro_RO',
1097 'rof',
1098 'ru',
1099 'ru_BY',
1100 'ru_KG',
1101 'ru_KZ',
1102 'ru_MD',
1103 'ru_RU',
1104 'ru_UA',
1105 'rw',
1106 'rw_RW',
1107 'rwk',
1108 'sa',
1109 'sa_IN',
1110 'sah',
1111 'sah_RU',
1112 'saq',
1113 'sat',
1114 'sat_IN',
1115 'sbp',
1116 'sc',
1117 'sc_IT',
1118 'sd',
1119 'sd_IN',
1120 'sd_IN@devanagari',
1121 'se',
1122 'se_FI',
1123 'se_NO',
1124 'se_SE',
1125 'seh',
1126 'ses',
1127 'sg',
1128 'sgs',
1129 'sgs_LT',
1130 'sh',
1131 'shi',
1132 'shi_Latn',
1133 'shi_Tfng',
1134 'shn',
1135 'shn_MM',
1136 'shs',
1137 'shs_CA',
1138 'si',
1139 'si_LK',
1140 'sid',
1141 'sid_ET',
1142 'sk',
1143 'sk_SK',
1144 'sl',
1145 'sl_SI',
1146 'sm',
1147 'sm_WS',
1148 'smn',
1149 'sn',
1150 'so',
1151 'so_DJ',
1152 'so_ET',
1153 'so_KE',
1154 'so_SO',
1155 'sq',
1156 'sq_AL',
1157 'sq_MK',
1158 'sq_XK',
1159 'sr',
1160 'sr_Cyrl',
1161 'sr_Cyrl_BA',
1162 'sr_Cyrl_ME',
1163 'sr_Cyrl_XK',
1164 'sr_Latn',
1165 'sr_Latn_BA',
1166 'sr_Latn_ME',
1167 'sr_Latn_XK',
1168 'sr_ME',
1169 'sr_RS',
1170 'sr_RS@latin',
1171 'ss',
1172 'ss_ZA',
1173 'st',
1174 'st_ZA',
1175 'sv',
1176 'sv_AX',
1177 'sv_FI',
1178 'sv_SE',
1179 'sw',
1180 'sw_CD',
1181 'sw_KE',
1182 'sw_TZ',
1183 'sw_UG',
1184 'szl',
1185 'szl_PL',
1186 'ta',
1187 'ta_IN',
1188 'ta_LK',
1189 'ta_MY',
1190 'ta_SG',
1191 'tcy',
1192 'tcy_IN',
1193 'te',
1194 'te_IN',
1195 'teo',
1196 'teo_KE',
1197 'tet',
1198 'tg',
1199 'tg_TJ',
1200 'th',
1201 'th_TH',
1202 'the',
1203 'the_NP',
1204 'ti',
1205 'ti_ER',
1206 'ti_ET',
1207 'tig',
1208 'tig_ER',
1209 'tk',
1210 'tk_TM',
1211 'tl',
1212 'tl_PH',
1213 'tlh',
1214 'tn',
1215 'tn_ZA',
1216 'to',
1217 'to_TO',
1218 'tpi',
1219 'tpi_PG',
1220 'tr',
1221 'tr_CY',
1222 'tr_TR',
1223 'ts',
1224 'ts_ZA',
1225 'tt',
1226 'tt_RU',
1227 'tt_RU@iqtelif',
1228 'twq',
1229 'tzl',
1230 'tzm',
1231 'tzm_Latn',
1232 'ug',
1233 'ug_CN',
1234 'uk',
1235 'uk_UA',
1236 'unm',
1237 'unm_US',
1238 'ur',
1239 'ur_IN',
1240 'ur_PK',
1241 'uz',
1242 'uz_Arab',
1243 'uz_Cyrl',
1244 'uz_Latn',
1245 'uz_UZ',
1246 'uz_UZ@cyrillic',
1247 'vai',
1248 'vai_Latn',
1249 'vai_Vaii',
1250 've',
1251 've_ZA',
1252 'vi',
1253 'vi_VN',
1254 'vo',
1255 'vun',
1256 'wa',
1257 'wa_BE',
1258 'wae',
1259 'wae_CH',
1260 'wal',
1261 'wal_ET',
1262 'wo',
1263 'wo_SN',
1264 'xh',
1265 'xh_ZA',
1266 'xog',
1267 'yav',
1268 'yi',
1269 'yi_US',
1270 'yo',
1271 'yo_BJ',
1272 'yo_NG',
1273 'yue',
1274 'yue_HK',
1275 'yue_Hans',
1276 'yue_Hant',
1277 'yuw',
1278 'yuw_PG',
1279 'zgh',
1280 'zh',
1281 'zh_CN',
1282 'zh_HK',
1283 'zh_Hans',
1284 'zh_Hans_HK',
1285 'zh_Hans_MO',
1286 'zh_Hans_SG',
1287 'zh_Hant',
1288 'zh_Hant_HK',
1289 'zh_Hant_MO',
1290 'zh_Hant_TW',
1291 'zh_MO',
1292 'zh_SG',
1293 'zh_TW',
1294 'zh_YUE',
1295 'zu',
1296 'zu_ZA',
1297 ];
1298 }
1299 }