diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e07e184cf..fa6901bb5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -52,11 +52,13 @@ jobs: rm -rf docs/statuses/http-statuses rm -rf docs/statuses/lang rm -rf docs/statuses/native-locale-names + rm -rf docs/statuses/native-country-names mkdir docs/statuses/attributes mkdir docs/statuses/http-statuses mkdir docs/statuses/lang mkdir docs/statuses/native-locale-names + mkdir docs/statuses/native-country-names - name: Download repositories run: | @@ -64,6 +66,7 @@ jobs: git clone --no-tags --single-branch https://github.com/Laravel-Lang/http-statuses.git tmp/http-statuses git clone --no-tags --single-branch https://github.com/Laravel-Lang/lang.git tmp/lang git clone --no-tags --single-branch https://github.com/Laravel-Lang/native-locale-names.git tmp/native-locale-names + git clone --no-tags --single-branch https://github.com/Laravel-Lang/native-country-names.git tmp/native-country-names - name: Move translation statuses run: | @@ -71,11 +74,13 @@ jobs: mv -f tmp/http-statuses/docs/status.md docs/statuses/http-statuses/index.md mv -f tmp/lang/docs/status.md docs/statuses/lang/index.md mv -f tmp/native-locale-names/docs/status.md docs/statuses/native-locale-names/index.md + mv -f tmp/native-country-names/docs/status.md docs/statuses/native-country-names/index.md mv -f tmp/attributes/docs/statuses docs/statuses/attributes/statuses mv -f tmp/http-statuses/docs/statuses docs/statuses/http-statuses/statuses mv -f tmp/lang/docs/statuses docs/statuses/lang/statuses mv -f tmp/native-locale-names/docs/statuses docs/statuses/native-locale-names/statuses + mv -f tmp/native-country-names/docs/statuses docs/statuses/native-country-names/statuses - name: Resolve page names run: | @@ -83,6 +88,7 @@ jobs: sed -i 's/# Completion Status/# Completion Status: HTTP Statuses/g' docs/statuses/http-statuses/index.md sed -i 's/# Completion Status/# Completion Status: Lang/g' docs/statuses/lang/index.md sed -i 's/# Completion Status/# Completion Status: Native Locale Names/g' docs/statuses/native-locale-names/index.md + sed -i 's/# Completion Status/# Completion Status: Native Locale Names/g' docs/statuses/native-country-names/index.md - name: Resolve navigation links run: | @@ -90,11 +96,13 @@ jobs: sed -i 's/<\/table>/<\/table>\n\n[ [go back](..\/index.md) | [to top](\#) ]/g' docs/statuses/http-statuses/index.md sed -i 's/<\/table>/<\/table>\n\n[ [go back](..\/index.md) | [to top](\#) ]/g' docs/statuses/lang/index.md sed -i 's/<\/table>/<\/table>\n\n[ [go back](..\/index.md) | [to top](\#) ]/g' docs/statuses/native-locale-names/index.md + sed -i 's/<\/table>/<\/table>\n\n[ [go back](..\/index.md) | [to top](\#) ]/g' docs/statuses/native-country-names/index.md sed -i 's/..\/status.md/..\/index.md/g' docs/statuses/attributes/statuses/* sed -i 's/..\/status.md/..\/index.md/g' docs/statuses/http-statuses/statuses/* sed -i 's/..\/status.md/..\/index.md/g' docs/statuses/lang/statuses/* sed -i 's/..\/status.md/..\/index.md/g' docs/statuses/native-locale-names/statuses/* + sed -i 's/..\/status.md/..\/index.md/g' docs/statuses/native-country-names/statuses/* - name: Build VuePress site run: npm run build diff --git a/composer.json b/composer.json index 95113f180..ec4b9f337 100644 --- a/composer.json +++ b/composer.json @@ -51,12 +51,14 @@ "laravel-lang/attributes": "^2.5.0", "laravel-lang/http-statuses": "^3.5.0", "laravel-lang/lang": "^13.3.0", + "laravel-lang/locale-list": "^1.0", "laravel-lang/locales": "^1.9", + "laravel-lang/native-country-names": "^1.0", + "laravel-lang/native-locale-names": "^1.4", "laravel-lang/publisher": "^15.0" }, "require-dev": { "dragon-code/support": "^6.11", - "laravel-lang/locale-list": "^1.0.1", "orchestra/testbench": "^8.14", "phpunit/phpunit": "^10.4.2", "symfony/var-dumper": "^6.3.6" diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index b5fdeeb59..8dc47e629 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -58,6 +58,7 @@ module.exports = { {text: 'Attributes', link: '/statuses/attributes/index.md'}, {text: 'HTTP Statuses', link: '/statuses/http-statuses/index.md'}, {text: 'Native Locale Names', link: '/statuses/native-locale-names/index.md'}, + {text: 'Native Country Names', link: '/statuses/native-country-names/index.md'}, ] }, ], @@ -139,6 +140,7 @@ module.exports = { '/usage/features/facades.md', '/usage/features/locale-list.md', '/usage/features/native-locale-names.md', + '/usage/features/native-country-names.md', '/usage/features/alignment.md', '/usage/features/smart-punctuation.md', ] diff --git a/docs/installation/about.md b/docs/installation/about.md index 6c45732e5..598445f81 100644 --- a/docs/installation/about.md +++ b/docs/installation/about.md @@ -78,7 +78,13 @@ This package solves this problem. ## `laravel-lang/native-locale-names` -This package contains a list of localized language names. +This package contains a list of localized locale names. + +I think there is no need to explain why it can be useful 🙂 + +## `laravel-lang/native-country-names` + +This package contains a list of localized country names. I think there is no need to explain why it can be useful 🙂 diff --git a/docs/installation/index.md b/docs/installation/index.md index 72b7a6cbe..14d0e3e9b 100644 --- a/docs/installation/index.md +++ b/docs/installation/index.md @@ -12,14 +12,21 @@ php artisan lang:update ## Recommended -To get the latest version of `Laravel Lang: Common`, simply require the project using [Composer](https://getcomposer.org): +To get the latest version of `Laravel Lang: Common`, simply require the project +using [Composer](https://getcomposer.org): ```bash:no-line-numbers composer require --dev laravel-lang/common ``` ::: tip -If you are using the list of localizations from the `Laravel Lang: Publisher` package in production, then use this command instead: `composer require laravel-lang/common`. +If you need a list of locales in production, separately install the `laravel-lang/locales` dependency by calling the +console command: + +```bash:no-line-numbers +composer require laravel-lang/locales +``` + ::: Now you can manage localizations: @@ -43,4 +50,5 @@ composer require --dev laravel-lang/http-statuses composer require laravel-lang/locales composer require laravel-lang/locale-list composer require laravel-lang/native-locale-names +composer require laravel-lang/native-country-names ``` diff --git a/docs/usage/features/native-country-names.md b/docs/usage/features/native-country-names.md new file mode 100644 index 000000000..80f8405c0 --- /dev/null +++ b/docs/usage/features/native-country-names.md @@ -0,0 +1,196 @@ +# Native Country Names + +If you want to get a localized list of countries, then simply call the `Native::get()` method from +the [`laravel-lang/native-country-names`](../../installation/index.md#installation) package. + +## Localized Names + +```php +use LaravelLang\NativeCountryNames\Native; +use LaravelLang\LocaleList\Locale; + +return Native::get('bn'); +// or +return Native::get(Locale::Bengali) +``` + +Result: + +```php +array:79 [ + "is" => "আইসল্যান্ড" + "az" => "আজারবাইজান" + "ps" => "আফগানিস্তান" + "hy" => "আর্মেনিয়া" + "sq" => "আলবেনিয়া" + "uk" => "ইউক্রেন" + "he" => "ইজরায়েল" + "it" => "ইতালি" + "sc" => "ইতালি" + "id" => "ইন্দোনেশিয়া" + "fa" => "ইরান" + // ... +] +``` + +## Native Names + +You can also get a list of localized names if you call the `get` method without passing parameters. +The same thing will happen if you pass an incorrect or empty value to the parameter. + +```php +use LaravelLang\NativeCountryNames\Native; + +return Native::get(); +// or +return Native::get(''); +// or +return Native::get(null); +// or +return Native::get('foo'); +``` + +Result: + +```php +array:79 [ + "az" => "Azərbaycan" + "bs" => "Bosna I Hercegovina" + "pt" => "Brasil" + "pt_BR" => "Brasil" + "sr_Latn_ME" => "Crna Gora" + "da" => "Danmark" + "de" => "Deutschland" + "et" => "Eesti" + "eu" => "Espainia" + "ca" => "Espanya" + "es" => "España" + "gl" => "España" + "oc" => "Fr" + "fr" => "France" + "hr" => "Hrvatska" + "id" => "Indonesia" + "it" => "Italia" + "sc" => "Itàlia" + "lv" => "Latvija" + "lt" => "Lietuva" + "hu" => "Magyarország" + "ms" => "Malaysia" + "nl" => "Nederland" + "nn" => "Noreg" + "nb" => "Norge" + "uz_Latn" => "Oʻzbekiston" + "tl" => "Philippines" + "fil" => "Pilipinas" + "pl" => "Polska" + "ro" => "România" + "de_CH" => "Schweiz" + "sq" => "Shqipëri" + "sl" => "Slovenija" + "sk" => "Slovensko" + "sr_Latn" => "Srbija" + "af" => "Suid-Afrika" + "fi" => "Suomi" + "sv" => "Sverige" + "sw" => "Tanzania" + "tr" => "Türkiye" + "tk" => "Türkmenistan" + "en" => "United States" + "vi" => "Việt Nam" + "cy" => "Y Deyrnas Unedig" + "is" => "Ísland" + "cs" => "Česko" + "el" => "Ελλάδα" + "uz_Cyrl" => "Ўзбекистон" + "be" => "Беларусь" + "bg" => "България" + "mn" => "Монгол" + "ru" => "Россия" + "mk" => "Северна Македонија" + "sr_Cyrl" => "Србија" + "tg" => "Тоҷикистон" + "uk" => "Україна" + "kk" => "Қазақстан" + "hy" => "Հայաստան" + "he" => "ישראל" + "ps" => "افغانستان" + "fa" => "ایران" + "ug" => "جۇڭگو" + "ar" => "مصر" + "ur" => "پاکستان" + "ne" => "नेपाल" + "hi" => "भारत" + "mr" => "भारत" + "bn" => "বাংলাদেশ" + "gu" => "ભારત" + "kn" => "ಭಾರತ" + "si" => "ශ්\u{200D}රී ලංකාව" + "th" => "ไทย" + "ka" => "საქართველო" + "km" => "កម្ពុជា" + "zh_CN" => "中国" + "zh_HK" => "中国香港特别行政区" + "zh_TW" => "台湾" + "ja" => "日本" + "ko" => "대한민국" +] +``` + +## Sorting + +To get the result sorted by key or value, pass `SortBy` to the enum parameter. + +By default, sorting by values is applied. + +### Sort By Keys + +```php +use LaravelLang\NativeCountryNames\Native; +use LaravelLang\NativeCountryNames\Enums\SortBy; + +return Native::get('en', SortBy::Key); +``` + +Result: + +```php +array:79 [ + "af" => "South Africa" + "ar" => "Egypt" + "az" => "Azerbaijan" + "be" => "Belarus" + "bg" => "Bulgaria" + "bn" => "Bangladesh" + "bs" => "Bosnia & Herzegovina" + "ca" => "Spain" + "cs" => "Czechia" + // ... +] +``` + +### Sort By Values + +```php +use LaravelLang\NativeCountryNames\Native; +use LaravelLang\NativeCountryNames\Enums\SortBy; + +return Native::get('en', SortBy::Value); +// or +return Native::get('en'); +``` + +Result: + +```php +array:79 [ + "ps" => "Afghanistan" + "sq" => "Albania" + "hy" => "Armenia" + "az" => "Azerbaijan" + "bn" => "Bangladesh" + "be" => "Belarus" + "bs" => "Bosnia & Herzegovina" + "pt" => "Brazil" + // ... +] +``` diff --git a/docs/usage/features/native-locale-names.md b/docs/usage/features/native-locale-names.md index dcd2b173c..b06fc0dc4 100644 --- a/docs/usage/features/native-locale-names.md +++ b/docs/usage/features/native-locale-names.md @@ -1,7 +1,7 @@ # Native Locale Names If you want to get a localized list of languages, then simply call the `Native::get()` method from -the [`laravel-lang/native-locale-names`](../../installation/index.md) package. +the [`laravel-lang/native-locale-names`](../../installation/index.md#alternative) package. ## Localized Names