gt-react 9.0.10-alpha.0 → 9.0.10-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.cjs.min.cjs +3 -3
- package/dist/client.esm.min.mjs +3 -3
- package/dist/hooks/useDetermineLocale.d.ts.map +1 -1
- package/dist/index.cjs.min.cjs +3 -3
- package/dist/index.esm.min.mjs +3 -3
- package/dist/internal.cjs.min.cjs +1 -1
- package/dist/internal.esm.min.mjs +1 -1
- package/dist/messages/createMessages.d.ts +4 -2
- package/dist/messages/createMessages.d.ts.map +1 -1
- package/dist/provider/ClientProvider.d.ts.map +1 -1
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
import e,{isValidElement as r}from"react";import{jsx as n}from"react/jsx-runtime";const t=e=>`Duplicate key found in dictionary: "${e}"`;function a(r,n=""){const i={};for(const o in r)if(r.hasOwnProperty(o)){const l=n?`${n}.${o}`:o;if("object"!=typeof r[o]||null===r[o]||Array.isArray(r[o])||e.isValidElement(r[o])){if(i.hasOwnProperty(l))throw new Error(t(l));i[l]=r[o]}else{const e=a(r[o],l);for(const r in e){if(i.hasOwnProperty(r))throw new Error(t(r));i[r]=e[r]}}}return i}function i(e,r){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)r.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(n[t[a]]=e[t[a]])}return n}"function"==typeof SuppressedError&&SuppressedError;var o="en-US",l=["singular","plural","dual","zero","one","two","few","many","other"];const s=e=>`gt-react: No dictionary entry found for id: "${e}"`;function c(t,a=0){let o=a;const s=e=>{const{type:r,props:n}=e;o+=1;let t,a={id:o};try{t="function"==typeof r&&r.gtTransformation||""}catch(e){t=""}if(t){const r=t.split("-");if("translate"===r[0])throw new Error((e=>{var r;return`General Translation: Nested <T> components. The inner <T> has the id: "${null===(r=null==e?void 0:e.props)||void 0===r?void 0:r.id}".`})(e));if("variable"===r[0]&&(a.variableType=(null==r?void 0:r[1])||"variable"),"plural"===r[0]){const e=Object.entries(n).reduce(((e,[r,n])=>{var t;return t=r,l.includes(t)&&(e[r]=c(n,o)),e}),{});Object.keys(e).length&&(a.branches=e)}if("branch"===r[0]){const e=i(n,["children","branch"]),r=Object.entries(e).reduce(((e,[r,n])=>(e[r]=c(n,o),e)),{});Object.keys(r).length&&(a.branches=r)}a.transformation=r[0]}return a};function u(t){return r(t)?function(r){const{props:t}=r;if(t["data-_gt"])throw new Error((e=>`General Translation already in use on child with props: ${e.props}. This usually occurs when you nest <T> components within the same file. Remove one of the <T> components to continue.`)(r));let a=s(r),i=Object.assign(Object.assign({},t),{"data-_gt":a});if(t.children&&!a.variableType&&(i.children=d(t.children)),r.type===e.Fragment)return n("span",Object.assign({style:{all:"unset",display:"contents"}},i));return e.cloneElement(r,i)}(t):t}function d(r){return Array.isArray(r)?e.Children.map(r,u):u(r)}return d(t)}const u={variable:"value",number:"n",datetime:"date",currency:"cost"};function d(e="variable"){return u[e]||"variable"}const p="_gt_";function b(e={},r){var n;if(e.name)return e.name;if(e["data-_gt-variable-name"])return e["data-_gt-variable-name"];return`${p}${u[r]||"value"}_${null===(n=e["data-_gt"])||void 0===n?void 0:n.id}`}function f(r){if(e.isValidElement(r)&&r.type===e.Fragment){const n=r.props;return!n.children||0===e.Children.count(n.children)}return!1}const v=e=>{var r;if(!e)return"";const{type:n,props:t}=e;if(n&&"function"==typeof n){if("displayName"in n&&"string"==typeof n.displayName&&n.displayName)return n.displayName;if("name"in n&&"string"==typeof n.name&&n.name)return n.name}return n&&"string"==typeof n?n:t.href?"a":(null===(r=t["data-_gt"])||void 0===r?void 0:r.id)?`C${t["data-_gt"].id}`:"function"},y=r=>{return n=r,e.isValidElement(n)?(e=>{const{type:r,props:n}=e;let t={type:v(e),props:{}};if(n["data-_gt"]){const e=n["data-_gt"];let r=Object.assign({},e);const a=e.transformation;if("variable"===a){const r=e.variableType||"variable";return{variable:r,key:b(n,r),id:e.id}}if("plural"===a&&e.branches){t.type="Plural";let n={};Object.entries(e.branches).forEach((([e,r])=>{n[e]=h(r)})),r=Object.assign(Object.assign({},r),{branches:n})}if("branch"===a&&e.branches){t.type="Branch";let n={};Object.entries(e.branches).forEach((([e,r])=>{n[e]=h(r)})),r=Object.assign(Object.assign({},r),{branches:n})}t.props["data-_gt"]=r}return n.children&&(t.props.children=h(n.children)),t})(r):"number"==typeof r?r.toString():r;var n};function h(e){return Array.isArray(e)?e.map(y):y(e)}function g(e,r,n){let t="",a=null;return"number"==typeof e&&!a&&n&&(t=function(e,r,n){void 0===r&&(r=l),void 0===n&&(n=[o]);var t=new Intl.PluralRules(n).select(e),a=Math.abs(e);if(0===a&&r.includes("zero"))return"zero";if(1===a){if(r.includes("singular"))return"singular";if(r.includes("one"))return"one"}if("one"===t&&r.includes("singular"))return"singular";if(2===a){if(r.includes("dual"))return"dual";if(r.includes("two"))return"two"}return"two"===t&&r.includes("dual")?"dual":r.includes(t)?t:"two"===t&&r.includes("dual")?"dual":"two"===t&&r.includes("plural")?"plural":"two"===t&&r.includes("other")?"other":"few"===t&&r.includes("plural")?"plural":"few"===t&&r.includes("other")?"other":"many"===t&&r.includes("plural")?"plural":"many"===t&&r.includes("other")?"other":"other"===t&&r.includes("plural")?"plural":""}(e,Object.keys(n),r)),t&&!a&&(a=n[t]),a}function m(r,n){let t=r,a=n.split(".");for(const r of a){if("object"!=typeof t||Array.isArray(t)||e.isValidElement(t))return void console.error(s(n));t=t[r]}return t}function O(e){if(Array.isArray(e)){if(1===e.length)return{entry:e[0]};if(2===e.length)return{entry:e[0],metadata:e[1]}}return{entry:e}}function j(e){var r;const n=(null===(r=e["data-_gt"])||void 0===r?void 0:r.variableType)||"variable";return{variableType:n,variableName:b(e,n),variableValue:void 0!==e.value?e.value:void 0!==e["data-_gt-unformatted-value"]?e["data-_gt-unformatted-value"]:void 0!==e.children?e.children:void 0,variableOptions:(()=>{const r=Object.assign(Object.assign({},e.currency&&{currency:e.currency}),e.options&&Object.assign({},e.options));return Object.keys(r).length?r:"string"==typeof e["data-_gt-variable-options"]?JSON.parse(e["data-_gt-variable-options"]):e["data-_gt-variable-options"]||void 0})()}}function _(e){const r=e;if(r&&"object"==typeof r&&"string"==typeof r.key){const e=Object.keys(r);if(1===e.length)return!0;if(2===e.length){if("number"==typeof r.id)return!0;if("string"==typeof r.variable)return!0}if(3===e.length&&"string"==typeof r.variable&&"number"==typeof r.id)return!0}return!1}function E(e){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function w({children:r,variables:n={},variablesOptions:t={},defaultLocale:a=o,renderVariable:l}){const s=r=>e.isValidElement(r)?(r=>{const o=E(r);if("variable"===(null==o?void 0:o.transformation)){let{variableName:e,variableType:i,variableValue:o,variableOptions:s}=j(r.props);return o=(()=>{if(void 0!==n[e])return n[e];if(void 0!==o)return o;if(e.startsWith(p)){const e=d(i);if(void 0!==n[e])return n[e]}})(),s=Object.assign(Object.assign({},t[e]),s),l({variableName:e,variableType:i,variableValue:o,variableOptions:s,locales:[a]})}if("plural"===(null==o?void 0:o.transformation)){const e="number"==typeof n.n?n.n:"number"==typeof r.props.n?r.props.n:r.props["data-_gt-n"];"number"==typeof e&&void 0===n.n&&(n.n=e);const t=o.branches||{};return c(g(e,[a],t)||r.props.children)}if("branch"===(null==o?void 0:o.transformation)){let e=r.props,{children:t,name:a,branch:l,"data-_gt":s}=e,u=i(e,["children","name","branch","data-_gt"]);return a=a||r.props["data-_gt-name"]||"branch",l=n[a]||l||r.props["data-_gt-branch-name"],u=o.branches||{},c(void 0!==u[l]?u[l]:t)}return r.props.children?e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0,children:c(r.props.children)})):e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0}))})(r):r,c=r=>Array.isArray(r)?e.Children.map(r,s):s(r);return c(r)}function V({sourceElement:r,targetElement:n,variables:t={},variablesOptions:a={},locales:i=[o],renderVariable:l}){var s;const{props:c}=r,u=c["data-_gt"],d=null==u?void 0:u.transformation;if("plural"===d){const e="number"==typeof t.n?t.n:"number"==typeof r.props.n?r.props.n:r.props["data-_gt-n"],o=g(e,i,u.branches||{})||r.props.children,s=g(e,i,n.props["data-_gt"].branches||{})||n.props.children;return"number"==typeof e&&void 0===t.n&&(t.n=e),A({source:o,target:s,variables:t,variablesOptions:a,locales:i,renderVariable:l})}if("branch"===d){let{name:e,branch:o,children:s}=c;e=e||r.props["data-_gt-name"]||"branch",o=t[e]||o||r.props["data-_gt-branch-name"];return A({source:(u.branches||{})[o]||s,target:(n.props["data-_gt"].branches||{})[o]||n.props.children,variables:t,variablesOptions:a,locales:i,renderVariable:l})}return(null==c?void 0:c.children)&&(null===(s=n.props)||void 0===s?void 0:s.children)?e.cloneElement(r,Object.assign(Object.assign({},c),{"data-_gt":void 0,children:A({source:c.children,target:n.props.children,variables:t,variablesOptions:a,locales:i,renderVariable:l})})):w({children:r,variables:t,variablesOptions:a,defaultLocale:i[0],renderVariable:l})}function A({source:r,target:t,variables:a={},variablesOptions:i={},locales:l=[o],renderVariable:s}){if(null==t&&r)return w({children:r,variables:a,variablesOptions:i,defaultLocale:l[0],renderVariable:s});if("string"==typeof t)return t;if(Array.isArray(t)&&!Array.isArray(r)&&r&&(r=[r]),Array.isArray(r)&&Array.isArray(t)){const o=r.filter((r=>{if(e.isValidElement(r)){const e=E(r);if(j(r.props),"variable"!==(null==e?void 0:e.transformation))return!0;{let{variableName:e,variableValue:n,variableOptions:t,variableType:o}=j(r.props);void 0===a[e]&&(a[e]=n);const l=d(o);void 0===a[l]&&(a[l]=n),i[e]=Object.assign(Object.assign({},i[e]),t)}}})),c=e=>o.find((r=>{var n,t;const a=E(r);if(void 0!==(null==a?void 0:a.id)){return a.id===(null===(t=null===(n=null==e?void 0:e.props)||void 0===n?void 0:n["data-_gt"])||void 0===t?void 0:t.id)}return!1}));return t.map(((r,t)=>{if("string"==typeof r)return n(e.Fragment,{children:r},`string_${t}`);if(_(r)){const o=r.key,c=r.variable||"variable",u=(()=>{if(void 0!==a[r.key])return a[r.key];if(o.startsWith(p)){const e=d(c);if(void 0!==a[e])return a[e]}})();return n(e.Fragment,{children:s({variableType:c,variableName:o,variableValue:u,variableOptions:i[r.key],locales:l})},`var_${t}`)}const o=c(r);return o?n(e.Fragment,{children:V({sourceElement:o,targetElement:r,variables:a,variablesOptions:i,locales:l,renderVariable:s})},`element_${t}`):void 0}))}if(t&&"object"==typeof t&&!Array.isArray(t)){const n=_(t)?"variable":"element";if(e.isValidElement(r)){if("element"===n)return V({sourceElement:r,targetElement:t,variables:a,variablesOptions:i,locales:l,renderVariable:s});const e=E(r);if("variable"===(null==e?void 0:e.transformation)){let{variableName:e,variableValue:n,variableOptions:t}=j(r.props);void 0===a[e]&&(a[e]=n),i[e]=Object.assign(Object.assign({},i[e]),t)}}if("variable"===n){const e=t,r=e.key,n=e.variable||"variable",o=(()=>{if(void 0!==a[e.key])return a[e.key];if(r.startsWith(p)){const e=d(n);if(void 0!==a[e])return a[e]}})();return s({variableType:n,variableName:r,variableValue:o,variableOptions:i[e.key]||{},locales:l})}}return w({children:r,variables:a,variablesOptions:i,defaultLocale:l[0],renderVariable:s})}const T=Object.assign({method:"default"},"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?{timeout:8e3}:{});function k(){return""}class N extends Error{constructor(e,r){super(e),this.error=e,this.code=r,this.code=r}toTranslationError(){return{state:"error",error:this.error,code:this.code}}}export{N as GTTranslationError,c as addGTIdentifier,T as defaultRenderSettings,O as extractEntryMetadata,a as flattenDictionary,m as getDictionaryEntry,d as getFallbackVariableName,g as getPluralBranch,b as getVariableName,j as getVariableProps,f as isEmptyReactFragment,_ as isVariableObject,w as renderDefaultChildren,k as renderSkeleton,A as renderTranslatedChildren,h as writeChildrenAsObjects};
|
1
|
+
import e,{isValidElement as r}from"react";import{jsx as n}from"react/jsx-runtime";import"generaltranslation";const t=e=>`Duplicate key found in dictionary: "${e}"`;function a(r,n=""){const i={};for(const o in r)if(r.hasOwnProperty(o)){const l=n?`${n}.${o}`:o;if("object"!=typeof r[o]||null===r[o]||Array.isArray(r[o])||e.isValidElement(r[o])){if(i.hasOwnProperty(l))throw new Error(t(l));i[l]=r[o]}else{const e=a(r[o],l);for(const r in e){if(i.hasOwnProperty(r))throw new Error(t(r));i[r]=e[r]}}}return i}function i(e,r){var n={};for(var t in e)Object.prototype.hasOwnProperty.call(e,t)&&r.indexOf(t)<0&&(n[t]=e[t]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(t=Object.getOwnPropertySymbols(e);a<t.length;a++)r.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(e,t[a])&&(n[t[a]]=e[t[a]])}return n}"function"==typeof SuppressedError&&SuppressedError;var o="en-US",l=["singular","plural","dual","zero","one","two","few","many","other"];const s=e=>`gt-react: No dictionary entry found for id: "${e}"`;function c(t,a=0){let o=a;const s=e=>{const{type:r,props:n}=e;o+=1;let t,a={id:o};try{t="function"==typeof r&&r.gtTransformation||""}catch(e){t=""}if(t){const r=t.split("-");if("translate"===r[0])throw new Error((e=>{var r;return`General Translation: Nested <T> components. The inner <T> has the id: "${null===(r=null==e?void 0:e.props)||void 0===r?void 0:r.id}".`})(e));if("variable"===r[0]&&(a.variableType=(null==r?void 0:r[1])||"variable"),"plural"===r[0]){const e=Object.entries(n).reduce(((e,[r,n])=>{var t;return t=r,l.includes(t)&&(e[r]=c(n,o)),e}),{});Object.keys(e).length&&(a.branches=e)}if("branch"===r[0]){const e=i(n,["children","branch"]),r=Object.entries(e).reduce(((e,[r,n])=>(e[r]=c(n,o),e)),{});Object.keys(r).length&&(a.branches=r)}a.transformation=r[0]}return a};function u(t){return r(t)?function(r){const{props:t}=r;if(t["data-_gt"])throw new Error((e=>`General Translation already in use on child with props: ${e.props}. This usually occurs when you nest <T> components within the same file. Remove one of the <T> components to continue.`)(r));let a=s(r),i=Object.assign(Object.assign({},t),{"data-_gt":a});if(t.children&&!a.variableType&&(i.children=d(t.children)),r.type===e.Fragment)return n("span",Object.assign({style:{all:"unset",display:"contents"}},i));return e.cloneElement(r,i)}(t):t}function d(r){return Array.isArray(r)?e.Children.map(r,u):u(r)}return d(t)}const u={variable:"value",number:"n",datetime:"date",currency:"cost"};function d(e="variable"){return u[e]||"variable"}const p="_gt_";function b(e={},r){var n;if(e.name)return e.name;if(e["data-_gt-variable-name"])return e["data-_gt-variable-name"];return`${p}${u[r]||"value"}_${null===(n=e["data-_gt"])||void 0===n?void 0:n.id}`}function f(r){if(e.isValidElement(r)&&r.type===e.Fragment){const n=r.props;return!n.children||0===e.Children.count(n.children)}return!1}const v=e=>{var r;if(!e)return"";const{type:n,props:t}=e;if(n&&"function"==typeof n){if("displayName"in n&&"string"==typeof n.displayName&&n.displayName)return n.displayName;if("name"in n&&"string"==typeof n.name&&n.name)return n.name}return n&&"string"==typeof n?n:t.href?"a":(null===(r=t["data-_gt"])||void 0===r?void 0:r.id)?`C${t["data-_gt"].id}`:"function"},y=r=>{return n=r,e.isValidElement(n)?(e=>{const{type:r,props:n}=e;let t={type:v(e),props:{}};if(n["data-_gt"]){const e=n["data-_gt"];let r=Object.assign({},e);const a=e.transformation;if("variable"===a){const r=e.variableType||"variable";return{variable:r,key:b(n,r),id:e.id}}if("plural"===a&&e.branches){t.type="Plural";let n={};Object.entries(e.branches).forEach((([e,r])=>{n[e]=h(r)})),r=Object.assign(Object.assign({},r),{branches:n})}if("branch"===a&&e.branches){t.type="Branch";let n={};Object.entries(e.branches).forEach((([e,r])=>{n[e]=h(r)})),r=Object.assign(Object.assign({},r),{branches:n})}t.props["data-_gt"]=r}return n.children&&(t.props.children=h(n.children)),t})(r):"number"==typeof r?r.toString():r;var n};function h(e){return Array.isArray(e)?e.map(y):y(e)}function g(e,r,n){let t="",a=null;return"number"==typeof e&&!a&&n&&(t=function(e,r,n){void 0===r&&(r=l),void 0===n&&(n=[o]);var t=new Intl.PluralRules(n).select(e),a=Math.abs(e);if(0===a&&r.includes("zero"))return"zero";if(1===a){if(r.includes("singular"))return"singular";if(r.includes("one"))return"one"}if("one"===t&&r.includes("singular"))return"singular";if(2===a){if(r.includes("dual"))return"dual";if(r.includes("two"))return"two"}return"two"===t&&r.includes("dual")?"dual":r.includes(t)?t:"two"===t&&r.includes("dual")?"dual":"two"===t&&r.includes("plural")?"plural":"two"===t&&r.includes("other")?"other":"few"===t&&r.includes("plural")?"plural":"few"===t&&r.includes("other")?"other":"many"===t&&r.includes("plural")?"plural":"many"===t&&r.includes("other")?"other":"other"===t&&r.includes("plural")?"plural":""}(e,Object.keys(n),r)),t&&!a&&(a=n[t]),a}function m(r,n){let t=r,a=n.split(".");for(const r of a){if("object"!=typeof t||Array.isArray(t)||e.isValidElement(t))return void console.error(s(n));t=t[r]}return t}function O(e){if(Array.isArray(e)){if(1===e.length)return{entry:e[0]};if(2===e.length)return{entry:e[0],metadata:e[1]}}return{entry:e}}function j(e){var r;const n=(null===(r=e["data-_gt"])||void 0===r?void 0:r.variableType)||"variable";return{variableType:n,variableName:b(e,n),variableValue:void 0!==e.value?e.value:void 0!==e["data-_gt-unformatted-value"]?e["data-_gt-unformatted-value"]:void 0!==e.children?e.children:void 0,variableOptions:(()=>{const r=Object.assign(Object.assign({},e.currency&&{currency:e.currency}),e.options&&Object.assign({},e.options));return Object.keys(r).length?r:"string"==typeof e["data-_gt-variable-options"]?JSON.parse(e["data-_gt-variable-options"]):e["data-_gt-variable-options"]||void 0})()}}function _(e){const r=e;if(r&&"object"==typeof r&&"string"==typeof r.key){const e=Object.keys(r);if(1===e.length)return!0;if(2===e.length){if("number"==typeof r.id)return!0;if("string"==typeof r.variable)return!0}if(3===e.length&&"string"==typeof r.variable&&"number"==typeof r.id)return!0}return!1}function E(e){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function w({children:r,variables:n={},variablesOptions:t={},defaultLocale:a=o,renderVariable:l}){const s=r=>e.isValidElement(r)?(r=>{const o=E(r);if("variable"===(null==o?void 0:o.transformation)){let{variableName:e,variableType:i,variableValue:o,variableOptions:s}=j(r.props);return o=(()=>{if(void 0!==n[e])return n[e];if(void 0!==o)return o;if(e.startsWith(p)){const e=d(i);if(void 0!==n[e])return n[e]}})(),s=Object.assign(Object.assign({},t[e]),s),l({variableName:e,variableType:i,variableValue:o,variableOptions:s,locales:[a]})}if("plural"===(null==o?void 0:o.transformation)){const e="number"==typeof n.n?n.n:"number"==typeof r.props.n?r.props.n:r.props["data-_gt-n"];"number"==typeof e&&void 0===n.n&&(n.n=e);const t=o.branches||{};return c(g(e,[a],t)||r.props.children)}if("branch"===(null==o?void 0:o.transformation)){let e=r.props,{children:t,name:a,branch:l,"data-_gt":s}=e,u=i(e,["children","name","branch","data-_gt"]);return a=a||r.props["data-_gt-name"]||"branch",l=n[a]||l||r.props["data-_gt-branch-name"],u=o.branches||{},c(void 0!==u[l]?u[l]:t)}return r.props.children?e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0,children:c(r.props.children)})):e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0}))})(r):r,c=r=>Array.isArray(r)?e.Children.map(r,s):s(r);return c(r)}function V({sourceElement:r,targetElement:n,variables:t={},variablesOptions:a={},locales:i=[o],renderVariable:l}){var s;const{props:c}=r,u=c["data-_gt"],d=null==u?void 0:u.transformation;if("plural"===d){const e="number"==typeof t.n?t.n:"number"==typeof r.props.n?r.props.n:r.props["data-_gt-n"],o=g(e,i,u.branches||{})||r.props.children,s=g(e,i,n.props["data-_gt"].branches||{})||n.props.children;return"number"==typeof e&&void 0===t.n&&(t.n=e),A({source:o,target:s,variables:t,variablesOptions:a,locales:i,renderVariable:l})}if("branch"===d){let{name:e,branch:o,children:s}=c;e=e||r.props["data-_gt-name"]||"branch",o=t[e]||o||r.props["data-_gt-branch-name"];return A({source:(u.branches||{})[o]||s,target:(n.props["data-_gt"].branches||{})[o]||n.props.children,variables:t,variablesOptions:a,locales:i,renderVariable:l})}return(null==c?void 0:c.children)&&(null===(s=n.props)||void 0===s?void 0:s.children)?e.cloneElement(r,Object.assign(Object.assign({},c),{"data-_gt":void 0,children:A({source:c.children,target:n.props.children,variables:t,variablesOptions:a,locales:i,renderVariable:l})})):w({children:r,variables:t,variablesOptions:a,defaultLocale:i[0],renderVariable:l})}function A({source:r,target:t,variables:a={},variablesOptions:i={},locales:l=[o],renderVariable:s}){if(null==t&&r)return w({children:r,variables:a,variablesOptions:i,defaultLocale:l[0],renderVariable:s});if("string"==typeof t)return t;if(Array.isArray(t)&&!Array.isArray(r)&&r&&(r=[r]),Array.isArray(r)&&Array.isArray(t)){const o=r.filter((r=>{if(e.isValidElement(r)){const e=E(r);if(j(r.props),"variable"!==(null==e?void 0:e.transformation))return!0;{let{variableName:e,variableValue:n,variableOptions:t,variableType:o}=j(r.props);void 0===a[e]&&(a[e]=n);const l=d(o);void 0===a[l]&&(a[l]=n),i[e]=Object.assign(Object.assign({},i[e]),t)}}})),c=e=>o.find((r=>{var n,t;const a=E(r);if(void 0!==(null==a?void 0:a.id)){return a.id===(null===(t=null===(n=null==e?void 0:e.props)||void 0===n?void 0:n["data-_gt"])||void 0===t?void 0:t.id)}return!1}));return t.map(((r,t)=>{if("string"==typeof r)return n(e.Fragment,{children:r},`string_${t}`);if(_(r)){const o=r.key,c=r.variable||"variable",u=(()=>{if(void 0!==a[r.key])return a[r.key];if(o.startsWith(p)){const e=d(c);if(void 0!==a[e])return a[e]}})();return n(e.Fragment,{children:s({variableType:c,variableName:o,variableValue:u,variableOptions:i[r.key],locales:l})},`var_${t}`)}const o=c(r);return o?n(e.Fragment,{children:V({sourceElement:o,targetElement:r,variables:a,variablesOptions:i,locales:l,renderVariable:s})},`element_${t}`):void 0}))}if(t&&"object"==typeof t&&!Array.isArray(t)){const n=_(t)?"variable":"element";if(e.isValidElement(r)){if("element"===n)return V({sourceElement:r,targetElement:t,variables:a,variablesOptions:i,locales:l,renderVariable:s});const e=E(r);if("variable"===(null==e?void 0:e.transformation)){let{variableName:e,variableValue:n,variableOptions:t}=j(r.props);void 0===a[e]&&(a[e]=n),i[e]=Object.assign(Object.assign({},i[e]),t)}}if("variable"===n){const e=t,r=e.key,n=e.variable||"variable",o=(()=>{if(void 0!==a[e.key])return a[e.key];if(r.startsWith(p)){const e=d(n);if(void 0!==a[e])return a[e]}})();return s({variableType:n,variableName:r,variableValue:o,variableOptions:i[e.key]||{},locales:l})}}return w({children:r,variables:a,variablesOptions:i,defaultLocale:l[0],renderVariable:s})}const T=Object.assign({method:"default"},"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?{timeout:8e3}:{});function k(){return""}class N extends Error{constructor(e,r){super(e),this.error=e,this.code=r,this.code=r}toTranslationError(){return{state:"error",error:this.error,code:this.code}}}export{N as GTTranslationError,c as addGTIdentifier,T as defaultRenderSettings,O as extractEntryMetadata,a as flattenDictionary,m as getDictionaryEntry,d as getFallbackVariableName,g as getPluralBranch,b as getVariableName,j as getVariableProps,f as isEmptyReactFragment,_ as isVariableObject,w as renderDefaultChildren,k as renderSkeleton,A as renderTranslatedChildren,h as writeChildrenAsObjects};
|
@@ -10,10 +10,12 @@ export declare const createNestedTError: (child: any) => string;
|
|
10
10
|
export declare const renderingError = "General Translation: Rendering error.";
|
11
11
|
export declare const dynamicTranslationError = "Error fetching batched translations:";
|
12
12
|
export declare const createGenericRuntimeTranslationError: (id: string | undefined, hash: string) => string;
|
13
|
-
export declare const dictionaryDisabledError
|
14
|
-
export declare const projectIdMissingWarning = "gt-react warn:
|
13
|
+
export declare const dictionaryDisabledError: string;
|
14
|
+
export declare const projectIdMissingWarning = "gt-react warn: Translation cloud services require a project ID! Find yours at generaltranslation.com/dashboard.";
|
15
15
|
export declare const createLibraryNoEntryWarning: (id: string) => string;
|
16
16
|
export declare const createNoEntryWarning: (id: string, prefixedId: string) => string;
|
17
17
|
export declare const createInvalidElementEntryWarning: (id: string, prefixedId: string) => string;
|
18
18
|
export declare const createMismatchingHashWarning: (expectedHash: string, receivedHash: string) => string;
|
19
|
+
export declare const APIKeyMissingWarn: string;
|
20
|
+
export declare const createUnsupportedLocalesWarning: (locales: string[]) => string;
|
19
21
|
//# sourceMappingURL=createMessages.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"createMessages.d.ts","sourceRoot":"","sources":["../../src/messages/createMessages.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"createMessages.d.ts","sourceRoot":"","sources":["../../src/messages/createMessages.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAqB,6HAC0F,CAAC;AAE7H,eAAO,MAAM,wBAAwB,kFAC4C,CAAC;AAElF,eAAO,MAAM,iBAAiB,kKACmI,CAAC;AAElK,eAAO,MAAM,wBAAwB,aAAc,GAAG,WACiB,CAAC;AAExE,eAAO,MAAM,4BAA4B,YAAa,MAAM,OAAO,MAAM,WAG7D,CAAC;AAEb,eAAO,MAAM,yCAAyC,OAAQ,MAAM,WAC6D,CAAC;AAElI,eAAO,MAAM,+BAA+B,OAAQ,MAAM,WAEmE,CAAC;AAE9H,eAAO,MAAM,uBAAuB,UAAW,GAAG,WAC8I,CAAC;AAEjM,eAAO,MAAM,kBAAkB,UAAW,GAAG,WACmD,CAAC;AAEjG,eAAO,MAAM,cAAc,0CAA0C,CAAC;AAEtE,eAAO,MAAM,uBAAuB,yCAAyC,CAAC;AAE9E,eAAO,MAAM,oCAAoC,OAC3C,MAAM,GAAG,SAAS,QAChB,MAAM,WAOb,CAAC;AAEF,eAAO,MAAM,uBAAuB,QAIoG,CAAC;AAIzI,eAAO,MAAM,uBAAuB,oHAC+E,CAAC;AAEpH,eAAO,MAAM,2BAA2B,OAAQ,MAAM,WACC,CAAC;AAExD,eAAO,MAAM,oBAAoB,OAAQ,MAAM,cAAc,MAAM,WACM,CAAC;AAE1E,eAAO,MAAM,gCAAgC,OACvC,MAAM,cACE,MAAM,WAEsI,CAAC;AAE3J,eAAO,MAAM,4BAA4B,iBACzB,MAAM,gBACN,MAAM,WAEkL,CAAC;AAEzM,eAAO,MAAM,iBAAiB,QAGqF,CAAC;AAEpH,eAAO,MAAM,+BAA+B,YAAa,MAAM,EAAE,WAMhD,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2D,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAOhF,OAAO,EACL,mBAAmB,EASpB,MAAM,gBAAgB,CAAC;AAYxB,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,MAAM,EAAE,OAAO,EACf,UAAU,EACV,iBAAyB,EACzB,aAAa,EACb,mBAAmB,EACnB,0BAA0B,EAC1B,OAAY,EACZ,cAAc,EACd,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,yBAAyB,EACzB,cAAyB,EACzB,UAA6B,GAC9B,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA4RzC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AASA,OAAO,EAEL,YAAY,EAGb,MAAM,gBAAgB,CAAC;
|
1
|
+
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AASA,OAAO,EAEL,YAAY,EAGb,MAAM,gBAAgB,CAAC;AAoBxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,QAAQ,EACR,SAAS,EAAE,UAAe,EAC1B,SAAS,EAAE,UAAU,EACrB,UAAe,EACf,OAAY,EACZ,aAAoC,EACpC,MAAM,EAAE,OAAO,EACf,QAA0B,EAC1B,UAAiC,EACjC,cAAsC,EACtC,eAAe,EACf,UAAU,EACV,GAAG,QAAQ,EACZ,EAAE;IACD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE;QACf,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA6bpB"}
|