Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d7fc1c

Browse files
authored
Improve locale documentation
1 parent fccd6b7 commit 8d7fc1c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

resources/views/docs/desktop/1/the-basics/application.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,20 @@ The facade offers several methods for accessing some of the system's localisatio
7676
This data can be helpful for localising your application, e.g. if you want to suggest the corresponding language to the user on first launch.
7777

7878
```php
79-
App::getLocale();
80-
App::getLocaleCountryCode();
81-
App::getSystemLocale();
79+
App::getLocale(); // e.g. "de", "fr-FR"
80+
App::getLocaleCountryCode(); // e.g. "US", "DE"
81+
App::getSystemLocale(); // e.g. "it-IT", "de-DE"
8282
```
8383

84-
The `getLocale` method will return the full locale string used by the app. This includes both the language and the country or region.
85-
`getLocaleCountryCode` returns only the country code part of the locale.
84+
The `getLocale` method will return the locale used by the app.
85+
Dependening on the user's settings, this might include both the language and the country / region or the language only.
86+
It is based on Chromiums `l10n_util` library; see [this page](https://source.chromium.org/chromium/chromium/src/+/main:ui/base/l10n/l10n_util.cc) to see possible values.
87+
88+
`getLocaleCountryCode` returns the user's system country code (using the [ISO 3166 code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
89+
This information is pulled from native OS APIs. If it is not possible to detect this information, an empty string will be returned.
90+
8691
With `getSystemLocale` you can access the system-wide locale setting. This is the locale set at the operating system level, not necessarily what the app is using.
92+
Under Windows and Linux, Chromium's `i18n` library is used to evaluate this information. macOS will use `[NSLocale currentLocale]`.
8793

8894

8995
### App Badge Count

0 commit comments

Comments
 (0)