Xamarin iOS故事板本地化

我正在开发与Visual Studio中的xamarin iOS应用程序。 我试图添加本地化到我的Main.storyboard文件和默认的LaunchScreen.xib文件,但我不能使它的工作。

我已经按照这里的文档,我也执行了示例应用程序(这是工作正常)。 我复制了项目的结构,并且检查了很多次,但是我无法看到我的string在故事板或xib文件(LaunchScreen.xib)中本地化。

这是我的Info.plist:

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDisplayName</key> <string>MyApp</string> <key>CFBundleIdentifier</key> <string>it.company.myapp</string> <key>CFBundleShortVersionString</key> <string>1.0</string> <key>CFBundleVersion</key> <string>1.0</string> <key>LSRequiresIPhoneOS</key> <true/> <key>MinimumOSVersion</key> <string>9.0</string> <key>UIDeviceFamily</key> <array> <integer>1</integer> <integer>2</integer> </array> <key>UILaunchStoryboardName</key> <string>LaunchScreen</string> <key>UIMainStoryboardFile</key> <string>Main</string> <key>UIMainStoryboardFile~ipad</key> <string>Main</string> <key>UIRequiredDeviceCapabilities</key> <array> <string>armv7</string> </array> <key>UISupportedInterfaceOrientations</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>UISupportedInterfaceOrientations~ipad</key> <array> <string>UIInterfaceOrientationPortrait</string> <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> <key>CFBundleDevelopmentRegion</key> <string>it</string> <key>CFBundleLocalizations</key> <array> <string>en</string> </array> </dict> </plist> 

这是我的项目结构的截图:

project_structure

我已经看到故事板本地化ids应该像“kId-c2-rCX”。 这对我的LaunchScreen.xib文件来说是正确的,但是对于Main.storyboard文件来说却是这样,它具有简单的数字ID,例如“192”,“193”ecc。 这可能是问题吗?

我错过了什么?

你必须设置一个默认值。 例如,您想本地化一个textField placeHolder,而不是硬编码占位符的默认值,本地化将工作。

我知道这是一个老问题,但我想告诉我的解决scheme的问题。

这是我的本地化结构:

在这里输入图像说明

在我的解决scheme中,我已将Main.strings -file重命名为与故事板相同的名称。

现在改变你的UI项目本地化的string。 在我的项目,使不同的。 这里是图像来展示我的意思。

在这里输入图像说明

以文本模式打开故事板,并将这些ID号码replace为文本。

现在打开你的Main.strings并在那里input你的项目。

在这里输入图像说明

更多信息来自: https : //developer.xamarin.com/guides/ios/advanced_topics/localization_and_internationalization/