Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added laravel-lang/native-currency-names package #148

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ jobs:
rm -rf docs/statuses/lang
rm -rf docs/statuses/native-locale-names
rm -rf docs/statuses/native-country-names
rm -rf docs/statuses/native-currency-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
mkdir docs/statuses/native-currency-names

- name: Download repositories
run: |
Expand All @@ -67,6 +69,7 @@ jobs:
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
git clone --no-tags --single-branch https://github.com/Laravel-Lang/native-currency-names.git tmp/native-currency-names

- name: Move translation statuses
run: |
Expand All @@ -75,20 +78,23 @@ jobs:
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/native-currency-names/docs/status.md docs/statuses/native-currency-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
mv -f tmp/native-currency-names/docs/statuses docs/statuses/native-currency-names/statuses

- name: Resolve page names
run: |
sed -i 's/# Completion Status/# Completion Status: Attributes/g' docs/statuses/attributes/index.md
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
sed -i 's/# Completion Status/# Completion Status: Native Country Names/g' docs/statuses/native-country-names/index.md
sed -i 's/# Completion Status/# Completion Status: Native Currency Names/g' docs/statuses/native-currency-names/index.md

- name: Resolve navigation links
run: |
Expand All @@ -97,12 +103,14 @@ jobs:
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/<\/table>/<\/table>\n\n[ [go back](..\/index.md) | [to top](\#) ]/g' docs/statuses/native-currency-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/*
sed -i 's/..\/status.md/..\/index.md/g' docs/statuses/native-currency-names/statuses/*

- name: Build VuePress site
run: npm run build
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"laravel-lang/locale-list": "^1.0",
"laravel-lang/locales": "^1.9",
"laravel-lang/native-country-names": "^1.0",
"laravel-lang/native-currency-names": "^1.0",
"laravel-lang/native-locale-names": "^1.4",
"laravel-lang/publisher": "^15.0"
},
Expand Down
2 changes: 2 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ module.exports = {
{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'},
{text: 'Native Currency Names', link: '/statuses/native-currency-names/index.md'},
]
},
],
Expand Down Expand Up @@ -141,6 +142,7 @@ module.exports = {
'/usage/features/locale-list.md',
'/usage/features/native-locale-names.md',
'/usage/features/native-country-names.md',
'/usage/features/native-currency-names.md',
'/usage/features/alignment.md',
'/usage/features/smart-punctuation.md',
]
Expand Down
4 changes: 4 additions & 0 deletions docs/installation/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ This package contains a list of localized country names.

I think there is no need to explain why it can be useful 🙂

## `laravel-lang/native-currency-names`

This package contains a list of localized currency names with their codes.

## `laravel-lang/locale-list`

This package contains a list of available locales that all Laravel Lang Team packages work with.
Expand Down
1 change: 1 addition & 0 deletions docs/installation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ 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
composer require laravel-lang/native-currency-names
```
1 change: 1 addition & 0 deletions docs/statuses/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
* [HTTP Statuses](http-statuses/index.md)
* [Native Locale Names](native-locale-names/index.md)
* [Native Country Names](native-country-names/index.md)
* [Native Currency Names](native-currency-names/index.md)
207 changes: 207 additions & 0 deletions docs/usage/features/native-currency-names.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
# Native Currency Names

If you want to get a localized list of currencies, then simply call the `Native::get()` method from
the [`laravel-lang/native-currency-names`](../../installation/index.md#alternative) package.

## Localized Names

```php
use LaravelLang\NativeCurrencyNames\Native;
use LaravelLang\LocaleList\Locale;

return Native::get('bn');
// or
return Native::get(Locale::Bengali)
```

Result:

```php
array:79 [
0 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "af"
+country: "ZA"
+code: "ZAR"
+numeric: 710
+name: "South African Rand"
+native: "Suid-Afrikaanse rand"
+localized: "দক্ষিণ আফ্রিকান রেন্ড"
}
1 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "sq"
+country: "AL"
+code: "ALL"
+numeric: 8
+name: "Albanian Lek"
+native: "Leku shqiptar"
+localized: "আলবেনিয়ান লেক"
}
2 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "ar"
+country: "EG"
+code: "EGP"
+numeric: 818
+name: "Egyptian Pound"
+native: "جنيه مصري"
+localized: "মিশরীয় পাউন্ড"
}
// ...
]
```

## 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\NativeCurrencyNames\Native;

return Native::get();
// or
return Native::get('');
// or
return Native::get(null);
// or
return Native::get('foo');
```

Result:

```php
array:79 [
0 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "af"
+country: "ZA"
+code: "ZAR"
+numeric: 710
+name: "South African Rand"
+native: "Suid-Afrikaanse rand"
+localized: "Suid-Afrikaanse rand"
}
1 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "sq"
+country: "AL"
+code: "ALL"
+numeric: 8
+name: "Albanian Lek"
+native: "Leku shqiptar"
+localized: "Leku shqiptar"
}
2 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "ar"
+country: "EG"
+code: "EGP"
+numeric: 818
+name: "Egyptian Pound"
+native: "جنيه مصري"
+localized: "جنيه مصري"
}
// ...
]
```

## 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\NativeCurrencyNames\Native;
use LaravelLang\NativeCurrencyNames\Enums\SortByy;

return Native::get('en', SortBy::Key);
```

Result:

```php
array:79 [
0 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "af"
+country: "ZA"
+code: "ZAR"
+numeric: 710
+name: "South African Rand"
+native: "Suid-Afrikaanse rand"
+localized: "South African Rand"
}
1 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "ar"
+country: "EG"
+code: "EGP"
+numeric: 818
+name: "Egyptian Pound"
+native: "جنيه مصري"
+localized: "Egyptian Pound"
}
2 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "az"
+country: "AZ"
+code: "AZN"
+numeric: 944
+name: "Azerbaijani Manat"
+native: "Azərbaycan Manatı"
+localized: "Azerbaijani Manat"
}
// ...
]
```

### Sort By Values

```php
use LaravelLang\NativeCurrencyNames\Native;
use LaravelLang\NativeCurrencyNames\Enums\SortByy;

return Native::get('en', SortBy::Value);
// or
return Native::get('en');
```

Result:

```php
array:79 [
0 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "af"
+country: "ZA"
+code: "ZAR"
+numeric: 710
+name: "South African Rand"
+native: "Suid-Afrikaanse rand"
+localized: "South African Rand"
}
1 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "sq"
+country: "AL"
+code: "ALL"
+numeric: 8
+name: "Albanian Lek"
+native: "Leku shqiptar"
+localized: "Albanian Lek"
}
2 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "ar"
+country: "EG"
+code: "EGP"
+numeric: 818
+name: "Egyptian Pound"
+native: "جنيه مصري"
+localized: "Egyptian Pound"
}
3 => LaravelLang\NativeCurrencyNames\Data\CurrencyData {
+locale: "hy"
+country: "AM"
+code: "AMD"
+numeric: 51
+name: "Armenian Dram"
+native: "հայկական դրամ"
+localized: "Armenian Dram"
}
// ...
]
```