Xamarin Community Toolkit TranslateExtension
The TranslateExtension
allows users to handle multi-language support at runtime. It uses the built-in LocalizationResourceManager
helper to retrieve the correct translation resource for the current active CultureInfo
.
Syntax
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:xct="http://xamarin.com/schemas/2020/toolkit"
x:Class="MyLittleApp.MainPage">
<StackLayout>
<Label Text="{xct:Translate AppResources.ATranslatedMessage}" />
<Label Text="{xct:Translate AppResources.AnotherTranslatedMessage, StringFormat='#{0}'}" />
</StackLayout>
</ContentPage>
Properties
Property | Type | Description |
---|---|---|
StringFormat | string | Allows the user to provide additional formatting to the translated text. |
Text | string | The resource that will be translated. |
Sample
You can see this in action in the Xamarin Community Toolkit Sample App.