Xamarin.form (XAML) Label Tag Display (Multilingual)

Asked 2 years ago, Updated 2 years ago, 83 views

I am having trouble displaying multiple lines on the label because the app supports multiple languages.

The following Japanese language is set to the AppResources.resx file.

<data name="aaa"xml:space="preserve">
        <value>Ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh;
    </data>
    <data name="bbb"xml:space="preserve">
        <value>good</value>
    </data>
    <data name="ccc"xml:space="preserve">
        <value> and </value>
    </data>

Also, the xaml file defines the following label tags:

<Label TextColor="Black"BackgroundColor="White">
  <Label.Text>
    {i18n:Translate aaa}
    {i18n:Translate bbb}
    {i18n:Translate ccc}
  </Label.Text>
</Label>

If you look at the iOS simulator in this state, it's not in Japanese defined in AppResources.resx.

 {i18n:Translate aaa}
    {i18n:Translate bbb}
    {i18n:Translate ccc}

appears.

To display multiple lines of Japanese-containing multilingual in a Label tag What should I do?
Professor, please.

c# xaml xamarin

2022-09-30 21:17

1 Answers

Try Label.FormattedText.

If you write as follows, you will expect the results.

<Label TextColor="Black"BackgroundColor="White">
    <Label.FormattedText>
        <FormattedString>
            <Span Text="{i18n:Translate aaa}"/>
            <Span Text="{x:Static x:Environment.NewLine}"/>
            <Span Text="{i18n:Translate bbb}"/gt;
            <Span Text="{x:Static x:Environment.NewLine}"/>
            <Span Text="{i18n:Translate ccc}"/>
        </FormattedString>
    </Label.FormattedText>
</Label>

If you don't mind, please include my blog post.
http://ticktack.hatenablog.jp/entry/2016/02/11/175656


2022-09-30 21:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.