Windows-Auto-Night-Mode icon indicating copy to clipboard operation
Windows-Auto-Night-Mode copied to clipboard

[UI] [Translation] On/Off toggle should be translatable?

Open Armin2208 opened this issue 2 months ago • 6 comments

Everyone knows what on/off means. But for a complete translation experience the on/off should be translatable. I think currently it just uses the windows system language? A change that shouldn't need much work, and if it does, it shouldnt be priority.

Image

Armin2208 avatar Oct 14 '25 19:10 Armin2208

I have seen this a few times before. In PowerToys they do this too. ~But Microsoft guide clearly advises against it.~ In short: it shouldn't be necessary, but it depends on the languages available in the app and in Windows...

Jay-o-Way avatar Oct 14 '25 21:10 Jay-o-Way

That's a weird guideline of Microsoft. I wouldn't support this guideline.

Armin2208 avatar Oct 14 '25 22:10 Armin2208

Ideally, these "Built-in labels" should follow the app's Override language, instead of simply looking at Windows Settings.

Reference issues:

  • https://github.com/microsoft/microsoft-ui-xaml/issues/10837 (mine)
  • https://github.com/microsoft/microsoft-ui-xaml/issues/10430 (Chen's)

What we can do is use the following code, and then add the strings to the Resource files.

[!IMPORTANT] This does mean that, at first (until translated) all of them will be in English - in stead of OS language - and it may create the danger that they get translated incorrectly. We have to use machine translation to overcome this.

<!-- App.xaml -->
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
                <ResourceDictionary Source="/Styles/CustomStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <Style BasedOn="{StaticResource DefaultToggleSwitchStyle}" TargetType="ToggleSwitch">
                <Setter Property="OnContent">
                    <Setter.Value>
                        <helpers:ResourceString Name="ToggleOn" />
                    </Setter.Value>
                </Setter>
                <Setter Property="OffContent">
                    <Setter.Value>
                        <helpers:ResourceString Name="ToggleOff" />
                    </Setter.Value>
                </Setter>
            </Style>
        </ResourceDictionary>

Jay-o-Way avatar Oct 17 '25 11:10 Jay-o-Way

What we can do is use the following code, and then add the strings to the Resource files.

    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
            <ResourceDictionary Source="/Styles/CustomStyles.xaml" />
        </ResourceDictionary.MergedDictionaries>
        <Style BasedOn="{StaticResource DefaultToggleSwitchStyle}" TargetType="ToggleSwitch">
            <Setter Property="OnContent">
                <Setter.Value>
                    <helpers:ResourceString Name="ToggleOn" />
                </Setter.Value>
            </Setter>
            <Setter Property="OffContent">
                <Setter.Value>
                    <helpers:ResourceString Name="ToggleOff" />
                </Setter.Value>
            </Setter>
        </Style>
    </ResourceDictionary>

This is a good solution. At the same time, in version 10 of ADM, there are localized files about On and Off, and we can make these contents return.

ChenYiLins avatar Oct 17 '25 12:10 ChenYiLins

What we can do is use the following code, and then add the strings to the Resource files.

    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
            <ResourceDictionary Source="/Styles/CustomStyles.xaml" />
        </ResourceDictionary.MergedDictionaries>
        <Style BasedOn="{StaticResource DefaultToggleSwitchStyle}" TargetType="ToggleSwitch">
            <Setter Property="OnContent">
                <Setter.Value>
                    <helpers:ResourceString Name="ToggleOn" />
                </Setter.Value>
            </Setter>
            <Setter Property="OffContent">
                <Setter.Value>
                    <helpers:ResourceString Name="ToggleOff" />
                </Setter.Value>
            </Setter>
        </Style>
    </ResourceDictionary>

@Jay-o-Way I need some help. The bad news is that it seems that this code still has no effect. The worst solution is that we manually add these properties for each ToggleSwtich. (;´д`)ゞ

ChenYiLins avatar Nov 11 '25 03:11 ChenYiLins

The worst solution is that we manually add these properties for each ToggleSwtich.

That would be an absolute "no way" for me. Ideally, the ~issue~ discussion will be picked up by MS XAML/WinUI, but even if/when decided, it's going to take a while before it will be available. In the mean time, my personal opinion is that (clearly) I see the issue, but find it of (very) low priority.

Jay-o-Way avatar Nov 11 '25 14:11 Jay-o-Way