WinUI3Localizer
WinUI3Localizer copied to clipboard
Recommended way to localize top-level UI components?
Is there are way to translate the top level UI component such a ContentDialog? What is recommended way to do this?
I wish to translate Title and PrimaryButtonText For instance like that:
<?xml version="1.0" encoding="utf-8" ?>
<ContentDialog
x:Class="NotifyAloud.Views.AboutDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:l="using:WinUI3Localizer"
xmlns:local="using:NotifyAloud"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="{l:Localize Key=AboutDialogTitle}" <
DefaultButton="Primary"
PrimaryButtonText="{l:Localize Key=AboutDialogPrimaryButtonText}" <
mc:Ignorable="d">
I've tried to use Bind also with the custom extension, not working either:
{
[MarkupExtensionReturnType(ReturnType = typeof(string))]
public class LocalizedStringExtension : MarkupExtension
{
public string Key { get; set; }
protected override object ProvideValue()
{
var localizedString = Localizer.Get().GetLocalizedString(Key);
return localizedString;
}
}
}
Appreciate your effort and time in making this awesome library.