Localize x: String

I saw such questions on MSDN, but they were not answered. Therefore, I can localize all my controls with x: Uid and a specific key format in the * .resw file. But how do I localize x: String? For instance:

<x:String x:Key="AppName">My App</x:String> 

I know some workarounds. But are there any good approaches?

+4
source share
2 answers

It seems like this is now impossible. Use x:String only for strings that should not be localized (for example, the name of the application). Otherwise, it is preferable to use TextBlock or some other text controls.

+3
source

There is a msdn message that is here . Its essence is this:

 <TextBlock x:Uid="MyTextBlock" FontSize="24.667" Text="Design Placeholder" /> 

Note the x:Uid here. Now it will be displayed back to the key in your RESW file. Everything that has this start key will have properties merged with it. So we have a key in our RESW for “Text”, using the key name MyTextBlock.Text with the value “Hello World” and runtime will make a replacement for you.

Steps:

  • Create a text block with the specified x:Uid .
  • Create a RESW file for your language, so named for your localization
  • Add lines to your RESW to replace the property in your text block.
+1
source

Source: https://habr.com/ru/post/1437202/


All Articles