react-localize-redux
Advanced tools
Comparing version 3.2.2 to 3.2.3
@@ -0,1 +1,5 @@ | ||
## 3.2.3 (July 13, 2018) | ||
* Fix issue with onMissingTranslation not handling defaultTranslation properly [#110](https://github.com/ryandrewjohnson/react-localize-redux/pull/110) | ||
## 3.2.2 (July 11, 2018) | ||
@@ -2,0 +6,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactLocalizeRedux=t(require("react")):e.ReactLocalizeRedux=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.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=18)}([function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];switch(t.type){case g:var n=t.payload.options||{};return t.payload.languages.map(function(e,t){var r=function(e){return void 0!==n.defaultLanguage?e===n.defaultLanguage:0===t};return"string"==typeof e?{code:e,active:r(e)}:l({},e,{active:r(e.code)})});case h:return e.map(function(e){return e.code===t.payload.languageCode?l({},e,{active:!0}):l({},e,{active:!1})});default:return e}}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],n=void 0,r=void 0;switch(t.type){case g:if(!t.payload.translation)return e;n=(0,f.flatten)(t.payload.translation,{safe:!0});var o=t.payload.options||{},a="string"==typeof t.payload.languages[0]?t.payload.languages[0]:t.payload.languages[0].code,i=o.defaultLanguage||a,u=Object.keys(n).some(function(e){return Array.isArray(n[e])}),c=u?n:(0,p.getSingleToMultilanguageTranslation)(i,t.languageCodes,n,e);return l({},e,c);case v:return r=t.payload.translationOptions&&void 0!==t.payload.translationOptions.translationTransform?t.payload.translationOptions.translationTransform(t.payload.translation||{},t.languageCodes):t.payload.translation,l({},e,(0,f.flatten)(r,{safe:!0}));case y:return n=(0,f.flatten)(t.payload.translation,{safe:!0}),l({},e,(0,p.getSingleToMultilanguageTranslation)(t.payload.language,t.languageCodes,n,e));default:return e}}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b,t=arguments[1];switch(t.type){case g:var n=t.payload.options||{},r=n.defaultLanguage||t.languageCodes[0];return l({},e,(0,p.validateOptions)(n),{defaultLanguage:r});default:return e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getTranslate=t.getTranslationsForSpecificLanguage=t.getTranslationsForActiveLanguage=t.translationsEqualSelector=t.getActiveLanguage=t.getOptions=t.getLanguages=t.getTranslations=t.setActiveLanguage=t.addTranslationForLanguage=t.addTranslation=t.initialize=t.localizeReducer=t.defaultTranslateOptions=t.TRANSLATE=t.SET_ACTIVE_LANGUAGE=t.ADD_TRANSLATION_FOR_LANGUAGE=t.ADD_TRANSLATION=t.INITIALIZE=void 0;var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l=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=a,t.translations=i,t.options=u;var s=n(0),f=(function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);t.default=e}(s),n(4),n(8)),d=n(15),p=n(3),g=t.INITIALIZE="@@localize/INITIALIZE",v=t.ADD_TRANSLATION="@@localize/ADD_TRANSLATION",y=t.ADD_TRANSLATION_FOR_LANGUAGE="@@localize/ADD_TRANSLATION_FOR_LANGUAGE",h=t.SET_ACTIVE_LANGUAGE="@@localize/SET_ACTIVE_LANGUAGE",b=(t.TRANSLATE="@@localize/TRANSLATE",t.defaultTranslateOptions={renderToStaticMarkup:!1,renderInnerHtml:!1,ignoreTranslateChildren:!1,onMissingTranslation:function(e){e.translationId,e.languageCode;return"Missing translationId: ${ translationId } for language: ${ languageCode }"}}),m={languages:[],translations:{},options:b},O=(t.localizeReducer=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m,t=arguments[1],n=e.languages.map(function(e){return e.code});return{languages:a(e.languages,t),translations:i(e.translations,l({},t,{languageCodes:n})),options:u(e.options,l({},t,{languageCodes:n}))}},t.initialize=function(e){return{type:g,payload:e}},t.addTranslation=function(e,t){return{type:v,payload:{translation:e,translationOptions:t}}},t.addTranslationForLanguage=function(e,t){return{type:y,payload:{translation:e,language:t}}},t.setActiveLanguage=function(e){return{type:h,payload:{languageCode:e}}},t.getTranslations=function(e){return e.translations}),T=t.getLanguages=function(e){return e.languages},j=t.getOptions=function(e){return e.options},w=t.getActiveLanguage=function(e){return T(e).filter(function(e){return!0===e.active})[0]},_=t.translationsEqualSelector=(0,d.createSelectorCreator)(d.defaultMemoize,function(e,t){var n="object"===(void 0===e?"undefined":c(e))?Object.keys(e).toString():void 0,r="object"===(void 0===t?"undefined":c(t))?Object.keys(t).toString():void 0,o="object"===(void 0===e?"undefined":c(e))?(0,p.objectValuesToString)(e):void 0,a="object"===(void 0===t?"undefined":c(t))?(0,p.objectValuesToString)(t):void 0;return(void 0!==n&&void 0!==o?n+" - "+o:e)===(void 0!==r&&void 0!==a?r+" - "+a:t)}),L=t.getTranslationsForActiveLanguage=_(w,T,O,p.getTranslationsForLanguage),x=t.getTranslationsForSpecificLanguage=_(T,O,function(e,t){return(0,d.defaultMemoize)(function(n){return(0,p.getTranslationsForLanguage)({code:n,active:!1},e,t)})}),S=(0,d.createSelector)(L,x,w,j,function(e,t,n,a){return function(i){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=(a.defaultLanguage,o(a,["defaultLanguage"])),f=c.language,d=void 0!==f?t(f):e,g=n&&n.code===a.defaultLanguage?e:void 0!==a.defaultLanguage?t(a.defaultLanguage):{},v=void 0!==f?f:n&&n.code,y=function(e){return h.onMissingTranslation({translationId:e,languageCode:v,defaultTranslation:g[e]})},h=l({},s,c),b=h.renderInnerHtml,m={translations:d,data:u,languageCode:v,renderInnerHtml:b,onMissingTranslation:y};if("string"==typeof i)return(0,p.getLocalizedElement)(l({translationId:i},m));if(Array.isArray(i))return i.reduce(function(e,t){return l({},e,r({},t,(0,p.getLocalizedElement)(l({translationId:t},m))))},{});throw new Error("react-localize-redux: Invalid key passed to getTranslate.")}});t.getTranslate=S},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.LocalizeContext=t.getContextPropsFromState=void 0;var o=n(0),a=(r(o),n(20)),i=r(a),u=n(15),c=n(1),l=function(e){return function(t){return e((0,c.initialize)(t))}},s=function(e){return function(t){return e((0,c.addTranslation)(t))}},f=function(e){return function(t,n){return e((0,c.addTranslationForLanguage)(t,n))}},d=function(e){return function(t){return e((0,c.setActiveLanguage)(t))}},p=t.getContextPropsFromState=function(e){return(0,u.createSelector)(c.getTranslate,c.getLanguages,c.getActiveLanguage,c.getOptions,function(t,n,r,o){var a=o.defaultLanguage||n[0]&&n[0].code,i=o.renderToStaticMarkup,u=void 0!==o.ignoreTranslateChildren?o.ignoreTranslateChildren:c.defaultTranslateOptions.ignoreTranslateChildren;return{translate:t,languages:n,defaultLanguage:a,activeLanguage:r,initialize:l(e),addTranslation:s(e),addTranslationForLanguage:f(e),setActiveLanguage:d(e),renderToStaticMarkup:i,ignoreTranslateChildren:u}})},g=(0,c.localizeReducer)(void 0,{}),v=p(function(){})(g);t.LocalizeContext=(0,i.default)(v)},function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.warning=t.get=t.getSingleToMultilanguageTranslation=t.storeDidChange=t.getTranslationsForLanguage=t.validateOptions=t.objectValuesToString=t.getIndexForLanguageCode=t.templater=t.hasHtmlTags=t.getLocalizedElement=void 0;var o=n(0),a=function(e){return e&&e.__esModule?e:{default:e}}(o);n(4);var i=(n(8),n(1),t.getLocalizedElement=function(e){var t=e.translationId,n=e.translations,o=e.data,c=e.renderInnerHtml,s=e.onMissingTranslation,f=n[t]||s(t),d=n[t]?o:{translationId:e.translationId,languageCode:e.languageCode},p=u(f,d);if("string"==typeof p)return!0===c&&i(p)?a.default.createElement("span",{dangerouslySetInnerHTML:{__html:p}}):p;var g=!0,v=!1,y=void 0;try{for(var h,b=p[Symbol.iterator]();!(g=(h=b.next()).done);g=!0){var m=h.value;if("string"==typeof m&&i(m))return l("HTML tags in the translation string are not supported when passing React components as arguments to the translation."),""}}catch(e){v=!0,y=e}finally{try{!g&&b.return&&b.return()}finally{if(v)throw y}}return a.default.createElement.apply(a.default,["span",null].concat(r(p)))},t.hasHtmlTags=function(e){var t=/(&[^\s]*;|<\/?\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]:{};if(!e)return"";var n=e.split(new RegExp("(\\${\\s*[^\\s]+\\s*})","gmi")).filter(function(e){return!!e}).map(function(e){var n=void 0;for(var r in t){if(n)break;var o="\\${\\s*"+r+"\\s*}";new RegExp(o,"gmi").test(e)&&(n=t[r])}return n||e});return n.some(function(e){return a.default.isValidElement(e)})?n:n.reduce(function(e,t){return e+""+t},"")},c=t.getIndexForLanguageCode=function(e,t){return t.map(function(e){return e.code}).indexOf(e)},l=(t.objectValuesToString=function(e){return Object.values?Object.values(e).toString():Object.keys(e).map(function(t){return e[t].toString()}).toString()},t.validateOptions=function(e){if(void 0!==e.onMissingTranslation&&"function"!=typeof e.onMissingTranslation)throw new Error("react-localize-redux: an invalid onMissingTranslation function was provided.");if(!1!==e.renderToStaticMarkup&&"function"!=typeof e.renderToStaticMarkup)throw new Error("\n react-localize-redux: initialize option renderToStaticMarkup is invalid. \n Please see https://ryandrewjohnson.github.io/react-localize-docs/#initialize.\n ");return e},t.getTranslationsForLanguage=function(e,t,n){if(!e)return{};for(var r=e.code,o=c(r,t),a=Object.keys(n),i=a.length,u={},l=0;l<i;l++){var s=a[l];u[s]=n[s][o]}return u},t.storeDidChange=function(e,t){function n(){var n=e.getState();n!==r&&(t(r),r=n)}var r=void 0,o=e.subscribe(n);return n(),o},t.getSingleToMultilanguageTranslation=function(e,t,n,r){for(var o=t.indexOf(e),a=o>=0?n:{},i=Object.keys(a),u=i.length,c={},l=0;l<u;l++)!function(e){var a=i[e],u=t.map(function(e,t){var i=r[a]||[];return t===o?n[a]:i[t]});c[a]=u}(l);return c},t.get=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return t.split(".").filter(Boolean).reduce(function(e,t){return e&&e[t]?e[t]:n},e)},t.warning=function(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(13),o=n(37),a=n(36),i=n(35),u=n(12);n(14);n.d(t,"createStore",function(){return r.a}),n.d(t,"combineReducers",function(){return o.a}),n.d(t,"bindActionCreators",function(){return a.a}),n.d(t,"applyMiddleware",function(){return i.a}),n.d(t,"compose",function(){return u.a})},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e){return function(t){return i.default.createElement(u.LocalizeContext.Consumer,null,function(n){return i.default.createElement(e,o({},n,t))})}}Object.defineProperty(t,"__esModule",{value:!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.withLocalize=r;var a=n(0),i=function(e){return e&&e.__esModule?e:{default:e}}(a),u=n(2)},function(e,t,n){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,n){function r(e,t){function n(e,u,c){c=c||1,Object.keys(e).forEach(function(l){var s=e[l],f=t.safe&&Array.isArray(s),d=Object.prototype.toString.call(s),p=a(s),g="[object Object]"===d||"[object Array]"===d,v=u?u+r+l:l;if(!f&&!p&&g&&Object.keys(s).length&&(!t.maxDepth||c<o))return n(s,v,c+1);i[v]=s})}t=t||{};var r=t.delimiter||".",o=t.maxDepth,i={};return n(e),i}function o(e,t){function n(e){var t=Number(e);return isNaN(t)||-1!==e.indexOf(".")?e:t}t=t||{};var r=t.delimiter||".",i=t.overwrite||!1,u={};return a(e)||"[object Object]"!==Object.prototype.toString.call(e)?e:(Object.keys(e).forEach(function(a){for(var c=a.split(r),l=n(c.shift()),s=n(c[0]),f=u;void 0!==s;){var d=Object.prototype.toString.call(f[l]),p="[object Object]"===d||"[object Array]"===d;if(!i&&!p&&void 0!==f[l])return;(i&&!p||!i&&null==f[l])&&(f[l]="number"!=typeof s||t.object?{}:[]),f=f[l],c.length>0&&(l=n(c.shift()),s=n(c[0]))}f[l]=o(e[a],t)}),u)}var a=n(24);e.exports=r;r.flatten=r,r.unflatten=o},function(e,t,n){"use strict";var r=n(31),o=r.a.Symbol;t.a=o},function(e,t,n){"use strict";function r(e){if(!n.i(i.a)(e)||n.i(o.a)(e)!=u)return!1;var t=n.i(a.a)(e);if(null===t)return!0;var r=f.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&s.call(r)==d}var o=n(25),a=n(27),i=n(32),u="[object Object]",c=Function.prototype,l=Object.prototype,s=c.toString,f=l.hasOwnProperty,d=s.call(Object);t.a=r},function(e,t,n){e.exports=n(33)()},function(e,t,n){"use strict";function r(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}t.a=r},function(e,t,n){"use strict";function r(e,t,a){function c(){b===h&&(b=h.slice())}function l(){return y}function s(e){if("function"!=typeof e)throw new Error("Expected listener to be a function.");var t=!0;return c(),b.push(e),function(){if(t){t=!1,c();var n=b.indexOf(e);b.splice(n,1)}}}function f(e){if(!n.i(o.a)(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(m)throw new Error("Reducers may not dispatch actions.");try{m=!0,y=v(y,e)}finally{m=!1}for(var t=h=b,r=0;r<t.length;r++){(0,t[r])()}return e}function d(e){if("function"!=typeof e)throw new Error("Expected the nextReducer to be a function.");v=e,f({type:u.INIT})}function p(){var e,t=s;return e={subscribe:function(e){function n(){e.next&&e.next(l())}if("object"!=typeof e)throw new TypeError("Expected the observer to be an object.");return n(),{unsubscribe:t(n)}}},e[i.a]=function(){return this},e}var g;if("function"==typeof t&&void 0===a&&(a=t,t=void 0),void 0!==a){if("function"!=typeof a)throw new Error("Expected the enhancer to be a function.");return a(r)(e,t)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var v=e,y=t,h=[],b=h,m=!1;return f({type:u.INIT}),g={dispatch:f,subscribe:s,getState:l,replaceReducer:d},g[i.a]=p,g}n.d(t,"b",function(){return u}),t.a=r;var o=n(10),a=n(38),i=n.n(a),u={INIT:"@@redux/INIT"}},function(e,t,n){"use strict"},function(e,t,n){"use strict";function r(e,t){return e===t}function o(e,t,n){if(null===t||null===n||t.length!==n.length)return!1;for(var r=t.length,o=0;o<r;o++)if(!e(t[o],n[o]))return!1;return!0}function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r,n=null,a=null;return function(){return o(t,n,arguments)||(a=e.apply(null,arguments)),n=arguments,a}}function i(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every(function(e){return"function"==typeof e})){var n=t.map(function(e){return typeof e}).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+n+"]")}return t}function u(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return function(){for(var t=arguments.length,r=Array(t),o=0;o<t;o++)r[o]=arguments[o];var u=0,c=r.pop(),l=i(r),s=e.apply(void 0,[function(){return u++,c.apply(null,arguments)}].concat(n)),f=a(function(){for(var e=[],t=l.length,n=0;n<t;n++)e.push(l[n].apply(null,arguments));return s.apply(null,e)});return f.resultFunc=c,f.recomputations=function(){return u},f.resetRecomputations=function(){return u=0},f}}function c(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l;if("object"!=typeof e)throw new Error("createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);var n=Object.keys(e);return t(n.map(function(t){return e[t]}),function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce(function(e,t,r){return e[n[r]]=t,e},{})})}t.__esModule=!0,t.defaultMemoize=a,t.createSelectorCreator=u,t.createStructuredSelector=c;var l=t.createSelector=u(a)},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.LocalizeProvider=void 0;var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(0),c=function(e){return e&&e.__esModule?e:{default:e}}(u);n(4);var l=n(1),s=n(2),f=n(3);t.LocalizeProvider=function(e){function t(e){r(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e)),a=n.props.store?n.props.store.dispatch:n.dispatch.bind(n);return n.getContextPropsSelector=(0,s.getContextPropsFromState)(a),n.state={localize:(0,l.localizeReducer)(void 0,{})},n}return a(t,e),i(t,[{key:"componentDidMount",value:function(){this.props.store&&(this.unsubscribeFromStore=(0,f.storeDidChange)(this.props.store,this.onStateDidChange.bind(this)))}},{key:"componentWillUnmount",value:function(){this.unsubscribeFromStore&&this.unsubscribeFromStore()}},{key:"onStateDidChange",value:function(e){if(this.props.store){var t=e&&e.localize,n=this.props.store.getState().localize,r=e&&(0,l.getActiveLanguage)(t),o=(0,l.getActiveLanguage)(n),a=e&&(0,l.getOptions)(t),i=(0,l.getOptions)(n),u=e&&(0,l.getTranslationsForActiveLanguage)(t),c=(0,l.getTranslationsForActiveLanguage)(n),s=(r&&r.code)!==(o&&o.code),f=a!==i,d=u!==c;(s||f||d)&&this.setState({localize:n})}}},{key:"dispatch",value:function(e){this.setState(function(t){return{localize:(0,l.localizeReducer)(t.localize,e)}})}},{key:"render",value:function(){return this.contextProps=this.getContextPropsSelector(this.state.localize),c.default.createElement(s.LocalizeContext.Provider,{value:this.contextProps},this.props.children)}}],[{key:"getDerivedStateFromProps",value:function(e,t){return null}}]),t}(u.Component)},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.Translate=void 0;var u=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},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(0),s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(l),f=n(11),d=(function(e){e&&e.__esModule}(f),n(1),n(3)),p=n(2),g=(n(6),function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),c(t,[{key:"componentDidMount",value:function(){this.addDefaultTranslation()}},{key:"componentDidUpdate",value:function(e){var t=this.props.id&&e.id!==this.props.id,n=!(0,d.get)(e,"context.defaultLanguage")&&!(0,d.get)(e,"options.language"),r=(0,d.get)(this.props,"context.defaultLanguage")||(0,d.get)(this.props,"options.language"),o=n&&r;(t||o)&&this.addDefaultTranslation()}},{key:"addDefaultTranslation",value:function(){var e=this.props,t=e.context,n=e.id,o=e.children,a=e.options,i=void 0===a?{}:a,u=i.language||t.defaultLanguage,c=function(e){return e},l=t.renderToStaticMarkup||c,s=void 0!==n,f=void 0!==u,d=void 0!==o,p="function"==typeof o,g=void 0!==i.ignoreTranslateChildren?i.ignoreTranslateChildren:t.ignoreTranslateChildren;if(d&&s&&f&&!p&&!g){var v=l(o);t.addTranslationForLanguage&&t.addTranslationForLanguage(r({},n,v),u)}}},{key:"renderChildren",value:function(){var e=this.props,t=e.context,n=e.id,r=void 0===n?"":n,o=e.options,a=e.data;return"function"==typeof this.props.children?this.props.children(t):t.translate&&t.translate(r,a,o)}},{key:"render",value:function(){return this.renderChildren()}}]),t}(s.Component));t.Translate=function(e){return s.createElement(p.LocalizeContext.Consumer,null,function(t){return s.createElement(g,u({},e,{context:t}))})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(17);Object.defineProperty(t,"Translate",{enumerable:!0,get:function(){return r.Translate}});var o=n(6);Object.defineProperty(t,"withLocalize",{enumerable:!0,get:function(){return o.withLocalize}});var a=n(16);Object.defineProperty(t,"LocalizeProvider",{enumerable:!0,get:function(){return a.LocalizeProvider}});var i=n(2);Object.defineProperty(t,"LocalizeContext",{enumerable:!0,get:function(){return i.LocalizeContext}});var u=n(1);Object.defineProperty(t,"localizeReducer",{enumerable:!0,get:function(){return u.localizeReducer}}),Object.defineProperty(t,"initialize",{enumerable:!0,get:function(){return u.initialize}}),Object.defineProperty(t,"addTranslation",{enumerable:!0,get:function(){return u.addTranslation}}),Object.defineProperty(t,"addTranslationForLanguage",{enumerable:!0,get:function(){return u.addTranslationForLanguage}}),Object.defineProperty(t,"setActiveLanguage",{enumerable:!0,get:function(){return u.setActiveLanguage}}),Object.defineProperty(t,"getTranslate",{enumerable:!0,get:function(){return u.getTranslate}}),Object.defineProperty(t,"getActiveLanguage",{enumerable:!0,get:function(){return u.getActiveLanguage}}),Object.defineProperty(t,"getLanguages",{enumerable:!0,get:function(){return u.getLanguages}}),Object.defineProperty(t,"getTranslations",{enumerable:!0,get:function(){return u.getTranslations}}),Object.defineProperty(t,"getOptions",{enumerable:!0,get:function(){return u.getOptions}})},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e,t){return e===t?0!==e||1/e==1/t:e!==e&&t!==t}function c(e){var t=[];return{on:function(e){t.push(e)},off:function(e){t=t.filter(function(t){return t!==e})},get:function(){return e},set:function(n,r){e=n,t.forEach(function(t){return t(e,r)})}}}function l(e){return Array.isArray(e)?e[0]:e}function s(e,t){var n,r,s="__create-react-context-"+(0,v.default)()+"__",d=function(e){function n(){var t,r,i;o(this,n);for(var u=arguments.length,l=Array(u),s=0;s<u;s++)l[s]=arguments[s];return t=r=a(this,e.call.apply(e,[this].concat(l))),r.emitter=c(r.props.value),i=t,a(r,i)}return i(n,e),n.prototype.getChildContext=function(){var e;return e={},e[s]=this.emitter,e},n.prototype.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var n=this.props.value,r=e.value,o=void 0;u(n,r)?o=0:(o="function"==typeof t?t(n,r):h,0!==(o|=0)&&this.emitter.set(e.value,o))}},n.prototype.render=function(){return this.props.children},n}(f.Component);d.childContextTypes=(n={},n[s]=p.default.object.isRequired,n);var g=function(t){function n(){var e,r,i;o(this,n);for(var u=arguments.length,c=Array(u),l=0;l<u;l++)c[l]=arguments[l];return e=r=a(this,t.call.apply(t,[this].concat(c))),r.state={value:r.getValue()},r.onUpdate=function(e,t){0!=((0|r.observedBits)&t)&&r.setState({value:r.getValue()})},i=e,a(r,i)}return i(n,t),n.prototype.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=void 0===t||null===t?h:t},n.prototype.componentDidMount=function(){this.context[s]&&this.context[s].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=void 0===e||null===e?h:e},n.prototype.componentWillUnmount=function(){this.context[s]&&this.context[s].off(this.onUpdate)},n.prototype.getValue=function(){return this.context[s]?this.context[s].get():e},n.prototype.render=function(){return l(this.props.children)(this.state.value)},n}(f.Component);return g.contextTypes=(r={},r[s]=p.default.object,r),{Provider:d,Consumer:g}}t.__esModule=!0;var f=n(0),d=(r(f),n(11)),p=r(d),g=n(23),v=r(g),y=n(22),h=(r(y),1073741823);t.default=s,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var o=n(0),a=r(o),i=n(19),u=r(i);t.default=a.default.createContext||u.default,e.exports=t.default},function(e,t,n){"use strict";function r(e,t,n,r,a,i,u,c){if(o(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,r,a,i,u,c],f=0;l=new Error(t.replace(/%s/g,function(){return s[f++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var o=function(e){};e.exports=r},function(e,t,n){"use strict";var r=n(7),o=r;e.exports=o},function(e,t,n){"use strict";(function(t){var n="__global_unique_id__";e.exports=function(){return t[n]=(t[n]||0)+1}}).call(t,n(5))},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")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactLocalizeRedux=t(require("react")):e.ReactLocalizeRedux=t(e.React)}(this,function(e){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.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=18)}([function(t,n){t.exports=e},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1];switch(t.type){case g:var n=t.payload.options||{};return t.payload.languages.map(function(e,t){var r=function(e){return void 0!==n.defaultLanguage?e===n.defaultLanguage:0===t};return"string"==typeof e?{code:e,active:r(e)}:l({},e,{active:r(e.code)})});case h:return e.map(function(e){return e.code===t.payload.languageCode?l({},e,{active:!0}):l({},e,{active:!1})});default:return e}}function i(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments[1],n=void 0,r=void 0;switch(t.type){case g:if(!t.payload.translation)return e;n=(0,f.flatten)(t.payload.translation,{safe:!0});var o=t.payload.options||{},a="string"==typeof t.payload.languages[0]?t.payload.languages[0]:t.payload.languages[0].code,i=o.defaultLanguage||a,u=Object.keys(n).some(function(e){return Array.isArray(n[e])}),c=u?n:(0,p.getSingleToMultilanguageTranslation)(i,t.languageCodes,n,e);return l({},e,c);case v:return r=t.payload.translationOptions&&void 0!==t.payload.translationOptions.translationTransform?t.payload.translationOptions.translationTransform(t.payload.translation||{},t.languageCodes):t.payload.translation,l({},e,(0,f.flatten)(r,{safe:!0}));case y:return n=(0,f.flatten)(t.payload.translation,{safe:!0}),l({},e,(0,p.getSingleToMultilanguageTranslation)(t.payload.language,t.languageCodes,n,e));default:return e}}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:b,t=arguments[1];switch(t.type){case g:var n=t.payload.options||{},r=n.defaultLanguage||t.languageCodes[0];return l({},e,(0,p.validateOptions)(n),{defaultLanguage:r});default:return e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getTranslate=t.getTranslationsForSpecificLanguage=t.getTranslationsForActiveLanguage=t.translationsEqualSelector=t.getActiveLanguage=t.getOptions=t.getLanguages=t.getTranslations=t.setActiveLanguage=t.addTranslationForLanguage=t.addTranslation=t.initialize=t.localizeReducer=t.defaultTranslateOptions=t.TRANSLATE=t.SET_ACTIVE_LANGUAGE=t.ADD_TRANSLATION_FOR_LANGUAGE=t.ADD_TRANSLATION=t.INITIALIZE=void 0;var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},l=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=a,t.translations=i,t.options=u;var s=n(0),f=(function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);t.default=e}(s),n(4),n(8)),d=n(15),p=n(3),g=t.INITIALIZE="@@localize/INITIALIZE",v=t.ADD_TRANSLATION="@@localize/ADD_TRANSLATION",y=t.ADD_TRANSLATION_FOR_LANGUAGE="@@localize/ADD_TRANSLATION_FOR_LANGUAGE",h=t.SET_ACTIVE_LANGUAGE="@@localize/SET_ACTIVE_LANGUAGE",b=(t.TRANSLATE="@@localize/TRANSLATE",t.defaultTranslateOptions={renderToStaticMarkup:!1,renderInnerHtml:!1,ignoreTranslateChildren:!1,defaultLanguage:"",onMissingTranslation:function(e){e.translationId,e.languageCode;return"Missing translationId: ${ translationId } for language: ${ languageCode }"}}),m={languages:[],translations:{},options:b},O=(t.localizeReducer=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:m,t=arguments[1],n=e.languages.map(function(e){return e.code});return{languages:a(e.languages,t),translations:i(e.translations,l({},t,{languageCodes:n})),options:u(e.options,l({},t,{languageCodes:n}))}},t.initialize=function(e){return{type:g,payload:e}},t.addTranslation=function(e,t){return{type:v,payload:{translation:e,translationOptions:t}}},t.addTranslationForLanguage=function(e,t){return{type:y,payload:{translation:e,language:t}}},t.setActiveLanguage=function(e){return{type:h,payload:{languageCode:e}}},t.getTranslations=function(e){return e.translations}),T=t.getLanguages=function(e){return e.languages},j=t.getOptions=function(e){var t=Object.assign({},e.options),n=void 0;return t.defaultLanguage||(n=T(e)||[],t.defaultLanguage=n[0]?n[0].code:""),t},w=t.getActiveLanguage=function(e){return T(e).filter(function(e){return!0===e.active})[0]},_=t.translationsEqualSelector=(0,d.createSelectorCreator)(d.defaultMemoize,function(e,t){var n="object"===(void 0===e?"undefined":c(e))?Object.keys(e).toString():void 0,r="object"===(void 0===t?"undefined":c(t))?Object.keys(t).toString():void 0,o="object"===(void 0===e?"undefined":c(e))?(0,p.objectValuesToString)(e):void 0,a="object"===(void 0===t?"undefined":c(t))?(0,p.objectValuesToString)(t):void 0;return(void 0!==n&&void 0!==o?n+" - "+o:e)===(void 0!==r&&void 0!==a?r+" - "+a:t)}),L=t.getTranslationsForActiveLanguage=_(w,T,O,p.getTranslationsForLanguage),x=t.getTranslationsForSpecificLanguage=_(T,O,function(e,t){return(0,d.defaultMemoize)(function(n){return(0,p.getTranslationsForLanguage)({code:n,active:!1},e,t)})}),S=(0,d.createSelector)(L,x,w,j,function(e,t,n,a){return function(i){var u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=a.defaultLanguage,f=o(a,["defaultLanguage"]),d=c.language,g=void 0!==d?t(d):e,v=n&&n.code===s?e:t(s),y=void 0!==d?d:n&&n.code,h=l({},f,c),b=function(e){var t=void 0!==g[e],n=void 0!==v[e],r=n?(0,p.getLocalizedElement)({translation:v[e],data:u,renderInnerHtml:h.renderInnerHtml}):"No default translation found! Ensure you've added translations for your default langauge.",o=t?g[e]:h.onMissingTranslation({translationId:e,languageCode:y,defaultTranslation:r}),a=t?u:{translationId:e,languageCode:y};return(0,p.getLocalizedElement)({translation:o,data:a,languageCode:y,renderInnerHtml:h.renderInnerHtml})};if("string"==typeof i)return b(i);if(Array.isArray(i))return i.reduce(function(e,t){return l({},e,r({},t,b(t)))},{});throw new Error("react-localize-redux: Invalid key passed to getTranslate.")}});t.getTranslate=S},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.LocalizeContext=t.getContextPropsFromState=void 0;var o=n(0),a=(r(o),n(20)),i=r(a),u=n(15),c=n(1),l=function(e){return function(t){return e((0,c.initialize)(t))}},s=function(e){return function(t){return e((0,c.addTranslation)(t))}},f=function(e){return function(t,n){return e((0,c.addTranslationForLanguage)(t,n))}},d=function(e){return function(t){return e((0,c.setActiveLanguage)(t))}},p=t.getContextPropsFromState=function(e){return(0,u.createSelector)(c.getTranslate,c.getLanguages,c.getActiveLanguage,c.getOptions,function(t,n,r,o){var a=o.defaultLanguage||n[0]&&n[0].code,i=o.renderToStaticMarkup,u=void 0!==o.ignoreTranslateChildren?o.ignoreTranslateChildren:c.defaultTranslateOptions.ignoreTranslateChildren;return{translate:t,languages:n,defaultLanguage:a,activeLanguage:r,initialize:l(e),addTranslation:s(e),addTranslationForLanguage:f(e),setActiveLanguage:d(e),renderToStaticMarkup:i,ignoreTranslateChildren:u}})},g=(0,c.localizeReducer)(void 0,{}),v=p(function(){})(g);t.LocalizeContext=(0,i.default)(v)},function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.warning=t.get=t.getSingleToMultilanguageTranslation=t.storeDidChange=t.getTranslationsForLanguage=t.validateOptions=t.objectValuesToString=t.getIndexForLanguageCode=t.templater=t.hasHtmlTags=t.getLocalizedElement=void 0;var o=n(0),a=function(e){return e&&e.__esModule?e:{default:e}}(o);n(4);var i=(n(8),n(1),t.getLocalizedElement=function(e){var t=e.translation,n=e.data,o=e.renderInnerHtml,c=u(t,n);if("string"==typeof c)return!0===o&&i(c)?a.default.createElement("span",{dangerouslySetInnerHTML:{__html:c}}):c;var s=!0,f=!1,d=void 0;try{for(var p,g=c[Symbol.iterator]();!(s=(p=g.next()).done);s=!0){var v=p.value;if("string"==typeof v&&i(v))return l("HTML tags in the translation string are not supported when passing React components as arguments to the translation."),""}}catch(e){f=!0,d=e}finally{try{!s&&g.return&&g.return()}finally{if(f)throw d}}return a.default.createElement.apply(a.default,["span",null].concat(r(c)))},t.hasHtmlTags=function(e){var t=/(&[^\s]*;|<\/?\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]:{};if(!e)return"";var n=e.split(new RegExp("(\\${\\s*[^\\s]+\\s*})","gmi")).filter(function(e){return!!e}).map(function(e){var n=void 0;for(var r in t){if(n)break;var o="\\${\\s*"+r+"\\s*}";new RegExp(o,"gmi").test(e)&&(n=t[r])}return n||e});return n.some(function(e){return a.default.isValidElement(e)})?n:n.reduce(function(e,t){return e+""+t},"")},c=t.getIndexForLanguageCode=function(e,t){return t.map(function(e){return e.code}).indexOf(e)},l=(t.objectValuesToString=function(e){return Object.values?Object.values(e).toString():Object.keys(e).map(function(t){return e[t].toString()}).toString()},t.validateOptions=function(e){if(void 0!==e.onMissingTranslation&&"function"!=typeof e.onMissingTranslation)throw new Error("react-localize-redux: an invalid onMissingTranslation function was provided.");if(!1!==e.renderToStaticMarkup&&"function"!=typeof e.renderToStaticMarkup)throw new Error("\n react-localize-redux: initialize option renderToStaticMarkup is invalid.\n Please see https://ryandrewjohnson.github.io/react-localize-docs/#initialize.\n ");return e},t.getTranslationsForLanguage=function(e,t,n){if(!e)return{};for(var r=e.code,o=c(r,t),a=Object.keys(n),i=a.length,u={},l=0;l<i;l++){var s=a[l];u[s]=n[s][o]}return u},t.storeDidChange=function(e,t){function n(){var n=e.getState();n!==r&&(t(r),r=n)}var r=void 0,o=e.subscribe(n);return n(),o},t.getSingleToMultilanguageTranslation=function(e,t,n,r){for(var o=t.indexOf(e),a=o>=0?n:{},i=Object.keys(a),u=i.length,c={},l=0;l<u;l++)!function(e){var a=i[e],u=t.map(function(e,t){var i=r[a]||[];return t===o?n[a]:i[t]});c[a]=u}(l);return c},t.get=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return t.split(".").filter(Boolean).reduce(function(e,t){return e&&e[t]?e[t]:n},e)},t.warning=function(e){"undefined"!=typeof console&&"function"==typeof console.error&&console.error(e);try{throw new Error(e)}catch(e){}})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(13),o=n(37),a=n(36),i=n(35),u=n(12);n(14);n.d(t,"createStore",function(){return r.a}),n.d(t,"combineReducers",function(){return o.a}),n.d(t,"bindActionCreators",function(){return a.a}),n.d(t,"applyMiddleware",function(){return i.a}),n.d(t,"compose",function(){return u.a})},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){"use strict";function r(e){return function(t){return i.default.createElement(u.LocalizeContext.Consumer,null,function(n){return i.default.createElement(e,o({},n,t))})}}Object.defineProperty(t,"__esModule",{value:!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.withLocalize=r;var a=n(0),i=function(e){return e&&e.__esModule?e:{default:e}}(a),u=n(2)},function(e,t,n){"use strict";function r(e){return function(){return e}}var o=function(){};o.thatReturns=r,o.thatReturnsFalse=r(!1),o.thatReturnsTrue=r(!0),o.thatReturnsNull=r(null),o.thatReturnsThis=function(){return this},o.thatReturnsArgument=function(e){return e},e.exports=o},function(e,t,n){function r(e,t){function n(e,u,c){c=c||1,Object.keys(e).forEach(function(l){var s=e[l],f=t.safe&&Array.isArray(s),d=Object.prototype.toString.call(s),p=a(s),g="[object Object]"===d||"[object Array]"===d,v=u?u+r+l:l;if(!f&&!p&&g&&Object.keys(s).length&&(!t.maxDepth||c<o))return n(s,v,c+1);i[v]=s})}t=t||{};var r=t.delimiter||".",o=t.maxDepth,i={};return n(e),i}function o(e,t){function n(e){var t=Number(e);return isNaN(t)||-1!==e.indexOf(".")?e:t}t=t||{};var r=t.delimiter||".",i=t.overwrite||!1,u={};return a(e)||"[object Object]"!==Object.prototype.toString.call(e)?e:(Object.keys(e).forEach(function(a){for(var c=a.split(r),l=n(c.shift()),s=n(c[0]),f=u;void 0!==s;){var d=Object.prototype.toString.call(f[l]),p="[object Object]"===d||"[object Array]"===d;if(!i&&!p&&void 0!==f[l])return;(i&&!p||!i&&null==f[l])&&(f[l]="number"!=typeof s||t.object?{}:[]),f=f[l],c.length>0&&(l=n(c.shift()),s=n(c[0]))}f[l]=o(e[a],t)}),u)}var a=n(24);e.exports=r;r.flatten=r,r.unflatten=o},function(e,t,n){"use strict";var r=n(31),o=r.a.Symbol;t.a=o},function(e,t,n){"use strict";function r(e){if(!n.i(i.a)(e)||n.i(o.a)(e)!=u)return!1;var t=n.i(a.a)(e);if(null===t)return!0;var r=f.call(t,"constructor")&&t.constructor;return"function"==typeof r&&r instanceof r&&s.call(r)==d}var o=n(25),a=n(27),i=n(32),u="[object Object]",c=Function.prototype,l=Object.prototype,s=c.toString,f=l.hasOwnProperty,d=s.call(Object);t.a=r},function(e,t,n){e.exports=n(33)()},function(e,t,n){"use strict";function r(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e){return e}:1===t.length?t[0]:t.reduce(function(e,t){return function(){return e(t.apply(void 0,arguments))}})}t.a=r},function(e,t,n){"use strict";function r(e,t,a){function c(){b===h&&(b=h.slice())}function l(){return y}function s(e){if("function"!=typeof e)throw new Error("Expected listener to be a function.");var t=!0;return c(),b.push(e),function(){if(t){t=!1,c();var n=b.indexOf(e);b.splice(n,1)}}}function f(e){if(!n.i(o.a)(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(m)throw new Error("Reducers may not dispatch actions.");try{m=!0,y=v(y,e)}finally{m=!1}for(var t=h=b,r=0;r<t.length;r++){(0,t[r])()}return e}function d(e){if("function"!=typeof e)throw new Error("Expected the nextReducer to be a function.");v=e,f({type:u.INIT})}function p(){var e,t=s;return e={subscribe:function(e){function n(){e.next&&e.next(l())}if("object"!=typeof e)throw new TypeError("Expected the observer to be an object.");return n(),{unsubscribe:t(n)}}},e[i.a]=function(){return this},e}var g;if("function"==typeof t&&void 0===a&&(a=t,t=void 0),void 0!==a){if("function"!=typeof a)throw new Error("Expected the enhancer to be a function.");return a(r)(e,t)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var v=e,y=t,h=[],b=h,m=!1;return f({type:u.INIT}),g={dispatch:f,subscribe:s,getState:l,replaceReducer:d},g[i.a]=p,g}n.d(t,"b",function(){return u}),t.a=r;var o=n(10),a=n(38),i=n.n(a),u={INIT:"@@redux/INIT"}},function(e,t,n){"use strict"},function(e,t,n){"use strict";function r(e,t){return e===t}function o(e,t,n){if(null===t||null===n||t.length!==n.length)return!1;for(var r=t.length,o=0;o<r;o++)if(!e(t[o],n[o]))return!1;return!0}function a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r,n=null,a=null;return function(){return o(t,n,arguments)||(a=e.apply(null,arguments)),n=arguments,a}}function i(e){var t=Array.isArray(e[0])?e[0]:e;if(!t.every(function(e){return"function"==typeof e})){var n=t.map(function(e){return typeof e}).join(", ");throw new Error("Selector creators expect all input-selectors to be functions, instead received the following types: ["+n+"]")}return t}function u(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return function(){for(var t=arguments.length,r=Array(t),o=0;o<t;o++)r[o]=arguments[o];var u=0,c=r.pop(),l=i(r),s=e.apply(void 0,[function(){return u++,c.apply(null,arguments)}].concat(n)),f=a(function(){for(var e=[],t=l.length,n=0;n<t;n++)e.push(l[n].apply(null,arguments));return s.apply(null,e)});return f.resultFunc=c,f.recomputations=function(){return u},f.resetRecomputations=function(){return u=0},f}}function c(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:l;if("object"!=typeof e)throw new Error("createStructuredSelector expects first argument to be an object where each property is a selector, instead received a "+typeof e);var n=Object.keys(e);return t(n.map(function(t){return e[t]}),function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t.reduce(function(e,t,r){return e[n[r]]=t,e},{})})}t.__esModule=!0,t.defaultMemoize=a,t.createSelectorCreator=u,t.createStructuredSelector=c;var l=t.createSelector=u(a)},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.LocalizeProvider=void 0;var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(0),c=function(e){return e&&e.__esModule?e:{default:e}}(u);n(4);var l=n(1),s=n(2),f=n(3);t.LocalizeProvider=function(e){function t(e){r(this,t);var n=o(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e)),a=n.props.store?n.props.store.dispatch:n.dispatch.bind(n);return n.getContextPropsSelector=(0,s.getContextPropsFromState)(a),n.state={localize:(0,l.localizeReducer)(void 0,{})},n}return a(t,e),i(t,[{key:"componentDidMount",value:function(){this.props.store&&(this.unsubscribeFromStore=(0,f.storeDidChange)(this.props.store,this.onStateDidChange.bind(this)))}},{key:"componentWillUnmount",value:function(){this.unsubscribeFromStore&&this.unsubscribeFromStore()}},{key:"onStateDidChange",value:function(e){if(this.props.store){var t=e&&e.localize,n=this.props.store.getState().localize,r=e&&(0,l.getActiveLanguage)(t),o=(0,l.getActiveLanguage)(n),a=e&&(0,l.getOptions)(t),i=(0,l.getOptions)(n),u=e&&(0,l.getTranslationsForActiveLanguage)(t),c=(0,l.getTranslationsForActiveLanguage)(n),s=(r&&r.code)!==(o&&o.code),f=a!==i,d=u!==c;(s||f||d)&&this.setState({localize:n})}}},{key:"dispatch",value:function(e){this.setState(function(t){return{localize:(0,l.localizeReducer)(t.localize,e)}})}},{key:"render",value:function(){return this.contextProps=this.getContextPropsSelector(this.state.localize),c.default.createElement(s.LocalizeContext.Provider,{value:this.contextProps},this.props.children)}}],[{key:"getDerivedStateFromProps",value:function(e,t){return null}}]),t}(u.Component)},function(e,t,n){"use strict";function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),t.Translate=void 0;var u=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},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=n(0),s=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(l),f=n(11),d=(function(e){e&&e.__esModule}(f),n(1),n(3)),p=n(2),g=(n(6),function(e){function t(){return o(this,t),a(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return i(t,e),c(t,[{key:"componentDidMount",value:function(){this.addDefaultTranslation()}},{key:"componentDidUpdate",value:function(e){var t=this.props.id&&e.id!==this.props.id,n=!(0,d.get)(e,"context.defaultLanguage")&&!(0,d.get)(e,"options.language"),r=(0,d.get)(this.props,"context.defaultLanguage")||(0,d.get)(this.props,"options.language"),o=n&&r;(t||o)&&this.addDefaultTranslation()}},{key:"addDefaultTranslation",value:function(){var e=this.props,t=e.context,n=e.id,o=e.children,a=e.options,i=void 0===a?{}:a,u=i.language||t.defaultLanguage,c=function(e){return e},l=t.renderToStaticMarkup||c,s=void 0!==n,f=void 0!==u,d=void 0!==o,p="function"==typeof o,g=void 0!==i.ignoreTranslateChildren?i.ignoreTranslateChildren:t.ignoreTranslateChildren;if(d&&s&&f&&!p&&!g){var v=l(o);t.addTranslationForLanguage&&t.addTranslationForLanguage(r({},n,v),u)}}},{key:"renderChildren",value:function(){var e=this.props,t=e.context,n=e.id,r=void 0===n?"":n,o=e.options,a=e.data;return"function"==typeof this.props.children?this.props.children(t):t.translate&&t.translate(r,a,o)}},{key:"render",value:function(){return this.renderChildren()}}]),t}(s.Component));t.Translate=function(e){return s.createElement(p.LocalizeContext.Consumer,null,function(t){return s.createElement(g,u({},e,{context:t}))})}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(17);Object.defineProperty(t,"Translate",{enumerable:!0,get:function(){return r.Translate}});var o=n(6);Object.defineProperty(t,"withLocalize",{enumerable:!0,get:function(){return o.withLocalize}});var a=n(16);Object.defineProperty(t,"LocalizeProvider",{enumerable:!0,get:function(){return a.LocalizeProvider}});var i=n(2);Object.defineProperty(t,"LocalizeContext",{enumerable:!0,get:function(){return i.LocalizeContext}});var u=n(1);Object.defineProperty(t,"localizeReducer",{enumerable:!0,get:function(){return u.localizeReducer}}),Object.defineProperty(t,"initialize",{enumerable:!0,get:function(){return u.initialize}}),Object.defineProperty(t,"addTranslation",{enumerable:!0,get:function(){return u.addTranslation}}),Object.defineProperty(t,"addTranslationForLanguage",{enumerable:!0,get:function(){return u.addTranslationForLanguage}}),Object.defineProperty(t,"setActiveLanguage",{enumerable:!0,get:function(){return u.setActiveLanguage}}),Object.defineProperty(t,"getTranslate",{enumerable:!0,get:function(){return u.getTranslate}}),Object.defineProperty(t,"getActiveLanguage",{enumerable:!0,get:function(){return u.getActiveLanguage}}),Object.defineProperty(t,"getLanguages",{enumerable:!0,get:function(){return u.getLanguages}}),Object.defineProperty(t,"getTranslations",{enumerable:!0,get:function(){return u.getTranslations}}),Object.defineProperty(t,"getOptions",{enumerable:!0,get:function(){return u.getOptions}})},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function u(e,t){return e===t?0!==e||1/e==1/t:e!==e&&t!==t}function c(e){var t=[];return{on:function(e){t.push(e)},off:function(e){t=t.filter(function(t){return t!==e})},get:function(){return e},set:function(n,r){e=n,t.forEach(function(t){return t(e,r)})}}}function l(e){return Array.isArray(e)?e[0]:e}function s(e,t){var n,r,s="__create-react-context-"+(0,v.default)()+"__",d=function(e){function n(){var t,r,i;o(this,n);for(var u=arguments.length,l=Array(u),s=0;s<u;s++)l[s]=arguments[s];return t=r=a(this,e.call.apply(e,[this].concat(l))),r.emitter=c(r.props.value),i=t,a(r,i)}return i(n,e),n.prototype.getChildContext=function(){var e;return e={},e[s]=this.emitter,e},n.prototype.componentWillReceiveProps=function(e){if(this.props.value!==e.value){var n=this.props.value,r=e.value,o=void 0;u(n,r)?o=0:(o="function"==typeof t?t(n,r):h,0!==(o|=0)&&this.emitter.set(e.value,o))}},n.prototype.render=function(){return this.props.children},n}(f.Component);d.childContextTypes=(n={},n[s]=p.default.object.isRequired,n);var g=function(t){function n(){var e,r,i;o(this,n);for(var u=arguments.length,c=Array(u),l=0;l<u;l++)c[l]=arguments[l];return e=r=a(this,t.call.apply(t,[this].concat(c))),r.state={value:r.getValue()},r.onUpdate=function(e,t){0!=((0|r.observedBits)&t)&&r.setState({value:r.getValue()})},i=e,a(r,i)}return i(n,t),n.prototype.componentWillReceiveProps=function(e){var t=e.observedBits;this.observedBits=void 0===t||null===t?h:t},n.prototype.componentDidMount=function(){this.context[s]&&this.context[s].on(this.onUpdate);var e=this.props.observedBits;this.observedBits=void 0===e||null===e?h:e},n.prototype.componentWillUnmount=function(){this.context[s]&&this.context[s].off(this.onUpdate)},n.prototype.getValue=function(){return this.context[s]?this.context[s].get():e},n.prototype.render=function(){return l(this.props.children)(this.state.value)},n}(f.Component);return g.contextTypes=(r={},r[s]=p.default.object,r),{Provider:d,Consumer:g}}t.__esModule=!0;var f=n(0),d=(r(f),n(11)),p=r(d),g=n(23),v=r(g),y=n(22),h=(r(y),1073741823);t.default=s,e.exports=t.default},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var o=n(0),a=r(o),i=n(19),u=r(i);t.default=a.default.createContext||u.default,e.exports=t.default},function(e,t,n){"use strict";function r(e,t,n,r,a,i,u,c){if(o(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,r,a,i,u,c],f=0;l=new Error(t.replace(/%s/g,function(){return s[f++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var o=function(e){};e.exports=r},function(e,t,n){"use strict";var r=n(7),o=r;e.exports=o},function(e,t,n){"use strict";(function(t){var n="__global_unique_id__";e.exports=function(){return t[n]=(t[n]||0)+1}}).call(t,n(5))},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 @@ * |
@@ -8,3 +8,2 @@ import { | ||
import { Store } from 'redux'; | ||
import { ComponentClass, Component } from 'react'; | ||
@@ -36,3 +35,3 @@ export as namespace ReactLocalizeRedux; | ||
languageCode: string; | ||
defaultTranslation: string; | ||
defaultTranslation: LocalizedElement; | ||
}; | ||
@@ -39,0 +38,0 @@ |
@@ -20,2 +20,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
// This is to get around the whole default options issue with Flow | ||
// I tried using the $Diff approach, but with no luck so for now stuck with this terd. | ||
// Because sometimes you just want flow to shut up! | ||
/** | ||
@@ -115,2 +120,3 @@ * ACTIONS | ||
ignoreTranslateChildren: false, | ||
defaultLanguage: '', | ||
onMissingTranslation: function onMissingTranslation(_ref) { | ||
@@ -191,3 +197,14 @@ var translationId = _ref.translationId, | ||
export var getOptions = function getOptions(state) { | ||
return state.options; | ||
var options = Object.assign({}, state.options); | ||
var languages = void 0; | ||
// If there isn't a default language, grab the first languages from the | ||
// available languages as default | ||
if (!options.defaultLanguage) { | ||
languages = getLanguages(state) || []; | ||
options.defaultLanguage = languages[0] ? languages[0].code : ''; | ||
} | ||
return options; | ||
}; | ||
@@ -243,30 +260,42 @@ | ||
var defaultTranslations = activeLanguage && activeLanguage.code === initializeOptions.defaultLanguage ? translationsForActiveLanguage : initializeOptions.defaultLanguage !== undefined ? getTranslationsForLanguage(initializeOptions.defaultLanguage) : {}; | ||
var defaultTranslations = activeLanguage && activeLanguage.code === defaultLanguage ? translationsForActiveLanguage : getTranslationsForLanguage(defaultLanguage); | ||
var languageCode = overrideLanguage !== undefined ? overrideLanguage : activeLanguage && activeLanguage.code; | ||
var onMissingTranslation = function onMissingTranslation(translationId) { | ||
return mergedOptions.onMissingTranslation({ | ||
var mergedOptions = _extends({}, defaultOptions, translateOptions); | ||
var getTranslation = function getTranslation(translationId) { | ||
var hasValidTranslation = translations[translationId] !== undefined; | ||
var hasValidDefaultTranslation = defaultTranslations[translationId] !== undefined; | ||
var defaultTranslation = hasValidDefaultTranslation ? getLocalizedElement({ | ||
translation: defaultTranslations[translationId], | ||
data: data, | ||
renderInnerHtml: mergedOptions.renderInnerHtml | ||
}) : "No default translation found! Ensure you've added translations for your default langauge."; | ||
// if translation is not valid then generate the on missing translation message in it's place | ||
var translation = hasValidTranslation ? translations[translationId] : mergedOptions.onMissingTranslation({ | ||
translationId: translationId, | ||
languageCode: languageCode, | ||
defaultTranslation: defaultTranslations[translationId] | ||
defaultTranslation: defaultTranslation | ||
}); | ||
}; | ||
var mergedOptions = _extends({}, defaultOptions, translateOptions); | ||
var renderInnerHtml = mergedOptions.renderInnerHtml; | ||
// if translations are missing than ovrride data to include translationId, languageCode | ||
// as these will be needed to render missing translations message | ||
var translationData = hasValidTranslation ? data : { translationId: translationId, languageCode: languageCode }; | ||
var sharedParams = { | ||
translations: translations, | ||
data: data, | ||
languageCode: languageCode, | ||
renderInnerHtml: renderInnerHtml, | ||
onMissingTranslation: onMissingTranslation | ||
return getLocalizedElement({ | ||
translation: translation, | ||
data: translationData, | ||
languageCode: languageCode, | ||
renderInnerHtml: mergedOptions.renderInnerHtml | ||
}); | ||
}; | ||
if (typeof value === 'string') { | ||
return getLocalizedElement(_extends({ translationId: value }, sharedParams)); | ||
return getTranslation(value); | ||
} else if (Array.isArray(value)) { | ||
return value.reduce(function (prev, cur) { | ||
return _extends({}, prev, _defineProperty({}, cur, getLocalizedElement(_extends({ translationId: cur }, sharedParams)))); | ||
return _extends({}, prev, _defineProperty({}, cur, getTranslation(cur))); | ||
}, {}); | ||
@@ -273,0 +302,0 @@ } else { |
@@ -10,15 +10,9 @@ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
export var getLocalizedElement = function getLocalizedElement(options) { | ||
var translationId = options.translationId, | ||
translations = options.translations, | ||
var translation = options.translation, | ||
data = options.data, | ||
renderInnerHtml = options.renderInnerHtml, | ||
onMissingTranslation = options.onMissingTranslation; | ||
renderInnerHtml = options.renderInnerHtml; | ||
var localizedString = translations[translationId] || onMissingTranslation(translationId); | ||
var placeholderData = translations[translationId] ? data : { | ||
translationId: options.translationId, | ||
languageCode: options.languageCode | ||
}; | ||
var translatedValueOrArray = templater(localizedString, placeholderData); | ||
var translatedValueOrArray = templater(translation, data); | ||
// if result of templater is string, do the usual stuff | ||
@@ -134,3 +128,3 @@ if (typeof translatedValueOrArray === 'string') { | ||
if (options.renderToStaticMarkup !== false && typeof options.renderToStaticMarkup !== 'function') { | ||
throw new Error('\n react-localize-redux: initialize option renderToStaticMarkup is invalid. \n Please see https://ryandrewjohnson.github.io/react-localize-docs/#initialize.\n '); | ||
throw new Error('\n react-localize-redux: initialize option renderToStaticMarkup is invalid.\n Please see https://ryandrewjohnson.github.io/react-localize-docs/#initialize.\n '); | ||
} | ||
@@ -137,0 +131,0 @@ |
@@ -8,3 +8,2 @@ import { | ||
import { Store } from 'redux'; | ||
import { ComponentClass, Component } from 'react'; | ||
@@ -36,3 +35,3 @@ export as namespace ReactLocalizeRedux; | ||
languageCode: string; | ||
defaultTranslation: string; | ||
defaultTranslation: LocalizedElement; | ||
}; | ||
@@ -39,0 +38,0 @@ |
@@ -42,2 +42,7 @@ 'use strict'; | ||
*/ | ||
// This is to get around the whole default options issue with Flow | ||
// I tried using the $Diff approach, but with no luck so for now stuck with this terd. | ||
// Because sometimes you just want flow to shut up! | ||
var INITIALIZE = exports.INITIALIZE = '@@localize/INITIALIZE'; | ||
@@ -134,2 +139,3 @@ var ADD_TRANSLATION = exports.ADD_TRANSLATION = '@@localize/ADD_TRANSLATION'; | ||
ignoreTranslateChildren: false, | ||
defaultLanguage: '', | ||
onMissingTranslation: function onMissingTranslation(_ref) { | ||
@@ -210,3 +216,14 @@ var translationId = _ref.translationId, | ||
var getOptions = exports.getOptions = function getOptions(state) { | ||
return state.options; | ||
var options = Object.assign({}, state.options); | ||
var languages = void 0; | ||
// If there isn't a default language, grab the first languages from the | ||
// available languages as default | ||
if (!options.defaultLanguage) { | ||
languages = getLanguages(state) || []; | ||
options.defaultLanguage = languages[0] ? languages[0].code : ''; | ||
} | ||
return options; | ||
}; | ||
@@ -262,30 +279,42 @@ | ||
var defaultTranslations = activeLanguage && activeLanguage.code === initializeOptions.defaultLanguage ? translationsForActiveLanguage : initializeOptions.defaultLanguage !== undefined ? getTranslationsForLanguage(initializeOptions.defaultLanguage) : {}; | ||
var defaultTranslations = activeLanguage && activeLanguage.code === defaultLanguage ? translationsForActiveLanguage : getTranslationsForLanguage(defaultLanguage); | ||
var languageCode = overrideLanguage !== undefined ? overrideLanguage : activeLanguage && activeLanguage.code; | ||
var onMissingTranslation = function onMissingTranslation(translationId) { | ||
return mergedOptions.onMissingTranslation({ | ||
var mergedOptions = _extends({}, defaultOptions, translateOptions); | ||
var getTranslation = function getTranslation(translationId) { | ||
var hasValidTranslation = translations[translationId] !== undefined; | ||
var hasValidDefaultTranslation = defaultTranslations[translationId] !== undefined; | ||
var defaultTranslation = hasValidDefaultTranslation ? (0, _utils.getLocalizedElement)({ | ||
translation: defaultTranslations[translationId], | ||
data: data, | ||
renderInnerHtml: mergedOptions.renderInnerHtml | ||
}) : "No default translation found! Ensure you've added translations for your default langauge."; | ||
// if translation is not valid then generate the on missing translation message in it's place | ||
var translation = hasValidTranslation ? translations[translationId] : mergedOptions.onMissingTranslation({ | ||
translationId: translationId, | ||
languageCode: languageCode, | ||
defaultTranslation: defaultTranslations[translationId] | ||
defaultTranslation: defaultTranslation | ||
}); | ||
}; | ||
var mergedOptions = _extends({}, defaultOptions, translateOptions); | ||
var renderInnerHtml = mergedOptions.renderInnerHtml; | ||
// if translations are missing than ovrride data to include translationId, languageCode | ||
// as these will be needed to render missing translations message | ||
var translationData = hasValidTranslation ? data : { translationId: translationId, languageCode: languageCode }; | ||
var sharedParams = { | ||
translations: translations, | ||
data: data, | ||
languageCode: languageCode, | ||
renderInnerHtml: renderInnerHtml, | ||
onMissingTranslation: onMissingTranslation | ||
return (0, _utils.getLocalizedElement)({ | ||
translation: translation, | ||
data: translationData, | ||
languageCode: languageCode, | ||
renderInnerHtml: mergedOptions.renderInnerHtml | ||
}); | ||
}; | ||
if (typeof value === 'string') { | ||
return (0, _utils.getLocalizedElement)(_extends({ translationId: value }, sharedParams)); | ||
return getTranslation(value); | ||
} else if (Array.isArray(value)) { | ||
return value.reduce(function (prev, cur) { | ||
return _extends({}, prev, _defineProperty({}, cur, (0, _utils.getLocalizedElement)(_extends({ translationId: cur }, sharedParams)))); | ||
return _extends({}, prev, _defineProperty({}, cur, getTranslation(cur))); | ||
}, {}); | ||
@@ -292,0 +321,0 @@ } else { |
@@ -23,15 +23,9 @@ 'use strict'; | ||
var getLocalizedElement = exports.getLocalizedElement = function getLocalizedElement(options) { | ||
var translationId = options.translationId, | ||
translations = options.translations, | ||
var translation = options.translation, | ||
data = options.data, | ||
renderInnerHtml = options.renderInnerHtml, | ||
onMissingTranslation = options.onMissingTranslation; | ||
renderInnerHtml = options.renderInnerHtml; | ||
var localizedString = translations[translationId] || onMissingTranslation(translationId); | ||
var placeholderData = translations[translationId] ? data : { | ||
translationId: options.translationId, | ||
languageCode: options.languageCode | ||
}; | ||
var translatedValueOrArray = templater(localizedString, placeholderData); | ||
var translatedValueOrArray = templater(translation, data); | ||
// if result of templater is string, do the usual stuff | ||
@@ -147,3 +141,3 @@ if (typeof translatedValueOrArray === 'string') { | ||
if (options.renderToStaticMarkup !== false && typeof options.renderToStaticMarkup !== 'function') { | ||
throw new Error('\n react-localize-redux: initialize option renderToStaticMarkup is invalid. \n Please see https://ryandrewjohnson.github.io/react-localize-docs/#initialize.\n '); | ||
throw new Error('\n react-localize-redux: initialize option renderToStaticMarkup is invalid.\n Please see https://ryandrewjohnson.github.io/react-localize-docs/#initialize.\n '); | ||
} | ||
@@ -150,0 +144,0 @@ |
{ | ||
"name": "react-localize-redux", | ||
"version": "3.2.2", | ||
"version": "3.2.3", | ||
"description": "Localization library for handling translations in React", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is too big to display
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
498339
4887