react-localize-redux
Advanced tools
Comparing version 2.4.0 to 2.4.1
@@ -221,3 +221,3 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
} else { | ||
throw new Error('react-localize-redux: invalid key passed to translate.'); | ||
throw new Error('react-localize-redux: Invalid key passed to getTranslate.'); | ||
} | ||
@@ -354,3 +354,3 @@ }; | ||
var getLocalizedElement = exports.getLocalizedElement = function getLocalizedElement(key, translations, data) { | ||
var localizedString = translations[key] || 'Missing locaized: ' + key; | ||
var localizedString = translations[key] || 'Missing localized key: ' + key; | ||
var translatedValue = templater(localizedString, data); | ||
@@ -357,0 +357,0 @@ return hasHtmlTags(translatedValue) ? _react2.default.createElement('span', { dangerouslySetInnerHTML: { __html: translatedValue } }) : translatedValue; |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-redux"),require("redux"),require("reselect")):"function"==typeof define&&define.amd?define(["react","react-redux","redux","reselect"],t):"object"==typeof exports?exports.ReactLocalizeRedux=t(require("react"),require("react-redux"),require("redux"),require("reselect")):e.ReactLocalizeRedux=t(e.React,e.ReactRedux,e.Redux,e.Reselect)}(this,function(e,t,n,r){return function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(e,t,n){"use strict";function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];switch(t.type){case f:var n=t.payload.languageCodes,r=t.payload.activeLanguage||n[0],a=n.indexOf(r);return n.map(function(e,t){return{code:e,active:t===a}});case g:return e.map(function(e){return e.code===t.payload.languageCode?o({},e,{active:!0}):o({},e,{active:!1})});default:return e}}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];switch(t.type){case s:return o({},e,(0,c.flatten)(t.payload.translation,{safe:!0}));default:return e}}t.__esModule=!0,t.getTranslate=t.getTranslationsForActiveLanguage=t.customeEqualSelector=t.getActiveLanguage=t.getLanguages=t.getTranslations=t.setActiveLanguage=t.setLanguages=t.addTranslation=t.localeReducer=t.TRANSLATE=t.SET_ACTIVE_LANGUAGE=t.SET_LANGUAGES=t.ADD_TRANSLATION=void 0;var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t.languages=r,t.translations=a;var u=n(8),c=n(5),i=n(9),l=n(4),s=t.ADD_TRANSLATION="@@localize/ADD_TRANSLATION",f=t.SET_LANGUAGES="@@localize/SET_LANGUAGES",g=t.SET_ACTIVE_LANGUAGE="@@localize/SET_ACTIVE_LANGUAGE",d=(t.TRANSLATE="@@localize/TRANSLATE",t.localeReducer=(0,u.combineReducers)({languages:r,translations:a}),t.addTranslation=function(e){return{type:s,payload:{translation:e}}},t.setLanguages=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return{type:f,payload:{languageCodes:e,activeLanguage:t}}},t.setActiveLanguage=function(e){return{type:g,payload:{languageCode:e}}},t.getTranslations=function(e){return e.translations}),p=t.getLanguages=function(e){return e.languages},v=t.getActiveLanguage=function(e){return p(e).find(function(e){return!0===e.active})},y=t.customeEqualSelector=(0,i.createSelectorCreator)(i.defaultMemoize,function(e,t){return!(Array.isArray(e)||"code,active"===Object.keys(e).toString())&&(t=Object.keys(t).toString(),e=Object.keys(e).toString()),t===e}),b=t.getTranslationsForActiveLanguage=y(v,p,d,function(e,t,n){var r=e.code,a=(0,l.getIndexForLanguageCode)(r,t);return Object.keys(n).reduce(function(e,t){var r;return o({},e,(r={},r[t]=n[t][a],r))},{})});t.getTranslate=(0,i.createSelector)(b,function(e){return function(t,n){if("string"==typeof t)return(0,l.getLocalizedElement)(t,e,n);if(Array.isArray(t))return t.reduce(function(t,r){var a;return o({},t,(a={},a[r]=(0,l.getLocalizedElement)(r,e,n),a))},{});throw new Error("react-localize-redux: invalid key passed to translate.")}})},function(t,n){t.exports=e},function(e,t,n){"use strict";t.__esModule=!0,t.localize=void 0;var r=n(1),a=(function(e){e&&e.__esModule}(r),n(7)),o=n(0),u=function(e){return function(t){var n=e?t[e]:t;return{currentLanguage:(0,o.getActiveLanguage)(n).code,translate:(0,o.getTranslate)(n)}}};t.localize=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,a.connect)(u(t),null)(e)}},function(e,t,n){"use strict";t.__esModule=!0;var r=n(2);Object.defineProperty(t,"localize",{enumerable:!0,get:function(){return r.localize}});var a=n(0);Object.defineProperty(t,"localeReducer",{enumerable:!0,get:function(){return a.localeReducer}}),Object.defineProperty(t,"addTranslation",{enumerable:!0,get:function(){return a.addTranslation}}),Object.defineProperty(t,"setLanguages",{enumerable:!0,get:function(){return a.setLanguages}}),Object.defineProperty(t,"setActiveLanguage",{enumerable:!0,get:function(){return a.setActiveLanguage}}),Object.defineProperty(t,"getTranslate",{enumerable:!0,get:function(){return a.getTranslate}}),Object.defineProperty(t,"getActiveLanguage",{enumerable:!0,get:function(){return a.getActiveLanguage}}),Object.defineProperty(t,"getLanguages",{enumerable:!0,get:function(){return a.getLanguages}}),Object.defineProperty(t,"getTranslations",{enumerable:!0,get:function(){return a.getTranslations}})},function(e,t,n){"use strict";t.__esModule=!0,t.getIndexForLanguageCode=t.templater=t.hasHtmlTags=t.getLocalizedElement=void 0;var r=n(1),a=function(e){return e&&e.__esModule?e:{default:e}}(r),o=(t.getLocalizedElement=function(e,t,n){var r=t[e]||"Missing locaized: "+e,c=u(r,n);return o(c)?a.default.createElement("span",{dangerouslySetInnerHTML:{__html:c}}):c},t.hasHtmlTags=function(e){var t=/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[\^'">\s]+))?)+\s*|\s*)\/?>/;return e.search(t)>=0}),u=t.templater=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(var n in t){var r="\\${\\s*"+n+"\\s*}",a=new RegExp(r,"gmi");e=e.replace(a,t[n])}return e};t.getIndexForLanguageCode=function(e,t){return t.map(function(e){return e.code}).indexOf(e)}},function(e,t,n){function r(e,t){function n(e,c,i){i=i||1,Object.keys(e).forEach(function(l){var s=e[l],f=t.safe&&Array.isArray(s),g=Object.prototype.toString.call(s),d=o(s),p="[object Object]"===g||"[object Array]"===g,v=c?c+r+l:l;if(!f&&!d&&p&&Object.keys(s).length&&(!t.maxDepth||i<a))return n(s,v,i+1);u[v]=s})}t=t||{};var r=t.delimiter||".",a=t.maxDepth,u={};return n(e),u}function a(e,t){function n(e){var t=Number(e);return isNaN(t)||-1!==e.indexOf(".")?e:t}t=t||{};var r=t.delimiter||".",u=t.overwrite||!1,c={};return o(e)||"[object Object]"!==Object.prototype.toString.call(e)?e:(Object.keys(e).forEach(function(o){for(var i=o.split(r),l=n(i.shift()),s=n(i[0]),f=c;void 0!==s;){var g=Object.prototype.toString.call(f[l]),d="[object Object]"===g||"[object Array]"===g;if(!u&&!d&&void 0!==f[l])return;(u&&!d||!u&&null==f[l])&&(f[l]="number"!=typeof s||t.object?{}:[]),f=f[l],i.length>0&&(l=n(i.shift()),s=n(i[0]))}f[l]=a(e[o],t)}),c)}var o=n(6);e.exports=r;r.flatten=r,r.unflatten=a},function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function r(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}/*! | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-redux"),require("redux"),require("reselect")):"function"==typeof define&&define.amd?define(["react","react-redux","redux","reselect"],t):"object"==typeof exports?exports.ReactLocalizeRedux=t(require("react"),require("react-redux"),require("redux"),require("reselect")):e.ReactLocalizeRedux=t(e.React,e.ReactRedux,e.Redux,e.Reselect)}(this,function(e,t,n,r){return function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(e,t,n){"use strict";function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];switch(t.type){case f:var n=t.payload.languageCodes,r=t.payload.activeLanguage||n[0],a=n.indexOf(r);return n.map(function(e,t){return{code:e,active:t===a}});case g:return e.map(function(e){return e.code===t.payload.languageCode?o({},e,{active:!0}):o({},e,{active:!1})});default:return e}}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1];switch(t.type){case s:return o({},e,(0,c.flatten)(t.payload.translation,{safe:!0}));default:return e}}t.__esModule=!0,t.getTranslate=t.getTranslationsForActiveLanguage=t.customeEqualSelector=t.getActiveLanguage=t.getLanguages=t.getTranslations=t.setActiveLanguage=t.setLanguages=t.addTranslation=t.localeReducer=t.TRANSLATE=t.SET_ACTIVE_LANGUAGE=t.SET_LANGUAGES=t.ADD_TRANSLATION=void 0;var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t.languages=r,t.translations=a;var u=n(8),c=n(5),i=n(9),l=n(4),s=t.ADD_TRANSLATION="@@localize/ADD_TRANSLATION",f=t.SET_LANGUAGES="@@localize/SET_LANGUAGES",g=t.SET_ACTIVE_LANGUAGE="@@localize/SET_ACTIVE_LANGUAGE",d=(t.TRANSLATE="@@localize/TRANSLATE",t.localeReducer=(0,u.combineReducers)({languages:r,translations:a}),t.addTranslation=function(e){return{type:s,payload:{translation:e}}},t.setLanguages=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return{type:f,payload:{languageCodes:e,activeLanguage:t}}},t.setActiveLanguage=function(e){return{type:g,payload:{languageCode:e}}},t.getTranslations=function(e){return e.translations}),p=t.getLanguages=function(e){return e.languages},v=t.getActiveLanguage=function(e){return p(e).find(function(e){return!0===e.active})},y=t.customeEqualSelector=(0,i.createSelectorCreator)(i.defaultMemoize,function(e,t){return!(Array.isArray(e)||"code,active"===Object.keys(e).toString())&&(t=Object.keys(t).toString(),e=Object.keys(e).toString()),t===e}),b=t.getTranslationsForActiveLanguage=y(v,p,d,function(e,t,n){var r=e.code,a=(0,l.getIndexForLanguageCode)(r,t);return Object.keys(n).reduce(function(e,t){var r;return o({},e,(r={},r[t]=n[t][a],r))},{})});t.getTranslate=(0,i.createSelector)(b,function(e){return function(t,n){if("string"==typeof t)return(0,l.getLocalizedElement)(t,e,n);if(Array.isArray(t))return t.reduce(function(t,r){var a;return o({},t,(a={},a[r]=(0,l.getLocalizedElement)(r,e,n),a))},{});throw new Error("react-localize-redux: Invalid key passed to getTranslate.")}})},function(t,n){t.exports=e},function(e,t,n){"use strict";t.__esModule=!0,t.localize=void 0;var r=n(1),a=(function(e){e&&e.__esModule}(r),n(7)),o=n(0),u=function(e){return function(t){var n=e?t[e]:t;return{currentLanguage:(0,o.getActiveLanguage)(n).code,translate:(0,o.getTranslate)(n)}}};t.localize=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,a.connect)(u(t),null)(e)}},function(e,t,n){"use strict";t.__esModule=!0;var r=n(2);Object.defineProperty(t,"localize",{enumerable:!0,get:function(){return r.localize}});var a=n(0);Object.defineProperty(t,"localeReducer",{enumerable:!0,get:function(){return a.localeReducer}}),Object.defineProperty(t,"addTranslation",{enumerable:!0,get:function(){return a.addTranslation}}),Object.defineProperty(t,"setLanguages",{enumerable:!0,get:function(){return a.setLanguages}}),Object.defineProperty(t,"setActiveLanguage",{enumerable:!0,get:function(){return a.setActiveLanguage}}),Object.defineProperty(t,"getTranslate",{enumerable:!0,get:function(){return a.getTranslate}}),Object.defineProperty(t,"getActiveLanguage",{enumerable:!0,get:function(){return a.getActiveLanguage}}),Object.defineProperty(t,"getLanguages",{enumerable:!0,get:function(){return a.getLanguages}}),Object.defineProperty(t,"getTranslations",{enumerable:!0,get:function(){return a.getTranslations}})},function(e,t,n){"use strict";t.__esModule=!0,t.getIndexForLanguageCode=t.templater=t.hasHtmlTags=t.getLocalizedElement=void 0;var r=n(1),a=function(e){return e&&e.__esModule?e:{default:e}}(r),o=(t.getLocalizedElement=function(e,t,n){var r=t[e]||"Missing localized key: "+e,c=u(r,n);return o(c)?a.default.createElement("span",{dangerouslySetInnerHTML:{__html:c}}):c},t.hasHtmlTags=function(e){var t=/<\/?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[\^'">\s]+))?)+\s*|\s*)\/?>/;return e.search(t)>=0}),u=t.templater=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(var n in t){var r="\\${\\s*"+n+"\\s*}",a=new RegExp(r,"gmi");e=e.replace(a,t[n])}return e};t.getIndexForLanguageCode=function(e,t){return t.map(function(e){return e.code}).indexOf(e)}},function(e,t,n){function r(e,t){function n(e,c,i){i=i||1,Object.keys(e).forEach(function(l){var s=e[l],f=t.safe&&Array.isArray(s),g=Object.prototype.toString.call(s),d=o(s),p="[object Object]"===g||"[object Array]"===g,v=c?c+r+l:l;if(!f&&!d&&p&&Object.keys(s).length&&(!t.maxDepth||i<a))return n(s,v,i+1);u[v]=s})}t=t||{};var r=t.delimiter||".",a=t.maxDepth,u={};return n(e),u}function a(e,t){function n(e){var t=Number(e);return isNaN(t)||-1!==e.indexOf(".")?e:t}t=t||{};var r=t.delimiter||".",u=t.overwrite||!1,c={};return o(e)||"[object Object]"!==Object.prototype.toString.call(e)?e:(Object.keys(e).forEach(function(o){for(var i=o.split(r),l=n(i.shift()),s=n(i[0]),f=c;void 0!==s;){var g=Object.prototype.toString.call(f[l]),d="[object Object]"===g||"[object Array]"===g;if(!u&&!d&&void 0!==f[l])return;(u&&!d||!u&&null==f[l])&&(f[l]="number"!=typeof s||t.object?{}:[]),f=f[l],i.length>0&&(l=n(i.shift()),s=n(i[0]))}f[l]=a(e[o],t)}),c)}var o=n(6);e.exports=r;r.flatten=r,r.unflatten=a},function(e,t){function n(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function r(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&n(e.slice(0,0))}/*! | ||
* Determine if an object is a Buffer | ||
@@ -3,0 +3,0 @@ * |
@@ -138,5 +138,5 @@ 'use strict'; | ||
} else { | ||
throw new Error('react-localize-redux: invalid key passed to translate.'); | ||
throw new Error('react-localize-redux: Invalid key passed to getTranslate.'); | ||
} | ||
}; | ||
}); |
@@ -13,3 +13,3 @@ 'use strict'; | ||
var getLocalizedElement = exports.getLocalizedElement = function getLocalizedElement(key, translations, data) { | ||
var localizedString = translations[key] || 'Missing locaized: ' + key; | ||
var localizedString = translations[key] || 'Missing localized key: ' + key; | ||
var translatedValue = templater(localizedString, data); | ||
@@ -16,0 +16,0 @@ return hasHtmlTags(translatedValue) ? _react2.default.createElement('span', { dangerouslySetInnerHTML: { __html: translatedValue } }) : translatedValue; |
@@ -138,5 +138,5 @@ 'use strict'; | ||
} else { | ||
throw new Error('react-localize-redux: invalid key passed to translate.'); | ||
throw new Error('react-localize-redux: Invalid key passed to getTranslate.'); | ||
} | ||
}; | ||
}); |
@@ -13,3 +13,3 @@ 'use strict'; | ||
var getLocalizedElement = exports.getLocalizedElement = function getLocalizedElement(key, translations, data) { | ||
var localizedString = translations[key] || 'Missing locaized: ' + key; | ||
var localizedString = translations[key] || 'Missing localized key: ' + key; | ||
var translatedValue = templater(localizedString, data); | ||
@@ -16,0 +16,0 @@ return hasHtmlTags(translatedValue) ? _react2.default.createElement('span', { dangerouslySetInnerHTML: { __html: translatedValue } }) : translatedValue; |
{ | ||
"name": "react-localize-redux", | ||
"version": "2.4.0", | ||
"version": "2.4.1", | ||
"description": "Dead simple localization for your React/Redux components", | ||
@@ -5,0 +5,0 @@ "main": "lib/index", |
@@ -6,4 +6,2 @@ # TODO: | ||
* only show missing translation text for dev - enhancement | ||
* see if I can use React 15 text element instead of span | ||
* conversion tool for json | ||
* a helper to pass multiple translation labels to child components | ||
* conversion tool for json |
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
60327