Skip to content
Open
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
22 changes: 22 additions & 0 deletions resources/views/docs/desktop/1/the-basics/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,28 @@ To get the current app version, use the `version` method. The version is defined
$version = App::version();
```

### Locale information

The facade offers several methods for accessing some of the system's localisation information.
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.

```php
App::getLocale(); // e.g. "de", "fr-FR"
App::getLocaleCountryCode(); // e.g. "US", "DE"
App::getSystemLocale(); // e.g. "it-IT", "de-DE"
```

The `getLocale` method will return the locale used by the app.
Dependening on the user's settings, this might include both the language and the country / region or the language only.
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.

`getLocaleCountryCode` returns the user's system country code (using the [ISO 3166 code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
This information is pulled from native OS APIs. If it is not possible to detect this information, an empty string will be returned.

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.
Under Windows and Linux, Chromium's `i18n` library is used to evaluate this information. macOS will use `[NSLocale currentLocale]`.


### App Badge Count
_Only available on macOS and Linux_

Expand Down