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

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

问题描述

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

我遵循了

我已经看到故事板本地化 ID 应该类似于kId-c2-rCX".这适用于我的 LaunchScreen.xib 文件,但不适用于 Main.storyboard 文件,它具有简单的数字 ID,如192"、193"ecc.这可能是问题吗?

我错过了什么?

解决方案

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

这是我的本地化结构:

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

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

以文本模式打开您的故事板并将这些 ID 编号替换为文本.

现在打开您的 Main.strings 并在那里输入您的项目.

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

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.

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).

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:

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?

What am I missing?

解决方案

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

Here is my localization structure:

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

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

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

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

More info from: https://developer.xamarin.com/guides/ios/advanced_topics/localization_and_internationalization/

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

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