【发布时间】:2014-01-01 09:25:07
【问题描述】:
我正在尝试在 Xamarin iOS/Android 项目的可移植类库中使用 .NET 本地化。我已按照以下步骤操作:
并且有如下代码:
string sText = strings.enter_movie_name;
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("fr");
sText = strings.enter_movie_name;
lblEnterMovieName.Text = sText;
我也试过了:
ResourceManager resman = new ResourceManager(typeof(MyApplication.strings));
string sText = resman.GetString("enter_movie_name", new CultureInfo("fr"));
我创建了 strings.resx,其中 enter_movie_name 等于“输入电影名称:”,strings.fr.resx 等于“Entre la 电影名称:”
但是,sText 总是以“输入电影名称:”结尾。我似乎无法获得“Entre la movie name:”版本。
我也在Cross-platform Localization 看到了帖子,但无法解决。我也不想在Localization on Xamarin.iOS 使用 iOS 特定版本,因为我希望能够从独立于平台的库中获取我的字符串。
谁能指出我哪里出错了?
【问题讨论】:
-
我实际上只是在这里发布了一个类似的问题:stackoverflow.com/questions/20608106/… 似乎特定于语言的 resx 文件(strings.fr.resx)被“编译”到 fr\MyApplication.resources.dll 中t 嵌入到应用程序中。因此它总是选择默认值。
标签: c# android ios localization xamarin