Socket
Socket
Sign inDemoInstall

cordova-plugin-localization-strings

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-localization-strings - npm Package Compare versions

Comparing version 4.1.1 to 4.1.2

2

package.json
{
"name": "cordova-plugin-localization-strings",
"version": "4.1.1",
"version": "4.1.2",
"description": "Cordova Plugin for handling localization strings on InfoPlist.strings and Localizable.strings on iOS, strings.xml on Android",

@@ -5,0 +5,0 @@ "keywords": [

@@ -1,4 +0,4 @@

# Cordova Localization String Plugin
# Cordova Localization Strings Plugin
This plugin helps you to manage string files that you need natively, namely on Localizable.strings and InfoPlist.strings on iOS, and strings.xml on Android.
This plugin helps you manage string files that you need natively, namely `Localizable.strings` and `InfoPlist.strings` on iOS, and `strings.xml` on Android.

@@ -9,5 +9,5 @@ This plugin also lets you localize your app name on both iOS and Android.

Install the plugin by fetching the dependencies
Install the plugin
$ cordova plugin add cordova-plugin-localization-strings --save
$ cordova plugin add cordova-plugin-localization-strings

@@ -47,5 +47,5 @@ Modify your project root to have the following structure:

By default, the language for the Localizable.strings, InfoPlist.strings or strings.xml is taken from the filename.
By default, the language for the `Localizable.strings`, `InfoPlist.strings` or `strings.xml` is taken from the filename.
For example, if the filename is es.json, the language is hence "es", and the plugin will create "/Resources/es.lproj/Localizable.strings" or "/values-es/strings.xml".
For example, if the filename is `es.json`, the language is hence `"es"`, and the plugin will create `"/Resources/es.lproj/Localizable.strings"` or `"/res/values-es/strings.xml"`.

@@ -60,2 +60,3 @@ Install iOS or Android platform

cordova prepare ios
cordova prepare android

@@ -66,18 +67,18 @@ #### Platform Specific Localizations

- zh-rCN
- zh-rHK
- zh-rTW
- `zh-rCN`
- `zh-rHK`
- `zh-rTW`
and for iOS:
- zh-Hans
- zh-Hans-CN
- zh-Hant
- zh-Hant-TW
- `zh-Hans`
- `zh-Hans-CN`
- `zh-Hant`
- `zh-Hant-TW`
In this case, you can use the locale in the json file to specify the platform localizations as in the following examples.
In this case, you can add the `"locale"` in the JSON file to specify the platform localizations as in the following examples.
N.B. The "locale" key is optional (if platform localization is not required).
N.B. The `"locale"` key is optional (if platform localization is not required).
zh-Hans.json
- `zh-Hans.json`

@@ -105,3 +106,3 @@ ```json

zh-Hant.json
- `zh-Hant.json`

@@ -131,15 +132,13 @@ ```json

This plugin relies on node >= 10 for some of its dependencies, and cordova >= 6.1.0.
This plugin works on cordova >= 6.1.0 and node >= 10.
Do remember to install these dependencies too via the `--fetch` when installing the plugin.
## Use Cases
Typically, 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.
Typically, in a Cordova application, localization is performed on the javascript layer. There are several libraries to help do so like [angular-translate](https://angular-translate.github.io/) on [Ionic 1](https://ionicframework.com/) and [ngx-translate](http://www.ngx-translate.com/) on [Ionic 2+](https://ionicframework.com/), with the help of plugins like [cordova-plugin-globalization](https://github.com/apache/cordova-plugin-globalization) to retrieve the locale or preferred language natively.
This plugin helps in native localization in the following use cases:
This plugin helps for native localization in the following use cases:
### Localizing App Name
The plugin will help to localize your app name if you require it to be named differently in different languages. Use the following json file format.
The plugin will help localize the app name if you require it to be named differently in different languages. Use the following JSON file format.

@@ -160,3 +159,3 @@ ```json

This plugin will help in localize the iOS permission descriptions, for example NSCameraUsageDescription. A full list of iOS permissions and other infoPlist strings that can be found here. (https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html "CocoaKeys")
This plugin will help localize the iOS permission descriptions, for example `NSCameraUsageDescription`. A full list of iOS permissions and other `InfoPlist` strings that can be found [here](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html).

@@ -176,6 +175,6 @@ Example usage:

Typically, there are 2 main ways push notifications can be localised:
Typically, there are 2 main ways push notifications can be localized:
- your app saves your user's selected language on the server, and pushes a localised string in the push notification to your user.
- your server pushes a key to the phone, and the app displays a localised version based on the key in the localization bundle, as determined from the user's phone OS's language.
- your app saves your user's selected language on the server, and pushes a localized string in the push notification to your user.
- your server pushes a key to the phone, and the app displays a localized version based on the key in the localization bundle, as determined from the user's phone OS's language.

@@ -186,4 +185,4 @@ This plugin helps in the latter approach.

- Storing Localized Content in Your App Bundle (https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW9)
- Formatting strings (https://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling)
- [Storing Localized Content in Your App Bundle](https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW9)
- [Formatting strings](https://developer.android.com/guide/topics/resources/string-resource.html#FormattingAndStyling)

@@ -201,3 +200,3 @@ Example usage:

The plugin will automatically generate Localizable.strings file using the following entry on iOS:
The plugin will automatically generate `Localizable.strings` file using the following entry on iOS:

@@ -209,3 +208,3 @@ ```

And on Android, the respective locale's strings.xml:
And on Android, the respective locale's `strings.xml`:

@@ -220,12 +219,16 @@ ```xml

## Details (iOS)
## Details for iOS
The plugin reads the assumed directory structure. The plugin reads from all the fields in config_ios and writes into the InfoPlist.strings, which will be placed in the respective locale.lproj directory. The rest of the strings in "app" will be placed in the Localizable.strings file and placed in the locale directory.
The plugin reads the assumed directory structure. It then reads from all the fields in `"config_ios"` and writes into the `InfoPlist.strings`, which will be placed in the respective `locale.lproj` directory. The rest of the strings in `"app"` will be placed in the `Localizable.strings` file inside the locale directory.
## Details (Android)
## Details for Android
The plugin reads the assumed directory structure, the plugin will combine all properties in "config_android" and "app", and inserted into the strings.xml of the locale's /res/val-locale/strings.xml
The plugin reads the assumed directory structure. It then combines all properties in `"config_android"` and `"app"` to insert them into the `strings.xml` of the locale's `/res/values-<xx>/strings.xml`.
## Override platform specific translations:
Note that for the app's default language the strings are stored in `"/res/values/strings.xml"` (directory name without `-<xx>` suffix).
This plugin considers `'en'` for the default value, matching your `en.json` file if it exists, but to change this you should define your own value through the `defaultlocale` attribute on your [`<widget>`](https://cordova.apache.org/docs/en/latest/config_ref/#widget) in _config.xml_.
For example `<widget id="" defaultlocale="es">…</widget>`.
## Overriding platform specific translations:
```json

@@ -248,2 +251,2 @@ {

(if `app_ios` or `app_android` are detected they will be used and override keys from `app`)
If `"app_ios"` or `"app_android"` are detected, they will be used and override keys from `"app"`.

@@ -168,3 +168,3 @@ var fs = require('fs');

var langJsonToProcess = _.extend(langJson.config_android, langJson.app, langJson.app_android);
var langJsonToProcess = _.extend({}, langJson.config_android, langJson.app, langJson.app_android);

@@ -171,0 +171,0 @@ // now iterate through langJsonToProcess

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc