kelvinhokk / cordova-plugin-localization-strings

Cordova Plugin for Localization of Strings on the App
MIT License
119 stars 106 forks source link

Platform specific localizations? #7

Closed rdantonio closed 7 years ago

rdantonio commented 7 years ago

Not sure if I'm just being dumb and missing something but we need to support languages like Simplified/Traditional Chinese and I can't seem to find a way to make this work for both Android and iOS with the same file(s).

For example prior to using this I had for Android:

and for iOS:

If I use one or the other one platform doesn't work, and putting them all will also throw errors as I don't see a way to exclude certain files from a specific platform. Any suggestions or help would be greatly appreciated!

kelvinhokk commented 7 years ago

What do you think if we add an optional locale in the json file to support locales with region? The idea, is instead of reading the locale from the file name (by default), the plugin will check for the locale.ios or locale.json.

zh-Hans.json

{
    "locale": {
        "ios": ["zh-Hans"],
        "android": ["zh-rCN"]
    },
    "config_ios": {
        "NSCameraUsageDescription": "扫描二维码",
        "CFBundleDisplayName": "应用程序名称",
        "CFBundleName": "应用程序名称"
    },
    "config_android": {
        "app_name": "应用程序名称"
    },
    "app": {
        "HAVE_MAIL_TITLE": "你收到了邮件",
        "HAVE_MAIL_MSG": "%1$@给您发送了封邮件,标题为\\\"%2$@\\\""
    }
}

zh-Hant.json

{
    "locale": {
        "ios": ["zh-Hant"],
        "android": ["zh-rTW", "zh-rHK"]
    },
    "config_ios": {
        "NSCameraUsageDescription": "掃描二維碼",
        "CFBundleDisplayName": "應用程序名稱",
        "CFBundleName": "應用程序名稱"
    },
    "config_android": {
        "app_name": "應用程序名稱"
    },
    "app": {
        "HAVE_MAIL_TITLE": "你收到了郵件",
        "HAVE_MAIL_MSG": "%1$@給您發送了封郵件,標題為\\\"%2$@\\\""
    }
}
rdantonio commented 7 years ago

Sorry for the delay in response, this sounds like it would work perfectly for us!

kelvinhokk commented 7 years ago

Hi rdantonio, I have just added support for this in version 1.1.0

Would you like to try it out?

rdantonio commented 7 years ago

Finally had a chance to test this out - it works great! Thank you for the effort!