Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Not correct Default system language load for MessageFormatExtensions #15440

Closed
XTorLukas opened this issue May 21, 2024 · 2 comments · Fixed by #15443
Closed

Bug: Not correct Default system language load for MessageFormatExtensions #15440

XTorLukas opened this issue May 21, 2024 · 2 comments · Fixed by #15443
Labels
bug Something isn't working 👀

Comments

@XTorLukas
Copy link
Contributor

XTorLukas commented May 21, 2024

Description

The system language is incorrectly defined, a problem occurs when Formater takes the default 'en' for parsing

Screenshot problem

  1. If I don't choose the exact language
    image
  2. Language not set to system language
    image
  3. This causes the plural localization to function incorrectly
    image

Steps To Reproduce

  1. If not specified default language load OS default correctly
@XTorLukas XTorLukas added the bug Something isn't working 👀 label May 21, 2024
@XTorLukas
Copy link
Contributor Author

We overlooked this because I had it selected explicitly, but I have a quick workaround

@XTorLukas
Copy link
Contributor Author

It would be enough for this method to be static

private void AddSupportedAppLanguages()
{
var appLanguages = ApplicationLanguages.ManifestLanguages
.Append(string.Empty) // Add default language id
.Select(language => new AppLanguageItem(language))
.OrderBy(language => language.LanguagID is not "") // Default language on top
.ThenBy(language => language.LanguageName);
AppLanguages = new ObservableCollection<AppLanguageItem>(appLanguages);
// Add default language
var osDefaultLanguage = new AppLanguageItem(CultureInfo.InstalledUICulture.Name);
if (AppLanguages.Select(language => language.LanguageName.Contains(osDefaultLanguage.LanguageName)).Any())
AppLanguages[0].LanguagID = osDefaultLanguage.LanguagID;
string languageID = ApplicationLanguages.PrimaryLanguageOverride;
SelectedAppLanguageIndex = AppLanguages
.IndexOf(AppLanguages.FirstOrDefault(dl => dl.LanguagID == languageID) ?? AppLanguages.First());
}

And then you could just use a similar condition for 'en' instead of CultureInfo.InstalledUICulture and store it in ApplicationLanguages.PrimaryLanguageOverride, I just don't know what the convention is for adding it to the App start method

private static readonly CultureInfo locale = ApplicationLanguages.PrimaryLanguageOverride == string.Empty ? CultureInfo.InstalledUICulture : new(ApplicationLanguages.PrimaryLanguageOverride);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 👀
Projects
Status: Done
1 participant