How to localize Cordova iOS projects?

后端 未结 6 1816
长发绾君心
长发绾君心 2020-12-10 19:36

I\'ve been searching on the Internet but none of the solutions I found seems to work so, my question is with Xcode 6, how we could localize a Cordova app?

The image

6条回答
  •  醉酒成梦
    2020-12-10 19:52

    The preferred answer is correct but has the drawback to be native, i. e. you have to modify the Info*.plist after cordova prepare.

    If you want to stick with the Cordova's style (which i recommend), you can use a hook or a plugin for this.

    I did it with a plugin because a plugin has (from scratch) the ability to modify the native configuration's files (AndroidManifest.xml or Info*.plist).

    See https://stackoverflow.com/a/27947343/2728710

    What I've done :

    • make a new specific plugin name "cordova-plugin-config-ios"

    localPlugins/cordova-plugin-config-ios/plugin.xml

    
    
        CRM Factory Cordova Localization iOS Plugin
        A label translate example
        
        
            
                
                    French
                
            
            
                
                    fr_FR
                
            
        
    
    
    • make a hook add-local-plugins.sh. In it, install the specific plugin made

    add-local-plugins.sh

    echo "Install specific plugin for modify Info*.plist"
    cordova plugin add cordova-plugin-config-ios --searchpath ${projectDir}/localPlugins/cordova-plugin-config-ios
    
    • call the hook via config.xml

    config.xml

    
    

    In my case, the hook was not mandatory but I like the freedom brought by it and to be able to log what the program did (echo part).

提交回复
热议问题