Skip to content

Commit

Permalink
Merge pull request #127 from Laravel-Lang/5.x
Browse files Browse the repository at this point in the history
Added information about the localization of locale names
  • Loading branch information
andrey-helldar authored Nov 10, 2023
2 parents b239623 + 978b9cb commit a4d4b02
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"laravel-lang/http-statuses": "^3.5.0",
"laravel-lang/lang": "^13.3.0",
"laravel-lang/locales": "^1.6",
"laravel-lang/native-locale-names": "^1.1",
"laravel-lang/native-locale-names": "^1.2",
"laravel-lang/publisher": "^15.0"
},
"require-dev": {
Expand Down
26 changes: 18 additions & 8 deletions docs/installation/upgrade-guide/publisher/15.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,47 +56,57 @@ Also [changed](../../../usage/aliases.md) `aliases` section in the configuration
### Before

```php
LaravelLang\Publisher\Facades\Helpers\Locales::available(); // array<string>
use LaravelLang\Publisher\Facades\Helpers\Locales;

return Locales::available(); // array<string>
// ['en', 'fr', 'de', ...]

LaravelLang\Publisher\Facades\Helpers\Locales::getDefault(); // string
return Locales::getDefault(); // string
// de-DE
```

### After

```php
LaravelLang\Locales\Facades\Locales::available(); // array<LocaleData>
use LaravelLang\Publisher\Facades\Helpers\Locales;

return Locales::available(); // array<LocaleData>
// [<object>, <object>, ...]

LaravelLang\Locales\Facades\Locales::getDefault(); // LocaleData
return Locales::getDefault(); // LocaleData
// <object>

LaravelLang\Locales\Facades\Locales::raw()->available(); // array<string>
return Locales::raw()->available(); // array<string>
// ['en', 'fr', 'de', ...]

LaravelLang\Locales\Facades\Locales::raw()->getDefault(); // string
return Locales::raw()->getDefault(); // string
// de-DE
```

`<object>` is a DTO class of `LocaleData`:

```php
use LaravelLang\Locales\Data\LocaleData;

app()->setLocale('vi');

// Non aliased
LaravelLang\Locales\Data\LocaleData {
LocaleData {
+code: "de"
+type: "Latn"
+name: "German"
+native: "Deutsch"
+localized: "Tiếng Đức"
+regional: "de_DE"
}

// Aliased
LaravelLang\Locales\Data\LocaleData {
LocaleData {
+code: "de-DE"
+type: "Latn"
+name: "German"
+native: "Deutsch"
+localized: "Tiếng Đức"
+regional: "de_DE"
}
```
Expand Down
27 changes: 23 additions & 4 deletions docs/usage/features/facades.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,46 +39,65 @@ Locales::getFallback(): LocaleData
For example:

```php
use LaravelLang\Locales\Data\LocaleData;
use LaravelLang\Locales\Facades\Locales;

// config('app.locale') // de

return Locales::getDefault();

// Non aliased
LaravelLang\Locales\Data\LocaleData {
LocaleData {
+code: "de"
+type: "Latn"
+name: "German"
+native: "Deutsch"
+localized: "Deutsch"
+regional: "de_DE"
}

// Aliased
LaravelLang\Locales\Data\LocaleData {
LocaleData {
+code: "de-DE"
+type: "Latn"
+name: "German"
+native: "Deutsch"
+localized: "Deutsch"
+regional: "de_DE"
}
```
```php
use LaravelLang\Locales\Data\LocaleData;
use LaravelLang\Locales\Facades\Locales;

// config('app.locale') // vi

return Locales::get('de');

LaravelLang\Locales\Data\LocaleData {
LocaleData {
+code: "de"
+type: "Latn"
+name: "German"
+native: "Deutsch"
+localized: "Tiếng Đức"
+regional: "de_DE"
}
```
```php
use LaravelLang\Locales\Data\LocaleData;
use LaravelLang\Locales\Facades\Locales;

// config('app.locale') // de

return Locales::get('foo');

// Will return the default locale
LaravelLang\Locales\Data\LocaleData {
LocaleData {
+code: "de"
+type: "Latn"
+name: "German"
+native: "Deutsch"
+localized: "Deutsch"
+regional: "de_DE"
}
```
Expand Down

0 comments on commit a4d4b02

Please sign in to comment.