From fccd6b7541ef1d63e40d5b5b479c6d8d5963ab17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Gl=C3=BCck?= Date: Sat, 16 Aug 2025 11:33:40 +0200 Subject: [PATCH 1/2] Add documentation for new locale information methods --- .../docs/desktop/1/the-basics/application.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/resources/views/docs/desktop/1/the-basics/application.md b/resources/views/docs/desktop/1/the-basics/application.md index da0c88f5..6770eb83 100644 --- a/resources/views/docs/desktop/1/the-basics/application.md +++ b/resources/views/docs/desktop/1/the-basics/application.md @@ -70,6 +70,22 @@ 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(); +App::getLocaleCountryCode(); +App::getSystemLocale(); +``` + +The `getLocale` method will return the full locale string used by the app. This includes both the language and the country or region. +`getLocaleCountryCode` returns only the country code part of the locale. +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. + + ### App Badge Count _Only available on macOS and Linux_ From 8d7fc1c9a0c604d8699df758f9ec6d85302547cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Gl=C3=BCck?= <65236355+JulianGlueck@users.noreply.github.com> Date: Fri, 22 Aug 2025 11:05:31 +0200 Subject: [PATCH 2/2] Improve locale documentation --- .../docs/desktop/1/the-basics/application.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/resources/views/docs/desktop/1/the-basics/application.md b/resources/views/docs/desktop/1/the-basics/application.md index 6770eb83..f48cceb9 100644 --- a/resources/views/docs/desktop/1/the-basics/application.md +++ b/resources/views/docs/desktop/1/the-basics/application.md @@ -76,14 +76,20 @@ The facade offers several methods for accessing some of the system's localisatio 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(); -App::getLocaleCountryCode(); -App::getSystemLocale(); +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 full locale string used by the app. This includes both the language and the country or region. -`getLocaleCountryCode` returns only the country code part of the locale. +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