Xamarin iOS故事板的本地化 [英] Xamarin iOS storyboard localization

查看:66
本文介绍了Xamarin iOS故事板的本地化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Visual Studio中使用xamarin开发ios应用程序. 我正在尝试将本地化添加到Main.storyboard文件和默认的LaunchScreen.xib文件中,但是我无法使其正常工作.

I'm developing an ios app with xamarin in Visual Studio. I'm trying to add localization to my Main.storyboard file and to default LaunchScreen.xib file but I can't make it work.

我已按照文档此处,并且我也执行了示例应用程序(运行正常).我已经复制了项目的结构,并且检查了很多次文件,但是看不到我的字符串位于情节提要或Xib文件(LaunchScreen.xib)中.

I've follow the documentation here and I've also executed the sample app (which is working fine). I've copied the structure of the project and I've checked files many times but I'm not be able to see my strings localized inside the storyboard or xib files (LaunchScreen.xib).

这是我的Info.plist:

This is my 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>

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

And this is a screenshot of my project structure:

我已经看到情节提要本地化ID应该类似于"kId-c2-rCX".这对于我的LaunchScreen.xib文件是正确的,但对于Main.storyboard文件却不是,该文件具有简单的数字ID,例如"192","193" ecc.这可能是问题吗?

I've seen that storyboard localization ids should be like "kId-c2-rCX". This is true for my LaunchScreen.xib file but not for Main.storyboard file which has simple numerical ids like "192", "193" ecc. Could this be the problem?

我想念什么?

推荐答案

我知道这是个老问题,但是我想告诉我解决问题的方法.

I know this is old question, but I want to tell my solution for problem.

这是我的本地化结构:

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

In my solution i have renamed Main.strings -file to same name that my storyboard.

现在将您的ui项目本地化ID更改为字符串.在我的项目中,与众不同.这是显示我的意思的图像.

Now change you ui item localization id to string. In my project that makes the different. Here is image to show what I mean.

以文本模式打开情节提要,然后将这些ID号替换为文本.

Open your storyboard in text mode and replace those id numbers to text.

现在打开您的Main.strings并在其中键入您的项目.

Now open your Main.strings and type your item there.

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

这篇关于Xamarin iOS故事板的本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆