在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):kelvinhokk/cordova-plugin-localization-strings开源软件地址(OpenSource Url):https://github.com/kelvinhokk/cordova-plugin-localization-strings开源编程语言(OpenSource Language):JavaScript 100.0%开源软件介绍(OpenSource Introduction):Cordova Localization Strings PluginThis plugin helps you manage string files that you need natively, namely This plugin also lets you localize your app name on both iOS and Android. How to UseInstall the plugin
Modify your project root to have the following structure:
A JSON file may look like this (Note: Breaking change from 1.0.0 onwards - new JSON format). {
"config_ios": {
"NSCameraUsageDescription": "Take pictures",
"CFBundleDisplayName": "Some App Name",
"CFBundleName": "Some App Name"
},
"config_android": {
"app_name": "Some App Name"
},
"app": {
"HAVE_MAIL_TITLE": "You have mail.",
"HAVE_MAIL_MSG": "%1$@ has you a message titled \\\"%2$@\\\""
}
} By default, the language for the For example, if the filename is Install iOS or Android platform
Run the code
Platform Specific LocalizationsThere are some platform specific localizations which differ for Android and iOS, for example for Android:
and for iOS:
In this case, you can add the N.B. The
{
"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$@\\\""
}
}
{
"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$@\\\""
}
} DependenciesThis plugin works on cordova >= 6.1.0 and node >= 10. Use CasesTypically, in a Cordova application, localization is performed on the javascript layer. There are several libraries to help do so like angular-translate on Ionic 1 and ngx-translate on Ionic 2+, with the help of plugins like cordova-plugin-globalization to retrieve the locale or preferred language natively. This plugin helps for native localization in the following use cases: Localizing App NameThe plugin will help localize the app name if you require it to be named differently in different languages. Use the following JSON file format. {
"config_ios": {
"CFBundleDisplayName": "Some App Name",
"CFBundleName": "Some App Name"
},
"config_android": {
"app_name": "Some App Name"
}
} Localizing iOS PermissionsThis plugin will help localize the iOS permission descriptions, for example Example usage: {
"config_ios": {
"NSCameraUsageDescription": "Take pictures",
"NSLocationUsageDescription": "Need Location for Some Purpose"
}
} iOS Settings localizationsThis plugin can localizae iOS Settings bundles. Example usage: {
"settings_ios": {
"Root": {
"App version": "App version"
}
}
} In the example shown, it would create a file such as "platforms/ios//Resources/Settings.bundle/.lproj/Root.strings" with the expected localizations for that language. Push notifications messagesTypically, there are 2 main ways push notifications can be localized:
This plugin helps in the latter approach. More information about the respective string localizations and formatting here: Example usage: {
"app": {
"HAVE_MAIL_TITLE": "You have mail.",
"HAVE_INVITE_MSG": "%1$@ has invited you to game room %2$@"
}
} The plugin will automatically generate
And on Android, the respective locale's <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<resources>
<string name="HAVE_MAIL_TITLE">You have mail.</string>
<string name="HAVE_INVITE_MSG">%1$s has invited you to game room %2$s</string>
</resources> Details for iOSThe plugin reads the assumed directory structure. It then reads from all the fields in Details for AndroidThe plugin reads the assumed directory structure. It then combines all properties in Note that for the app's default language the strings are stored in Overriding platform specific translations:{
"app": {
"HAVE_MAIL_TITLE": "Sie haben Post. This should be overwritten by platform-specific string.",
"HAVE_MAIL_MSG": "%1$@ has you a message titled \\\"%2$@\\\""
},
"app_ios": {
"HAVE_MAIL_TITLE": "Sie haben Post in iOS.",
"Key with Spaces": "Schlüssel mit Leerzeichen"
},
"app_android": {
"HAVE_MAIL_TITLE": "Sie haben Post in Android.",
"ONLY_ON_ANDROID": "Testmeldung nur unter Android."
}
} If |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论