Sunday, 1 September 2019

How does iOS perform localization in Cordova / Phonegap build?

I am trying to display my app name in different languages.

  1. English
  2. Chinese (Simplified)
  3. Chinese (Traditional)

I am using phonegap build to build the app so cannot use xcode.

Therefore, I have created 3 folders which contain respective InfoPlist.strings file manually on res folder like:

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

Example of InfoPlist.strings file inside zh-hant.lproj folder:

enter image description here

My config.xml has these lines to copy to respective folder and also use it respectively.

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

The problem is that when I install the app on iPhone the translation is not working. My current language set to English, I get the English name.

When I change language to chinese it does not reflect (translation not working, i.e still in English).

How do I fix this ? Is there anything I am missing ?



from How does iOS perform localization in Cordova / Phonegap build?

No comments:

Post a Comment