public static class DesktopLanguages The languages the user prefers, as the operating system lists them, for choosing the application's locale.
Remarks
Negotiate the list against the languages the application ships and set the result as its locale, unless the user chose one in its settings:
var locale = settings.Language ?? AppCatalog.ResolveLocale(DesktopLanguages.Preferred);
await services.GetRequiredService<IRunicApplicationLocale>().SetLocaleAsync(locale);It needs no window or host and works in command-line tools too.
Properties
Preferred
public static IReadOnlyList<string> Preferred { get; } The user's preferred languages as BCP 47 tags, such as de-CH or zh-Hans-CN, most preferred first, each once. Each read asks the operating system again.
Remarks
- Windows: the user's display languages (
GetUserPreferredUILanguages). - macOS: the user's preferred languages (
CFLocaleCopyPreferredLanguages, asNSLocale.preferredLanguages). - Linux and other systems: the list gettext reads,
LANGUAGEthenLC_ALL,LC_MESSAGESandLANG, converted from POSIX locales such asde_CH.UTF-8;LANGUAGEcounts only when the messages locale is notCorPOSIX, as gettext does.
When the system lists none, the list holds CultureInfo.CurrentUICulture's name, and is empty for the invariant culture.