0

A while back I have created some pages in UWP with several RichTextBlock controls. Problem is now I have to localize those RickTextBlock controls, and each have specific formatting tags (Paragraph, Bold, Underline, Span, etc...).

Unlike other controls I can't seem to find a way to use the x:Uid tag inside the RichTextBlock xaml to access my Resources.resw files.

Has anyone been able to localize these controls? I am also looking for strategies on how to translate sentences which have just some of the words in bold or underline... in other words, how do you do translation and still maintain the formatting?

Jean-Marc
  • 73
  • 9
  • _..., how do you do translation and still maintain the formatting?_ translation is not word to word mapping between different languages, the difficulty is, if you don't speak both languages, you don't even know what the translation is for a given word. Only the translator can help keep the formatting. – kennyzx Oct 10 '17 at 05:42

1 Answers1

2

You could use <Run/> tag to show the text in the specific format tags instead of putting text string in the format tags directly. Then, you could use x:Uid to do localization for the text.

For example:

<RichTextBlock TextIndent="12" >
        <Paragraph TextIndent="24">
            <Run x:Uid="first" Text="First paragraph."></Run>
        </Paragraph>
        <Paragraph>
            <Run x:Uid="second" Text="Second paragraph."></Run>
        </Paragraph>
        <Paragraph>
            <Run x:Uid="third" Text="Third paragraph."></Run>
            <Bold>
                <Run x:Uid="blodtext" Text="With an inline."></Run>
            </Bold>
        </Paragraph>
</RichTextBlock>

enter image description here enter image description here

Xie Steven
  • 8,544
  • 1
  • 9
  • 23
  • Yes I know about this, but that does not work well for paragraphs with multiple embedded formatting. Ideally the formatting would have to be saved as part of the resource... – Jean-Marc Oct 10 '17 at 18:50