From 6430d1a2cce934db9bcb0f44c30e056ad4268fa2 Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Fri, 29 Dec 2023 22:46:44 +0300 Subject: [PATCH 1/2] Adding new locales --- composer.json | 4 +- config/private.php | 239 ++++++++++++++++++++++++ tests/Datasets/LocaleTypes.php | 71 +++++++ tests/Datasets/Locales.php | 47 +++++ tests/Unit/Facades/Locales/InfoTest.php | 32 ++++ 5 files changed, 391 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 40c2337..5b7f2a6 100644 --- a/composer.json +++ b/composer.json @@ -31,10 +31,10 @@ "archtechx/enums": "^0.3.2", "dragon-code/support": "^6.11.3", "illuminate/collections": "^10.0", - "laravel-lang/locale-list": "^1.1", + "laravel-lang/locale-list": "^1.2", "laravel-lang/native-country-names": "^1.2", "laravel-lang/native-currency-names": "^1.2", - "laravel-lang/native-locale-names": "^2.1.0" + "laravel-lang/native-locale-names": "^2.2" }, "require-dev": { "orchestra/testbench": "^8.0", diff --git a/config/private.php b/config/private.php index 1fa98b4..191b40b 100644 --- a/config/private.php +++ b/config/private.php @@ -30,6 +30,11 @@ 'regional' => 'sq_AL', ], + Locale::Amharic->value => [ + 'type' => 'Ethi', + 'regional' => 'am_ET', + ], + Locale::Arabic->value => [ 'type' => 'Arab', 'regional' => 'ar_AE', @@ -42,11 +47,26 @@ 'regional' => 'hy_AM', ], + Locale::Assamese->value => [ + 'type' => 'Beng', + 'regional' => 'as_IN', + ], + Locale::Azerbaijani->value => [ 'type' => 'Latn', 'regional' => 'az_AZ', ], + Locale::Bambara->value => [ + 'type' => 'Latn', + 'regional' => 'bm_ML', + ], + + Locale::Bhojpuri->value => [ + 'type' => 'Deva', + 'regional' => 'bho_IN', + ], + Locale::Basque->value => [ 'type' => 'Latn', 'regional' => 'eu_ES', @@ -77,6 +97,11 @@ 'regional' => 'ca_ES', ], + Locale::Cebuano->value => [ + 'type' => 'Latn', + 'regional' => 'ceb_PH', + ], + Locale::CentralKhmer->value => [ 'type' => 'Khmr', 'regional' => 'km_KH', @@ -112,6 +137,11 @@ 'regional' => 'da_DK', ], + Locale::Dogri->value => [ + 'type' => 'Deva', + 'regional' => 'doi_IN', + ], + Locale::Dutch->value => [ 'type' => 'Latn', 'regional' => 'nl_NL', @@ -122,11 +152,21 @@ 'regional' => 'en_GB', ], + Locale::Esperanto->value => [ + 'type' => 'Latn', + 'regional' => 'eo_001', + ], + Locale::Estonian->value => [ 'type' => 'Latn', 'regional' => 'et_EE', ], + Locale::Ewe->value => [ + 'type' => 'Latn', + 'regional' => 'ee_GH', + ], + Locale::Finnish->value => [ 'type' => 'Latn', 'regional' => 'fi_FI', @@ -137,6 +177,11 @@ 'regional' => 'fr_FR', ], + Locale::Frisian->value => [ + 'type' => 'Latn', + 'regional' => 'fy_NL', + ], + Locale::Galician->value => [ 'type' => 'Latn', 'regional' => 'gl_ES', @@ -167,6 +212,16 @@ 'regional' => 'gu_IN', ], + Locale::Hausa->value => [ + 'type' => 'Latn', + 'regional' => 'ha_NG', + ], + + Locale::Hawaiian->value => [ + 'type' => 'Latn', + 'regional' => 'haw', + ], + Locale::Hebrew->value => [ 'type' => 'Hebr', 'regional' => 'he_IL', @@ -189,11 +244,21 @@ 'regional' => 'is_IS', ], + Locale::Igbo->value => [ + 'type' => 'Latn', + 'regional' => 'ig_NG', + ], + Locale::Indonesian->value => [ 'type' => 'Latn', 'regional' => 'id_ID', ], + Locale::Irish->value => [ + 'type' => 'Latn', + 'regional' => 'ga_IE', + ], + Locale::Italian->value => [ 'type' => 'Latn', 'regional' => 'it_IT', @@ -214,41 +279,118 @@ 'regional' => 'kk_KZ', ], + Locale::Kinyarwanda->value => [ + 'type' => 'Latn', + 'regional' => 'rw_RW', + ], + Locale::Korean->value => [ 'type' => 'Hang', 'regional' => 'ko_KR', ], + Locale::Kurdish->value => [ + 'type' => 'Latn', + 'regional' => 'ku_TR', + ], + + Locale::KurdishSorani->value => [ + 'type' => 'Arab', + 'regional' => 'ckb_IQ', + + 'direction' => Direction::RightToLeft, + ], + + Locale::Kyrgyz->value => [ + 'type' => 'Cyrl', + 'regional' => 'ky_KG', + ], + + Locale::Lao->value => [ + 'type' => 'Laoo', + 'regional' => 'lo_LA', + ], + Locale::Latvian->value => [ 'type' => 'Latn', 'regional' => 'lv_LV', ], + Locale::Lingala->value => [ + 'type' => 'Latn', + 'regional' => 'ln_CD', + ], + Locale::Lithuanian->value => [ 'type' => 'Latn', 'regional' => 'lt_LT', ], + Locale::Luganda->value => [ + 'type' => 'Latn', + 'regional' => 'lg_UG', + ], + + Locale::Luxembourgish->value => [ + 'type' => 'Latn', + 'regional' => 'lb_LU', + ], + Locale::Macedonian->value => [ 'type' => 'Cyrl', 'regional' => 'mk_MK', ], + Locale::Maithili->value => [ + 'type' => 'Deva', + 'regional' => 'mai_IN', + ], + + Locale::Malagasy->value => [ + 'type' => 'Latn', + 'regional' => 'mg_MG', + ], + + Locale::Malayalam->value => [ + 'type' => 'Mlym', + 'regional' => 'ml_IN', + ], + Locale::Malay->value => [ 'type' => 'Latn', 'regional' => 'ms_MY', ], + Locale::Maltese->value => [ + 'type' => 'Latn', + 'regional' => 'mt_MT', + ], + Locale::Marathi->value => [ 'type' => 'Deva', 'regional' => 'mr_IN', ], + Locale::Maori->value => [ + 'type' => 'Latn', + 'regional' => 'mi_NZ', + ], + + Locale::MeiteilonManipuri->value => [ + 'type' => 'Beng', + 'regional' => 'mni_IN', + ], + Locale::Mongolian->value => [ 'type' => 'Mong', 'regional' => 'mn_MN', ], + Locale::MyanmarBurmese->value => [ + 'type' => 'Mymr', + 'regional' => 'my_MM', + ], + Locale::Nepali->value => [ 'type' => 'Deva', 'regional' => 'ne', @@ -269,6 +411,16 @@ 'regional' => 'oc_FR', ], + Locale::OdiaOriya->value => [ + 'type' => 'Orya', + 'regional' => 'or_IN', + ], + + Locale::Oromo->value => [ + 'type' => 'Latn', + 'regional' => 'om_ET', + ], + Locale::Pashto->value => [ 'type' => 'Arab', 'regional' => 'ps_AF', @@ -303,6 +455,16 @@ 'regional' => 'pt_BR', ], + Locale::Punjabi->value => [ + 'type' => 'Guru', + 'regional' => 'pa_IN', + ], + + Locale::Quechua->value => [ + 'type' => 'Latn', + 'regional' => 'qu_PE', + ], + Locale::Romanian->value => [ 'type' => 'Latn', 'regional' => 'ro_RO', @@ -313,11 +475,21 @@ 'regional' => 'ru_RU', ], + Locale::Sanskrit->value => [ + 'type' => 'Deva', + 'regional' => 'sa_IN', + ], + Locale::Sardinian->value => [ 'type' => 'Latn', 'regional' => 'sc_IT', ], + Locale::ScotsGaelic->value => [ + 'type' => 'Latn', + 'regional' => 'gd_GB', + ], + Locale::SerbianCyrillic->value => [ 'type' => 'Cyrl', 'regional' => 'sr_RS', @@ -333,6 +505,18 @@ 'regional' => 'sr_Latn_ME', ], + Locale::Shona->value => [ + 'type' => 'Latn', + 'regional' => 'sn_ZW', + ], + + Locale::Sindhi->value => [ + 'type' => 'Arab', + 'regional' => 'sd_PK', + + 'direction' => Direction::RightToLeft, + ], + Locale::Sinhala->value => [ 'type' => 'Sinh', 'regional' => 'si_LK', @@ -348,11 +532,21 @@ 'regional' => 'sl_SI', ], + Locale::Somali->value => [ + 'type' => 'Latn', + 'regional' => 'so_SO', + ], + Locale::Spanish->value => [ 'type' => 'Latn', 'regional' => 'es_ES', ], + Locale::Sundanese->value => [ + 'type' => 'Latn', + 'regional' => 'su_ID', + ], + Locale::Swahili->value => [ 'type' => 'Latn', 'regional' => 'sw_KE', @@ -373,6 +567,26 @@ 'regional' => 'tg_TJ', ], + Locale::Tamil->value => [ + 'type' => 'Taml', + 'regional' => 'ta_IN', + ], + + Locale::Tatar->value => [ + 'type' => 'Cyrl', + 'regional' => 'tt_RU', + ], + + Locale::Telugu->value => [ + 'type' => 'Telu', + 'regional' => 'te_IN', + ], + + Locale::Tigrinya->value => [ + 'type' => 'Ethi', + 'regional' => 'ti_ET', + ], + Locale::Thai->value => [ 'type' => 'Thai', 'regional' => 'th_TH', @@ -388,6 +602,11 @@ 'regional' => 'tk_TM', ], + Locale::TwiAkan->value => [ + 'type' => 'Latn', + 'regional' => 'ak_GH', + ], + Locale::Uighur->value => [ 'type' => 'Arab', 'regional' => 'ug_CN', @@ -426,5 +645,25 @@ 'type' => 'Latn', 'regional' => 'cy_GB', ], + + Locale::Xhosa->value => [ + 'type' => 'Latn', + 'regional' => 'xh_ZA', + ], + + Locale::Yiddish->value => [ + 'type' => 'Hebr', + 'regional' => 'yi_001', + ], + + Locale::Yoruba->value => [ + 'type' => 'Latn', + 'regional' => 'yo_NG', + ], + + Locale::Zulu->value => [ + 'type' => 'Latn', + 'regional' => 'zu_ZA', + ], ], ]; diff --git a/tests/Datasets/LocaleTypes.php b/tests/Datasets/LocaleTypes.php index b5469bd..81c56b5 100644 --- a/tests/Datasets/LocaleTypes.php +++ b/tests/Datasets/LocaleTypes.php @@ -21,48 +21,75 @@ Locale::Afrikaans, Locale::Albanian, Locale::Azerbaijani, + Locale::Bambara, Locale::Basque, Locale::Bosnian, Locale::Catalan, + Locale::Cebuano, Locale::Croatian, Locale::Czech, Locale::Danish, Locale::Dutch, Locale::English, + Locale::Esperanto, Locale::Estonian, + Locale::Ewe, Locale::Finnish, Locale::French, + Locale::Frisian, Locale::Galician, Locale::German, Locale::GermanSwitzerland, + Locale::Hausa, + Locale::Hawaiian, Locale::Hungarian, Locale::Icelandic, + Locale::Igbo, Locale::Indonesian, + Locale::Irish, Locale::Italian, + Locale::Kinyarwanda, + Locale::Kurdish, Locale::Latvian, + Locale::Lingala, Locale::Lithuanian, + Locale::Luganda, + Locale::Luxembourgish, + Locale::Malagasy, Locale::Malay, + Locale::Maltese, + Locale::Maori, Locale::NorwegianBokmal, Locale::NorwegianNynorsk, Locale::Occitan, + Locale::Oromo, Locale::Pilipino, Locale::Polish, Locale::Portuguese, Locale::PortugueseBrazil, + Locale::Quechua, Locale::Romanian, Locale::Sardinian, + Locale::ScotsGaelic, Locale::SerbianLatin, Locale::SerbianMontenegrin, + Locale::Shona, Locale::Slovak, Locale::Slovenian, + Locale::Somali, Locale::Spanish, + Locale::Sundanese, Locale::Swahili, Locale::Swedish, Locale::Tagalog, Locale::Turkish, + Locale::TwiAkan, Locale::UzbekLatin, Locale::Vietnamese, Locale::Welsh, + Locale::Xhosa, + Locale::Yoruba, + Locale::Zulu, ]); dataset('locale-type-armn', [ @@ -73,10 +100,12 @@ Locale::Belarusian, Locale::Bulgarian, Locale::Kazakh, + Locale::Kyrgyz, Locale::Macedonian, Locale::Russian, Locale::SerbianCyrillic, Locale::Tajik, + Locale::Tatar, Locale::Turkmen, Locale::Ukrainian, Locale::UzbekCyrillic, @@ -84,14 +113,18 @@ dataset('locale-type-arab', [ Locale::Arabic, + Locale::KurdishSorani, Locale::Pashto, Locale::Persian, + Locale::Sindhi, Locale::Uighur, Locale::Urdu, ]); dataset('locale-type-beng', [ + Locale::Assamese, Locale::Bengali, + Locale::MeiteilonManipuri, ]); dataset('locale-type-khmr', [ @@ -118,12 +151,17 @@ dataset('locale-type-hebr', [ Locale::Hebrew, + Locale::Yiddish, ]); dataset('locale-type-deva', [ + Locale::Bhojpuri, + Locale::Dogri, Locale::Hindi, + Locale::Maithili, Locale::Marathi, Locale::Nepali, + Locale::Sanskrit, ]); dataset('locale-type-jpan', [ @@ -149,3 +187,36 @@ dataset('locale-type-thai', [ Locale::Thai, ]); + +dataset('locale-type-ethi', [ + Locale::Amharic, + Locale::Tigrinya, +]); + +dataset('locale-type-laoo', [ + Locale::Lao, +]); + +dataset('locale-type-mlym', [ + Locale::Malayalam, +]); + +dataset('locale-type-mymr', [ + Locale::MyanmarBurmese, +]); + +dataset('locale-type-orya', [ + Locale::OdiaOriya, +]); + +dataset('locale-type-guru', [ + Locale::Punjabi, +]); + +dataset('locale-type-taml', [ + Locale::Tamil, +]); + +dataset('locale-type-telu', [ + Locale::Telugu, +]); diff --git a/tests/Datasets/Locales.php b/tests/Datasets/Locales.php index 3c51cc6..c53c084 100644 --- a/tests/Datasets/Locales.php +++ b/tests/Datasets/Locales.php @@ -29,14 +29,19 @@ dataset('locale-direction-left-to-right', [ Locale::Afrikaans, Locale::Albanian, + Locale::Amharic, Locale::Armenian, + Locale::Assamese, Locale::Azerbaijani, + Locale::Bambara, Locale::Basque, Locale::Belarusian, Locale::Bengali, + Locale::Bhojpuri, Locale::Bosnian, Locale::Bulgarian, Locale::Catalan, + Locale::Cebuano, Locale::CentralKhmer, Locale::Chinese, Locale::ChineseHongKong, @@ -44,69 +49,111 @@ Locale::Croatian, Locale::Czech, Locale::Danish, + Locale::Dogri, Locale::Dutch, Locale::English, + Locale::Esperanto, Locale::Estonian, + Locale::Ewe, Locale::Finnish, Locale::French, + Locale::Frisian, Locale::Galician, Locale::Georgian, Locale::German, Locale::GermanSwitzerland, Locale::Greek, Locale::Gujarati, + Locale::Hausa, + Locale::Hawaiian, Locale::Hindi, Locale::Hungarian, Locale::Icelandic, + Locale::Igbo, Locale::Indonesian, + Locale::Irish, Locale::Italian, Locale::Japanese, Locale::Kannada, Locale::Kazakh, + Locale::Kinyarwanda, Locale::Korean, + Locale::Kurdish, + Locale::Kyrgyz, + Locale::Lao, Locale::Latvian, + Locale::Lingala, Locale::Lithuanian, + Locale::Luganda, + Locale::Luxembourgish, Locale::Macedonian, + Locale::Maithili, + Locale::Malagasy, Locale::Malay, + Locale::Malayalam, + Locale::Maltese, + Locale::Maori, Locale::Marathi, + Locale::MeiteilonManipuri, Locale::Mongolian, + Locale::MyanmarBurmese, Locale::Nepali, Locale::NorwegianBokmal, Locale::NorwegianNynorsk, Locale::Occitan, + Locale::OdiaOriya, + Locale::Oromo, Locale::Pilipino, Locale::Polish, Locale::Portuguese, Locale::PortugueseBrazil, + Locale::Punjabi, + Locale::Quechua, Locale::Romanian, Locale::Russian, + Locale::Sanskrit, Locale::Sardinian, + Locale::ScotsGaelic, Locale::SerbianCyrillic, Locale::SerbianLatin, Locale::SerbianMontenegrin, + Locale::Shona, Locale::Sinhala, Locale::Slovak, Locale::Slovenian, + Locale::Somali, Locale::Spanish, + Locale::Sundanese, Locale::Swahili, Locale::Swedish, Locale::Tagalog, Locale::Tajik, + Locale::Tamil, + Locale::Tatar, + Locale::Telugu, Locale::Thai, + Locale::Tigrinya, Locale::Turkish, Locale::Turkmen, + Locale::TwiAkan, Locale::Ukrainian, Locale::UzbekCyrillic, Locale::UzbekLatin, Locale::Vietnamese, Locale::Welsh, + Locale::Xhosa, + Locale::Yiddish, + Locale::Yoruba, + Locale::Zulu, ]); dataset('locale-direction-right-to-left', [ Locale::Arabic, Locale::Hebrew, + Locale::KurdishSorani, Locale::Pashto, Locale::Persian, + Locale::Sindhi, Locale::Uighur, Locale::Urdu, ]); diff --git a/tests/Unit/Facades/Locales/InfoTest.php b/tests/Unit/Facades/Locales/InfoTest.php index 2468ad5..227bdd5 100644 --- a/tests/Unit/Facades/Locales/InfoTest.php +++ b/tests/Unit/Facades/Locales/InfoTest.php @@ -119,6 +119,38 @@ expect(Locales::info($locale))->type->toBe('Thai'); })->with('locale-type-thai'); +it('checks the Ethi locale type', function (Locale $locale) { + expect(Locales::info($locale))->type->toBe('Ethi'); +})->with('locale-type-ethi'); + +it('checks the Laoo locale type', function (Locale $locale) { + expect(Locales::info($locale))->type->toBe('Laoo'); +})->with('locale-type-laoo'); + +it('checks the Mlym locale type', function (Locale $locale) { + expect(Locales::info($locale))->type->toBe('Mlym'); +})->with('locale-type-mlym'); + +it('checks the Mymr locale type', function (Locale $locale) { + expect(Locales::info($locale))->type->toBe('Mymr'); +})->with('locale-type-mymr'); + +it('checks the Orya locale type', function (Locale $locale) { + expect(Locales::info($locale))->type->toBe('Orya'); +})->with('locale-type-orya'); + +it('checks the Guru locale type', function (Locale $locale) { + expect(Locales::info($locale))->type->toBe('Guru'); +})->with('locale-type-guru'); + +it('checks the Taml locale type', function (Locale $locale) { + expect(Locales::info($locale))->type->toBe('Taml'); +})->with('locale-type-taml'); + +it('checks the Telu locale type', function (Locale $locale) { + expect(Locales::info($locale))->type->toBe('Telu'); +})->with('locale-type-telu'); + it('checking information for incorrect locale', function (?string $locale) { expect(Locales::info($locale)) ->code->toBeString()->toBe('en') From dab0e0de822ae6f44a2d1f86b65a0d15c366104d Mon Sep 17 00:00:00 2001 From: Andrey Helldar Date: Sat, 30 Dec 2023 00:38:47 +0300 Subject: [PATCH 2/2] Added support for new localization codes --- composer.json | 10 +++++----- tests/Unit/Facades/Locales/InfoTest.php | 22 +++++++++++++++------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 5b7f2a6..e145483 100644 --- a/composer.json +++ b/composer.json @@ -31,17 +31,17 @@ "archtechx/enums": "^0.3.2", "dragon-code/support": "^6.11.3", "illuminate/collections": "^10.0", - "laravel-lang/locale-list": "^1.2", - "laravel-lang/native-country-names": "^1.2", - "laravel-lang/native-currency-names": "^1.2", - "laravel-lang/native-locale-names": "^2.2" + "laravel-lang/locale-list": "^1.2-RC1", + "laravel-lang/native-country-names": "^1.3-RC1", + "laravel-lang/native-currency-names": "^1.3-RC1", + "laravel-lang/native-locale-names": "^2.2-RC2" }, "require-dev": { "orchestra/testbench": "^8.0", "pestphp/pest": "^2.24.1", "symfony/var-dumper": "^6.0 || ^7.0" }, - "minimum-stability": "stable", + "minimum-stability": "RC", "prefer-stable": true, "autoload": { "psr-4": { diff --git a/tests/Unit/Facades/Locales/InfoTest.php b/tests/Unit/Facades/Locales/InfoTest.php index 227bdd5..ddfe8fb 100644 --- a/tests/Unit/Facades/Locales/InfoTest.php +++ b/tests/Unit/Facades/Locales/InfoTest.php @@ -23,23 +23,31 @@ expect(Locales::info($locale)) ->code->toBeString()->toBe($locale) ->type->toBeString()->toBeIn([ - 'Latn', - 'Armn', - 'Cyrl', 'Arab', + 'Armn', 'Beng', - 'Khmr', - 'Hans', + 'Cyrl', + 'Deva', + 'Ethi', 'Geor', 'Grek', 'Gujr', + 'Guru', + 'Hang', + 'Hans', 'Hebr', - 'Deva', 'Jpan', + 'Khmr', 'Knda', - 'Hang', + 'Laoo', + 'Latn', + 'Mlym', 'Mong', + 'Mymr', + 'Orya', 'Sinh', + 'Taml', + 'Telu', 'Thai', ]) ->native->toBeString()