0
我试图让我的Xamarin Forms应用程序支持多种语言,如英语和阿拉伯语,这些语言基于不基于手机语言的用户选择。 以下代码显示如何将我的语言更改为阿拉伯语或英语。更改基于用户选择的应用程序语言配置
下面的代码是TranslateExtension从Xamarin Forms Samples部分:
public object ProvideValue(IServiceProvider serviceProvider)
{
if (Text == null)
return "";
ResourceManager resmgr = new ResourceManager(ResourceId, typeof(TranslateExtension).GetTypeInfo().Assembly);
var translation = resmgr.GetString(Text, ci);
if (translation == null)
{
#if DEBUG
throw new ArgumentException(
String.Format("Key '{0}' was not found in resources '{1}' for culture '{2}'.", Text, ResourceId, ci.Name),"Text");
#else
translation = Text; // HACK: returns the key, which GETS DISPLAYED TO THE USER
#endif
}
return translation;
}
谁能帮助我,告诉我如何使基于用户选择这项工作不是基于设备的语言。感谢帮助。