Closed p6laris closed 1 year ago
Hi! Is your app a packaged app (default) ? or a non-packaged app?
It's is packaged app sir, Generated with Template Studio.
I'm working on a sample app generated with the TemplateStudio. Just give me a few days🔥
Thanks, appreciated so much 🙏
Sorry for the delay. This is a sample app is created with the TemplateStudio. Let me know if you have any questions.
Sir, When i try to initialize the localizer, strangely this exception will throw. any idea why? WinUI3Localizer.LocalizerException: 'Failed to set language. [{PreviousLanguage} -> {NextLanguage}]'
Sorry. That exception message is going to be fixed in the next version.
You might get this message when the SetLanguage(string language)
method is called but failed to find the language
.
This is how the SetLanguage
method is implemented inside the WinUI3Localizer
.
public async Task SetLanguage(string language)
{
string previousLanguage = CurrentDictionary.Language;
try
{
if (this.languageDictionaries.TryGetValue(
language,
out LanguageDictionary? dictionary) is true &&
dictionary is not null)
{
CurrentDictionary = dictionary;
await LocalizeDependencyObjects();
OnLanguageChanged(previousLanguage, CurrentDictionary.Language);
return;
}
}
catch (LocalizerException)
{
throw;
}
catch (Exception exception)
{
ThrowLocalizerException(exception, "Exception setting language. [{PreviousLanguage} -> {NextLanguage}]", previousLanguage, language);
}
ThrowLocalizerException(innerException: null, "Failed to set language. [{PreviousLanguage} -> {NextLanguage}]", previousLanguage, language);
return;
}
My first guess is that you are not setting the DefaultLanguage
in the options:
ILocalizer localizer = await new LocalizerBuilder()
.SetOptions(options =>
{
options.DefaultLanguage = "YOUR DEFAULT LANGUAGE";
}
.Build();
You also need to make sure that your default language is added as a LanguageDictionary
.
Hello There, Is it possible to provide a minimal, beginner-friendly example usage. I have carefully examined the code samples available in the repository, but as a beginner, I still find it challenging to comprehend the implementation details.
Thank you for the efforts