react-redux-translate
Advanced tools
Comparing version 1.0.3 to 1.0.4
15
index.js
'use strict'; | ||
function translator (defaultLanguage, storeLanguageKey, path) { | ||
function translator (language, storeLanguageKey, path) { | ||
if (arguments.length < 3) | ||
throw new Error("Function 'translator' require at least three arguments default language, language key in the store, path from the root of the project (directory contained node-modules) to 'i18n' directory"); | ||
function Lang(defaultLanguage, path) { | ||
function Lang(language, path) { | ||
this.path = path; | ||
this.defineSource(defaultLanguage); | ||
this.defineSource(language); | ||
} | ||
@@ -17,3 +17,3 @@ | ||
const i18n = new Lang(defaultLanguage, path); | ||
const i18n = new Lang(language, path); | ||
@@ -49,3 +49,8 @@ function translate(props) { | ||
} | ||
return result; | ||
if (!/<\w+>\w?|\w+<\/\w+>/.test(string)) { | ||
return string; | ||
} else { | ||
const innerHtml = props => <span dangerouslySetInnerHTML={{__html: props}} /> | ||
return innerHtml(string); | ||
} | ||
} | ||
@@ -52,0 +57,0 @@ |
{ | ||
"name": "react-redux-translate", | ||
"version": "1.0.3", | ||
"description": "provide i18n translate using react-redux state", | ||
"version": "1.0.4", | ||
"description": "easy internationalization with react-redux", | ||
"main": "index.js", | ||
@@ -19,3 +19,4 @@ "scripts": { | ||
"react-redux", | ||
"i18n", | ||
"redux", | ||
"react-i18n", | ||
"translate", | ||
@@ -22,0 +23,0 @@ "internationalization" |
@@ -34,4 +34,3 @@ #react-redux-translate | ||
3. 'pathToI18nDirectoryProjectRoot' path form root of the project (the same level where is the node-modules directory) | ||
to 'i18n' directory. | ||
3. 'pathToI18nDirectoryProjectRoot' path form root of the project (the same level where is the node-modules directory) to 'i18n' directory. | ||
@@ -57,3 +56,3 @@ | ||
`"home":{"event": "Meet ${} and ${} at GitHub" }` | ||
`"home": {"event": "Meet ${} and ${} at GitHub" }` | ||
@@ -64,3 +63,10 @@ and you set follow params to the `<T/>`component | ||
you will get **"`Meet Mary and John at GitHub`"** string inside `div`. | ||
you will get **"`Meet Mary and John at GitHub`"** string inside `div`. | ||
Of cause you can add any HTML tags with **class** attribute: | ||
"home": "<a href='some-link' class="this-string-will-blue-as-link">Some text <i>some text with italic style</i></span>" | ||
You don't need to do any special to insert HTML tags into translation string! | ||
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
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
58651
6
52
69
3