Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-localization

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-localization - npm Package Compare versions

Comparing version 1.0.0 to 1.0.2

34

lib/LocalizedStrings.js
'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 @@

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