react-localization
Advanced tools
Comparing version 1.0.0 to 1.0.2
'use strict'; | ||
/** | ||
* Simple module to localize the React interface using the same syntax | ||
* used in the ReactNativeLocalization module | ||
* (https://github.com/stefalda/ReactNativeLocalization) | ||
* | ||
* Originally developed by Stefano Falda (stefano.falda@gmail.com) | ||
* | ||
* It uses a call to the Navigator/Browser object to get the current interface language, | ||
* then display the correct language strings or the default language (the first | ||
* one if a match is not found). | ||
* | ||
* This library has been refactored to use the newly created localized-strings package so to | ||
* unify the code and make it easier to mantain | ||
* | ||
* How to use: | ||
* Check the instructions at: | ||
* https://github.com/stefalda/react-localization | ||
*/ | ||
@@ -21,18 +39,2 @@ Object.defineProperty(exports, "__esModule", { | ||
/** | ||
* Simple module to localize the React interface using the same syntax | ||
* used in the ReactNativeLocalization module | ||
* (https://github.com/stefalda/ReactNativeLocalization) | ||
* | ||
* Originally developed by Stefano Falda (stefano.falda@gmail.com) | ||
* | ||
* It uses a call to the Navigator/Browser object to get the current interface language, | ||
* then display the correct language strings or the default language (the first | ||
* one if a match is not found). | ||
* | ||
* How to use: | ||
* Check the instructions at: | ||
* https://github.com/stefalda/react-localization | ||
*/ | ||
var isReactComponent = function isReactComponent(value) { | ||
@@ -39,0 +41,0 @@ return _typeof(value.$$typeof) === 'symbol'; |
{ | ||
"name": "react-localization", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"description": "Simple module to localize the React interface using the same syntax used in the ReactNativeLocalization module, use 'npm run build' before publishing", | ||
@@ -36,5 +36,5 @@ "scripts": { | ||
"dependencies": { | ||
"localized-strings": "0.0.4", | ||
"localized-strings": "0.0.5", | ||
"react": "^16.0.0" | ||
} | ||
} |
@@ -6,4 +6,6 @@ # react-localization | ||
### Note about version 1.x | ||
This library has been refactored to use the newly created [localized-strings package]((https://github.com/stefalda/localized-strings), now added as a dependency, so to unify the code and make it easier to mantain | ||
This library has been refactored to use the newly created [localized-strings package](https://github.com/stefalda/localized-strings), now added as a dependency, so to unify the code and make it easier to mantain | ||
All the basic code is now in the localized-strings project but this React version add support for embedding JSX code in the formatted strings, by overriding the formatString method. | ||
## How it works | ||
@@ -16,2 +18,3 @@ | ||
##Installation | ||
`npm install --save react-localization` | ||
@@ -50,2 +53,22 @@ | ||
``` | ||
The first language is considered the default one, so if a translation is missing for the selected language, the default one is shown and a line is written to the log as a reminder. | ||
#### Update / Overwrite Locale | ||
You might have default localized in the build but then download the latest localization strings from a server. Use setContent to overwrite the whole object. | ||
**NOTE** that this will remove all other localizations if used. | ||
```js | ||
strings.setContent({ | ||
en:{ | ||
how:"How do you want your egg todajsie?", | ||
boiledEgg:"Boiled eggsie", | ||
softBoiledEgg:"Soft-boiled egg", | ||
choice:"How to choose the egg" | ||
} | ||
}) | ||
``` | ||
## API | ||
@@ -52,0 +75,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
11992
95
150
0
+ Addedlocalized-strings@0.0.5(transitive)
- Removedlocalized-strings@0.0.4(transitive)
Updatedlocalized-strings@0.0.5