WinUI3Localizer
WinUI3Localizer copied to clipboard
The property UseUidWhenLocalizedStringNotFound removed in the latest version
Hi, after upgrading the WinUI3Localizer to the version - 2.2.0.0 from 1.0.1, we found the "UseUidWhenLocalizedStringNotFound" was removed, and the below calling will return empty string rather than the uid
Localizer.Get().GetLocalizedString(resourceKey)
Is there any other work around or way to keep the same behaviour as previous version?
Hi @penndai !
I needed to make that change to be consistent with localization in XAML. Can you consider using a helper?
public static class LocalizerHelper
{
public static string GetLocalizedStringEx(this ILocalizer localizer, string uid, bool returnUidOnEmptyString)
{
if (localizer.GetLocalizedString(uid) is string localizedString &&
string.IsNullOrEmpty(localizedString) is false)
{
return localizedString;
}
if (returnUidOnEmptyString is true)
{
return uid;
}
return string.Empty;
}
}
string localizedString = Localizer.Get().GetLocalizedStringEx(uid: "TEST_UID", returnUidOnEmptyString: true);
Closing for now. Feel free to reopen or start a new issue if you need further assistance.