yesseruser
yesseruser

Reputation: 70

How do I localize a Button's ToolTip text in UWP - WinUI 2

I'm making a UWP app with WinUI 2.8. I have a button control, and with a basic ToolTip in it.

How can I localize the ToolTip using localization tables?

Here's my XAML code of the button:

<Button 
    x:Name="SaveB" 
    x:Uid="Save" 
    Content="Save" 
    ToolTipService.ToolTip="Saves the input." 
    Click="SaveB_Click" 
/>

Upvotes: 0

Views: 374

Answers (1)

Roy Li - MSFT
Roy Li - MSFT

Reputation: 8666

What you need to do is to create resources files targeting different languages in your app and save the localized string in the files.

Here are the steps to create a localized string for en-US. You could take it as example.

  1. On the Application tab, confirm that the Default language is set appropriately (for example, "en" or "en-US").
  2. Under your project node, create a new folder and name it "Strings".
  3. Under Strings, create a new sub-folder and name it "en-US".
  4. Under en-US, create a new Resources File (.resw) and confirm that it is named "Resources.resw".
  5. Save the resource strings into Resources.resw file.

Like this:

enter image description here

The Xaml code should be like this:

    <Grid>
    <Button x:Name="SaveB" x:Uid="Save" Click="SaveB_Click" />
</Grid>

Result:

enter image description here

More information please refer to: Localize strings in your UI and app package manifest

Upvotes: 1

Related Questions