如何本地化 Visual Studio 中的 Info.plist 内容

How to localize Info.plist content in Visual Studio

我有一个 Xamarin iOS 应用程序,目前支持 4 种不同的语言。然而 我现在希望能够翻译我的 info.plist 文件的内容及其 NSCameraUsageDescription 之类的键,以便它 values也可以翻译。

到目前为止,我已经做了很多研究,通过搜索文档,建议创建一个 InfoPlist.strings 文件,其中包含 我的钥匙 NSCameraUsageDescription = "the content here".

每种语言都有一个 InfoPlist.strings 文件,该文件将包含在文件夹 fr.lproj[=35 中=]等后文

我认为在 Xcode 中利用此选项可以创建 .strings 文件并直接对其进行本地化,这一点得到了相对较好的解释。 但是,在 Visual Studio 上,我在介绍和改编我的文件时遇到了一些困难。 Xcode 上的 .strings 文件相当于 VS 上的 .resx 文件?

我的 InfoPlist.strings 和我的主 Info.plist 文件之间的关系如何才能告诉我的应用程序点击文件夹 fr.lproj / InfoPlist.strings 当我例如切换到法语。

我是否应该为每种语言创建一个名为 fr.lproj 的文件夹,我将单个文件 InfoPlist.strings 或 InfoPlist.resx 与我的密钥放在其中?

However, on Visual Studio I have some difficulties to introduce and adapt my files. The equivalent of a .strings file on Xcode is a .resx file on VS ?

不,要在 visual studio 中创建 .strings 文件,您应该选择添加 -> 新项目 -> 文本文件 ,然后更改文件名称与 xxx.strings.

How can the relationship between my InfoPlist.strings and my main Info.plist file be in order to tell my application to tap in the folder fr.lproj / InfoPlist.strings when I switch to french for instance.

如果你为每个语言都创建了InfoPlist.strings,它会自动读取相应语言文件中的配置,然后显示正确的语言。如果在 InfoPlist.strings 上找不到密钥,它将使用 main Info.plist.

中的默认值

Am I supposed to create one folder for each language named fr.lproj where I put a single file InfoPlist.strings or InfoPlist.resx with my keys ?

是的,如果您要支持四种语言,您应该创建 3 个 xx.lporj 文件夹(另一个是 Base.lporj),每个文件夹包含一个 InfoPlist.stringsLocalizable.strings.

在您的 InfoPlist.strings 文件中,设置密钥 NSCameraUsageDescription = "the content here" 等....

阅读 document 可能会有帮助。

这是我刚刚在我的项目中创建的: