question

MikkelRuneRasmussen-8782 avatar image
0 Votes"
MikkelRuneRasmussen-8782 asked JarvanZhang-MSFT commented

How do i change resources based on the culture?

Hi.

I am currently developing an application that needs to be two different languages. As such, i have created a Resources.resx as well as a Resources.da-DK.resx.

For changing the culture, I have made a picker, that lets the user change the language they want to use, as well as the culture. However, when the culture is changed to da-DK, I still get output from my regular Resources.resx. How do I change what text gets printed in the UI?

Thanks

dotnet-xamarin
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, MikkelRuneRasmussen-8782. For this function, you could set dynamic binding for the content with the RESX resources.

<StackLayout>
    <Label Text="{Binding Resources[Content]}" />
    <Picker ItemsSource="{Binding Languages}" SelectedItem="{Binding SelectedLanguage, Mode=TwoWay}" />
</StackLayout>

Similar issues:
https://stackoverflow.com/questions/60766540/dynamic-resx-translation-in-xamarin-forms-using-mvvm
https://stackoverflow.com/questions/44410407/xamarin-forms-change-ui-language-at-runtime-xaml

You could google with the keyword as Dynamically binding RESX Resources in Xamarin Forms to check the related tutorial.

0 Votes 0 ·

1 Answer

alessandrocaliaro avatar image
0 Votes"
alessandrocaliaro answered
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.