【问题标题】:How does iOS perform localization in Cordova / Phonegap build?iOS 如何在 Cordova / Phonegap 构建中执行本地化?
【发布时间】:2019-08-30 12:39:22
【问题描述】:

我正在尝试以不同的语言显示我的应用名称。

  1. 英语
  2. 中文(简体)
  3. 中文(繁体)

我正在使用 phonegap build 来构建应用程序,因此无法使用 xcode。

因此,我在 res 文件夹上手动创建了 3 个包含相应 InfoPlist.strings 文件的文件夹,例如:

  • en.lproj/InfoPlist.strings
  • zh.lproj/InfoPlist.strings
  • zh-hant.lproj/InfoPlist.strings

zh-hant.lproj 文件夹中的 InfoPlist.strings 文件示例:

我的 config.xml 将这些行复制到相应的文件夹并分别使用它。

        <resource-file src="res/zh-hant.lproj" target="zh-hant.lproj" />
        <resource-file src="res/zh.lproj" target="zh.lproj" />
        <resource-file src="res/en.lproj" target="en.lproj" />

        <!-- copy localization file -->

        <resource-file src="res/zh-hant.lproj/InfoPlist.strings" target="zh-hant.lproj/InfoPlist.strings" />
        <resource-file src="res/zh.lproj/InfoPlist.strings" target="zh.lproj/InfoPlist.strings" />
        <resource-file src="res/en.lproj/InfoPlist.strings" target="en.lproj/InfoPlist.strings" />

        <config-file platform="ios" parent="LSHasLocalizedDisplayName" mode="replace">
        <true />
        </config-file>

        <edit-config target="CFBundleLocalizations" file="*-Info.plist" mode="overwrite">
            <array>
                <string>en</string> <!-- english -->
                <string>zh</string> <!-- chinese (simplified) -->
                <string>zh-hant</string> <!-- chinese (traditional) -->
            </array>
        </edit-config>

问题是当我在 iPhone 上安装应用程序时,翻译不起作用。我当前的语言设置为英语,我得到了英文名称。

当我将语言更改为中文时,它没有反映(翻译不起作用,即仍然是英文)。

我该如何解决这个问题?有什么我想念的吗?

【问题讨论】:

  • 您是否在 App Store 中设置了此应用名称?
  • @Lu_ 不,我现在只是在本地构建和测试它。该应用尚未提交到商店。

标签: ios cordova localization phonegap


【解决方案1】:

如果您想调试本地化,您需要编辑您的方案,如here 所述。

【讨论】:

  • 您好 NIkitah,感谢您的回复,但我正在使用 phonegap,无法调试应用程序。
  • Phonegap 构建只是使用 WebView 组件显示内容的本机应用程序。您的项目仍然是 XCode 项目。
  • 是的,但没有什么可调试的。我只有语言环境文件,可能 iOS 应该只在构建期间使用它,但您会发现它没有以正确的方式发生。可能是我错过了什么。
猜你喜欢
  • 2016-03-26
  • 1970-01-01
  • 1970-01-01
  • 2015-03-08
  • 1970-01-01
  • 2014-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多