【发布时间】:2020-10-22 14:44:37
【问题描述】:
我需要创建一个支持多语言的应用程序。
所以我做了一个如下示例应用程序。
Page.xamal
<StackLayout
VerticalOptions="CenterAndExpand">
<Label Text="{x:Static local:AppResources.Title}" TextColor="Black"
HorizontalOptions="CenterAndExpand" />
<Button Text="{x:Static local:AppResources.ClickMe}" Clicked="Button1_Clicked"/>
<Label Text="{x:Static local:AppResources.Title}" TextColor="Black"
HorizontalOptions="CenterAndExpand" />
<Button Text="{x:Static local:AppResources.ClickMe}" Clicked="Button2_Clicked"/>
</StackLayout>
page.xamal.cs
private void Button1_Clicked(object sender, EventArgs e)
{
CultureInfo culture = new CultureInfo("th");
AppResources.Culture = culture;
}
作为 xmarin 表单文档,我设置了 AssemblyInfo.cs(公共文件夹)
[assembly: NeutralResourcesLanguage("en-GB")]
所以我的默认语言是“en-GB”。
我有 3 个 AppRerources.resx
- AppResources.resx
- AppResources.th.resx
- AppResources.en-GB.resx
但是当我按下第一个按钮时,我看不到该应用正在更改语言。
我错过了什么?
【问题讨论】:
标签: c# xamarin xamarin.forms