gt-react 9.2.30 → 10.0.0-alpha.15
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/CHANGELOG.md +0 -12
- package/LICENSE.md +1 -1
- package/dist/client.cjs.min.cjs +3 -3
- package/dist/client.d.ts +69 -74
- package/dist/client.esm.min.mjs +3 -3
- package/dist/dictionaries/getEntryAndMetadata.d.ts +2 -2
- package/dist/dictionaries/getEntryAndMetadata.d.ts.map +1 -1
- package/dist/dictionaries/loadDictionaryHelper.d.ts.map +1 -1
- package/dist/hooks/useGTClass.d.ts +1 -1
- package/dist/hooks/useGTClass.d.ts.map +1 -1
- package/dist/hooks/useLocaleSelector.d.ts +1 -10
- package/dist/hooks/useLocaleSelector.d.ts.map +1 -1
- package/dist/index.cjs.min.cjs +3 -3
- package/dist/index.esm.min.mjs +3 -3
- package/dist/internal/addGTIdentifier.d.ts +3 -2
- package/dist/internal/addGTIdentifier.d.ts.map +1 -1
- package/dist/internal/writeChildrenAsObjects.d.ts.map +1 -1
- package/dist/internal.cjs.min.cjs +1 -1
- package/dist/internal.d.ts +3 -2
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.esm.min.mjs +1 -1
- package/dist/provider/ClientProvider.d.ts.map +1 -1
- package/dist/provider/GTProvider.d.ts +1 -1
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/dist/provider/hooks/useCreateInternalUseGTFunction.d.ts +3 -3
- package/dist/provider/hooks/useCreateInternalUseGTFunction.d.ts.map +1 -1
- package/dist/provider/hooks/useCreateInternalUseTranslationsFunction.d.ts +3 -3
- package/dist/provider/hooks/useCreateInternalUseTranslationsFunction.d.ts.map +1 -1
- package/dist/provider/hooks/useErrorChecks.d.ts.map +1 -1
- package/dist/provider/hooks/useLoadTranslations.d.ts +6 -4
- package/dist/provider/hooks/useLoadTranslations.d.ts.map +1 -1
- package/dist/provider/hooks/useRuntimeTranslation.d.ts +7 -5
- package/dist/provider/hooks/useRuntimeTranslation.d.ts.map +1 -1
- package/dist/rendering/isVariableObject.d.ts +1 -1
- package/dist/rendering/isVariableObject.d.ts.map +1 -1
- package/dist/rendering/renderDefaultChildren.d.ts +3 -3
- package/dist/rendering/renderDefaultChildren.d.ts.map +1 -1
- package/dist/rendering/renderTranslatedChildren.d.ts +2 -2
- package/dist/rendering/renderTranslatedChildren.d.ts.map +1 -1
- package/dist/translation/inline/T.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/context.d.ts +6 -4
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/runtime.d.ts +8 -6
- package/dist/types/runtime.d.ts.map +1 -1
- package/dist/types/types.d.ts +34 -52
- package/dist/types/types.d.ts.map +1 -1
- package/dist/ui/LocaleSelector.d.ts.map +1 -1
- package/dist/variables/Currency.d.ts +7 -7
- package/dist/variables/Currency.d.ts.map +1 -1
- package/dist/variables/DateTime.d.ts +5 -6
- package/dist/variables/DateTime.d.ts.map +1 -1
- package/dist/variables/Num.d.ts +6 -6
- package/dist/variables/Num.d.ts.map +1 -1
- package/dist/variables/Var.d.ts +2 -3
- package/dist/variables/Var.d.ts.map +1 -1
- package/dist/variables/_getVariableProps.d.ts +8 -5
- package/dist/variables/_getVariableProps.d.ts.map +1 -1
- package/package.json +3 -3
@@ -1 +1 @@
|
|
1
|
-
"use strict";var e=require("react");require("generaltranslation");var r=require("react/jsx-runtime");const t=e=>`Duplicate key found in dictionary: "${e}"`;function n(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(t[n[a]]=e[n[a]])}return t}"function"==typeof SuppressedError&&SuppressedError;var a="en",i=["singular","plural","dual","zero","one","two","few","many","other"];var o=new(function(){function e(){this.cache=new Map}return e.prototype._generateKey=function(e,r,t){void 0===t&&(t={});var n=Array.isArray(r)?r.join(","):r,a=t?JSON.stringify(t,Object.keys(t).sort()):"{}";return"".concat(e,":").concat(n,":").concat(a)},e.prototype.get=function(e,r,t){void 0===t&&(t={});var n=this._generateKey(e,r,t);if(!this.cache.has(n)){var a=new Intl[e](r,t);this.cache.set(n,a)}return this.cache.get(n)},e}());const l={variable:"value",number:"n",datetime:"date",currency:"cost"};function s(e={},r){var t;if(e.name)return e.name;return`_gt_${l[r]||"value"}_${null===(t=e["data-_gt"])||void 0===t?void 0:t.id}`}const c=e=>{var r;if(!e)return"";const{type:t,props:n}=e;if(t&&"function"==typeof t){if("displayName"in t&&"string"==typeof t.displayName&&t.displayName)return t.displayName;if("name"in t&&"string"==typeof t.name&&t.name)return t.name}return t&&"string"==typeof t?t:n.href?"a":(null===(r=n["data-_gt"])||void 0===r?void 0:r.id)?`C${n["data-_gt"].id}`:"function"},u=r=>{return t=r,e.isValidElement(t)?(e=>{const{type:r,props:t}=e,n={type:c(e),props:{}};if(t["data-_gt"]){const e=t["data-_gt"];let r=Object.assign({},e);const a=e.transformation;if("variable"===a){const r=e.variableType||"variable";return{variable:r,key:s(t,r),id:e.id}}if("plural"===a&&e.branches){n.type="Plural";const t={};Object.entries(e.branches).forEach((([e,r])=>{t[e]=d(r)})),r=Object.assign(Object.assign({},r),{branches:t})}if("branch"===a&&e.branches){n.type="Branch";const t={};Object.entries(e.branches).forEach((([e,r])=>{t[e]=d(r)})),r=Object.assign(Object.assign({},r),{branches:t})}n.props["data-_gt"]=r}return t.children&&(n.props.children=d(t.children)),n})(r):"number"==typeof r?r.toString():r;var t};function d(e){return Array.isArray(e)?e.map(u):u(e)}function p(e,r,t){let n="",a=null;return"number"==typeof e&&!a&&t&&(n=function(e,r,t){void 0===r&&(r=i),void 0===t&&(t=["en"]);var n=o.get("PluralRules",t).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"===n&&r.includes("singular"))return"singular";if(2===a){if(r.includes("dual"))return"dual";if(r.includes("two"))return"two"}return"two"===n&&r.includes("dual")?"dual":r.includes(n)?n:"two"===n&&r.includes("dual")?"dual":"two"===n&&r.includes("plural")?"plural":"two"===n&&r.includes("other")?"other":"few"===n&&r.includes("plural")?"plural":"few"===n&&r.includes("other")?"other":"many"===n&&r.includes("plural")?"plural":"many"===n&&r.includes("other")?"other":"other"===n&&r.includes("plural")?"plural":""}(e,Object.keys(t),r)),n&&!a&&(a=t[n]),a}function f(e){var r;const t=(null===(r=e["data-_gt"])||void 0===r?void 0:r.variableType)||"variable";return{variableName:s(e,t),variableType:t,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 b(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 y(e){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function h({children:r,defaultLocale:t=a,renderVariable:i}){const o=r=>e.isValidElement(r)?(r=>{const a=y(r);if("variable"===(null==a?void 0:a.transformation)){const{variableType:e,variableValue:n,variableOptions:a}=f(r.props);return i({variableType:e,variableValue:n,variableOptions:a,locales:[t]})}if("plural"===(null==a?void 0:a.transformation)){const e=a.branches||{};return l(p(r.props.n,[t],e)||r.props.children)}if("branch"===(null==a?void 0:a.transformation)){let e=r.props,{children:t,name:i,branch:o,"data-_gt":s}=e,c=n(e,["children","name","branch","data-_gt"]);return i=i||r.props["data-_gt-name"]||"branch",c=a.branches||{},l(void 0!==c[o]?c[o]:t)}return"fragment"===(null==a?void 0:a.transformation)?e.createElement(r.type,{key:r.props.key,children:l(r.props.children)}):r.props.children?e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0,children:l(r.props.children)})):e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0}))})(r):r,l=r=>Array.isArray(r)?e.Children.map(r,o):o(r);return l(r)}function v({sourceElement:r,targetElement:t,locales:n=[a],renderVariable:i}){var o,l;const{props:s}=r,c=s["data-_gt"],u=null==c?void 0:c.transformation;if("plural"===u){const e=r.props.n;return g({source:p(e,n,c.branches||{})||r.props.children,target:p(e,n,t.props["data-_gt"].branches||{})||t.props.children,locales:n,renderVariable:i})}if("branch"===u){let{name:e,branch:a,children:o}=s;e=e||r.props["data-_gt-name"]||"branch";return g({source:(c.branches||{})[a]||o,target:(t.props["data-_gt"].branches||{})[a]||t.props.children,locales:n,renderVariable:i})}return"fragment"===u&&(null===(o=t.props)||void 0===o?void 0:o.children)?e.createElement(r.type,{key:r.props.key,children:g({source:s.children,target:t.props.children,locales:n,renderVariable:i})}):(null==s?void 0:s.children)&&(null===(l=t.props)||void 0===l?void 0:l.children)?e.cloneElement(r,Object.assign(Object.assign({},s),{"data-_gt":void 0,children:g({source:s.children,target:t.props.children,locales:n,renderVariable:i})})):h({children:r,defaultLocale:n[0],renderVariable:i})}function g({source:t,target:n,locales:i=[a],renderVariable:o}){if(null==n&&t)return h({children:t,defaultLocale:i[0],renderVariable:o});if("string"==typeof n)return n;if(Array.isArray(n)&&!Array.isArray(t)&&t&&(t=[t]),Array.isArray(t)&&Array.isArray(n)){const a={},l={},s=t.filter((r=>{if(e.isValidElement(r)){const e=y(r);if("variable"!==(null==e?void 0:e.transformation))return!0;{const{variableName:e,variableValue:t,variableOptions:n}=f(r.props);a[e]=t,l[e]=n}}})),c=e=>s.find((r=>{var t,n;const a=y(r);if(void 0!==(null==a?void 0:a.id)){return a.id===(null===(n=null===(t=null==e?void 0:e.props)||void 0===t?void 0:t["data-_gt"])||void 0===n?void 0:n.id)}return!1}))||s.shift();return n.map(((t,n)=>{if("string"==typeof t)return r.jsx(e.Fragment,{children:t},`string_${n}`);if(b(t))return r.jsx(e.Fragment,{children:o({variableType:t.variable||"variable",variableValue:a[t.key],variableOptions:l[t.key],locales:i})},`var_${n}`);const s=c(t);return s?r.jsx(e.Fragment,{children:v({sourceElement:s,targetElement:t,locales:i,renderVariable:o})},`element_${n}`):void 0}))}if(n&&"object"==typeof n&&!Array.isArray(n)){const r=b(n)?"variable":"element";if(e.isValidElement(t)){if("element"===r)return v({sourceElement:t,targetElement:n,locales:i,renderVariable:o});const e=y(t);if("variable"===(null==e?void 0:e.transformation)){const{variableValue:e,variableOptions:r,variableType:n}=f(t.props);return o({variableType:n,variableValue:e,variableOptions:r,locales:i})}}}return h({children:t,defaultLocale:i[0],renderVariable:o})}const m={method:"default",timeout:"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?8e3:12e3};class O 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}}}const j=e=>"string"==typeof e||Array.isArray(e),E=e=>"object"==typeof e&&null!==e&&!Array.isArray(e);exports.GTTranslationError=O,exports.addGTIdentifier=function r(t,a=0){let o=a;const l=e=>{const{type:t,props:a}=e;o+=1;const l={id:o};let s;try{s="function"==typeof t&&t.gtTransformation||""}catch(e){s=""}if(s){const t=s.split("-");if("translate"===t[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"===t[0]&&(l.variableType=(null==t?void 0:t[1])||"variable"),"plural"===t[0]){const e=Object.entries(a).reduce(((e,[t,n])=>{var a;return a=t,i.includes(a)&&(e[t]=r(n,o)),e}),{});Object.keys(e).length&&(l.branches=e)}if("branch"===t[0]){const{children:e,branch:t}=a,i=n(a,["children","branch"]),s=Object.entries(i).reduce(((e,[t,n])=>(e[t]=r(n,o),e)),{});Object.keys(s).length&&(l.branches=s)}l.transformation=t[0]}return l};function s(r){return e.isValidElement(r)?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));const n=l(r),a=Object.assign(Object.assign({},t),{"data-_gt":n});return t.children&&!n.variableType&&(a.children=c(t.children)),r.type===e.Fragment&&(a["data-_gt"].transformation="fragment"),e.cloneElement(r,a)}(r):r}function c(r){return Array.isArray(r)?e.Children.map(r,s):s(r)}return c(t)},exports.defaultLocaleCookieName="generaltranslation.locale",exports.defaultRenderSettings=m,exports.flattenDictionary=function e(r,n=""){const a={};for(const i in r)if(r.hasOwnProperty(i)){const o=n?`${n}.${i}`:i;if("object"!=typeof r[i]||null===r[i]||Array.isArray(r[i])){if(a.hasOwnProperty(o))throw new Error(t(o));a[o]=r[i]}else{const n=e(r[i],o);for(const e in n){if(a.hasOwnProperty(e))throw new Error(t(e));a[e]=n[e]}}}return a},exports.getDictionaryEntry=function(r,t){let n=r;const a=t.split(".");for(const r of a){if("object"!=typeof n||Array.isArray(n)||e.isValidElement(n))return;n=n[r]}return n},exports.getEntryAndMetadata=function(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}},exports.getPluralBranch=p,exports.getVariableName=s,exports.getVariableProps=f,exports.isValidDictionaryEntry=function(e){if("string"==typeof e)return!0;if(Array.isArray(e)){if("string"!=typeof(null==e?void 0:e[0]))return!1;const r=null==e?void 0:e[1];if(void 0===r)return!0;if(r&&"object"==typeof r)return!0}return!1},exports.isVariableObject=b,exports.mergeDictionaries=function e(r,t){const n=Object.assign(Object.assign({},Object.fromEntries(Object.entries(r).filter((([,e])=>j(e))))),Object.fromEntries(Object.entries(t).filter((([,e])=>j(e))))),a=Object.entries(r).filter((([,e])=>E(e))).map((([e])=>e)),i=Object.entries(t).filter((([,e])=>E(e))).map((([e])=>e)),o=new Set([...a,...i]);for(const a of o)n[a]=e(r[a]||{},t[a]||{});return n},exports.renderDefaultChildren=h,exports.renderSkeleton=function(){return""},exports.renderTranslatedChildren=g,exports.writeChildrenAsObjects=d;
|
1
|
+
"use strict";var e=require("react");require("generaltranslation");var r=require("react/jsx-runtime");const t=e=>`Duplicate key found in dictionary: "${e}"`;function n(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(t[n[a]]=e[n[a]])}return t}"function"==typeof SuppressedError&&SuppressedError;var a="en",i=["singular","plural","dual","zero","one","two","few","many","other"];var o=new(function(){function e(){this.cache=new Map}return e.prototype._generateKey=function(e,r,t){void 0===t&&(t={});var n=Array.isArray(r)?r.join(","):r,a=t?JSON.stringify(t,Object.keys(t).sort()):"{}";return"".concat(e,":").concat(n,":").concat(a)},e.prototype.get=function(e,r,t){void 0===t&&(t={});var n=this._generateKey(e,r,t);if(!this.cache.has(n)){var a=new Intl[e](r,t);this.cache.set(n,a)}return this.cache.get(n)},e}());function l(e){var r=e;if(r&&"object"==typeof r&&"string"==typeof r.k){var t=Object.keys(r);if(1===t.length)return!0;if(2===t.length){if("number"==typeof r.i)return!0;if("string"==typeof r.v)return!0}if(3===t.length&&"string"==typeof r.v&&"number"==typeof r.i)return!0}return!1}const s={variable:"value",number:"n",datetime:"date",currency:"cost"};function c(e={},r){var t;if(e.name)return e.name;return`_gt_${s[r]||"value"}_${null===(t=e["data-_gt"])||void 0===t?void 0:t.id}`}var u={pl:"placeholder",ti:"title",alt:"alt",arl:"aria-label",arb:"aria-labelledby",ard:"aria-describedby"},d={variable:"v",number:"n",datetime:"d",currency:"c"},p={v:"variable",n:"number",d:"datetime",c:"currency"};const f=e=>{var r;if(!e)return"";const{type:t,props:n}=e;if(t&&"function"==typeof t){if("displayName"in t&&"string"==typeof t.displayName&&t.displayName)return t.displayName;if("name"in t&&"string"==typeof t.name&&t.name)return t.name}return t&&"string"==typeof t?t:n.href?"a":(null===(r=n["data-_gt"])||void 0===r?void 0:r.id)?`C${n["data-_gt"].id}`:"function"},b=r=>{return t=r,e.isValidElement(t)?(e=>{const{type:r,props:t}=e,n={type:f(e),props:{}};if(t["data-_gt"]){const e=t["data-_gt"];let r=Object.assign({},e);Object.entries(u).forEach((([e,n])=>{t[n]&&(r[e]=t[n])}));const a=e.t;if("variable"===a){const r=d[e.variableType||"variable"];return{v:r,k:c(t,r),i:e.id}}if("plural"===a&&e.b){n.type="Plural";const t={};Object.entries(e.b).forEach((([e,r])=>{t[e]=y(r)})),r=Object.assign(Object.assign({},r),{b:t})}if("branch"===a&&e.b){n.type="Branch";const t={};Object.entries(e.b).forEach((([e,r])=>{t[e]=y(r)})),r=Object.assign(Object.assign({},r),{b:t})}n.props["data-_gt"]=r}return t.children&&(n.props.children=y(t.children)),n})(r):"number"==typeof r?r.toString():r;var t};function y(e){return Array.isArray(e)?e.map(b):b(e)}function v(e,r,t){let n="",a=null;return"number"==typeof e&&!a&&t&&(n=function(e,r,t){void 0===r&&(r=i),void 0===t&&(t=["en"]);var n=o.get("PluralRules",t).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"===n&&r.includes("singular"))return"singular";if(2===a){if(r.includes("dual"))return"dual";if(r.includes("two"))return"two"}return"two"===n&&r.includes("dual")?"dual":r.includes(n)?n:"two"===n&&r.includes("dual")?"dual":"two"===n&&r.includes("plural")?"plural":"two"===n&&r.includes("other")?"other":"few"===n&&r.includes("plural")?"plural":"few"===n&&r.includes("other")?"other":"many"===n&&r.includes("plural")?"plural":"many"===n&&r.includes("other")?"other":"other"===n&&r.includes("plural")?"plural":""}(e,Object.keys(t),r)),n&&!a&&(a=t[n]),a}function g(e){var r;return"object"==typeof e&&!!e&&"data-_gt"in e&&"object"==typeof e["data-_gt"]&&!!e["data-_gt"]&&"transformation"in e["data-_gt"]&&"variable"===(null===(r=e["data-_gt"])||void 0===r?void 0:r.transformation)}function h(e){var r;const t=(null===(r=e["data-_gt"])||void 0===r?void 0:r.variableType)||"variable";return{variableName:c(e,t),variableType:t,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({},void 0!==e.currency&&{currency:e.currency}),void 0!==e.options&&{options: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 m(e){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function O({children:r,defaultLocale:t=a,renderVariable:i}){const o=r=>e.isValidElement(r)?(r=>{const a=m(r);if(g(r.props)){const{variableType:e,variableValue:n,variableOptions:a}=h(r.props);return i({variableType:e,variableValue:n,variableOptions:a,locales:[t]})}if("plural"===(null==a?void 0:a.transformation)){const e=a.branches||{};return l(v(r.props.n,[t],e)||r.props.children)}if("branch"===(null==a?void 0:a.transformation)){let e=r.props,{children:t,name:i,branch:o,"data-_gt":s}=e,c=n(e,["children","name","branch","data-_gt"]);return c=a.branches||{},l(void 0!==c[o]?c[o]:t)}return"fragment"===(null==a?void 0:a.transformation)?e.createElement(r.type,{key:r.props.key,children:l(r.props.children)}):r.props.children?e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0,children:l(r.props.children)})):e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0}))})(r):r,l=r=>Array.isArray(r)?e.Children.map(r,o):o(r);return l(r)}function j({sourceElement:r,targetElement:t,locales:n=[a],renderVariable:i}){var o,l;const{props:s}=r,{props:c}=t,d=s["data-_gt"],p=null==d?void 0:d.t,f=c["data-_gt"],b={};if(f&&Object.entries(u).forEach((([e,r])=>{f[e]&&(b[r]=f[e])})),"plural"===p){const e=r.props.n;return _({source:v(e,n,d.b||{})||r.props.children,target:v(e,n,t.props["data-_gt"].b||{})||t.props.children,locales:n,renderVariable:i})}if("branch"===p){const{branch:e,children:r}=s;return _({source:(d.b||{})[e]||r,target:(t.props["data-_gt"].b||{})[e]||t.props.children,locales:n,renderVariable:i})}return"fragment"===p&&(null===(o=t.props)||void 0===o?void 0:o.children)?e.createElement(r.type,{key:r.props.key,children:_({source:s.children,target:t.props.children,locales:n,renderVariable:i})}):(null==s?void 0:s.children)&&(null===(l=t.props)||void 0===l?void 0:l.children)?e.cloneElement(r,Object.assign(Object.assign(Object.assign({},s),b),{"data-_gt":void 0,children:_({source:s.children,target:t.props.children,locales:n,renderVariable:i})})):O({children:r,defaultLocale:n[0],renderVariable:i})}function _({source:t,target:n,locales:i=[a],renderVariable:o}){if(null==n&&t)return O({children:t,defaultLocale:i[0],renderVariable:o});if("string"==typeof n)return n;if(Array.isArray(n)&&!Array.isArray(t)&&t&&(t=[t]),Array.isArray(t)&&Array.isArray(n)){const a={},s={},c=t.filter((r=>{if(e.isValidElement(r)){if(!g(r.props))return!0;{const{variableName:e,variableValue:t,variableOptions:n}=h(r.props);a[e]=t,s[e]=n}}return!1})),u=e=>c.find((r=>{var t,n;const a=m(r);if(void 0!==(null==a?void 0:a.id)){return a.id===(null===(n=null===(t=null==e?void 0:e.props)||void 0===t?void 0:t["data-_gt"])||void 0===n?void 0:n.id)}return!1}))||c.shift();return n.map(((t,n)=>{if("string"==typeof t)return r.jsx(e.Fragment,{children:t},`string_${n}`);if(l(t))return r.jsx(e.Fragment,{children:o({variableType:p[t.v||"v"],variableValue:a[t.k],variableOptions:s[t.k],locales:i})},`var_${n}`);const c=u(t);return c?r.jsx(e.Fragment,{children:j({sourceElement:c,targetElement:t,locales:i,renderVariable:o})},`element_${n}`):void 0}))}if(n&&"object"==typeof n&&!Array.isArray(n)){const r=l(n)?"variable":"element";if(e.isValidElement(t)){if("element"===r)return j({sourceElement:t,targetElement:n,locales:i,renderVariable:o});const e=m(t);if("variable"===(null==e?void 0:e.transformation)){const{variableValue:e,variableOptions:r,variableType:n}=h(t.props);return o({variableType:n,variableValue:e,variableOptions:r,locales:i})}}}return O({children:t,defaultLocale:i[0],renderVariable:o})}const E={method:"default",timeout:"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?8e3:12e3};const w=e=>"string"==typeof e||Array.isArray(e),A=e=>"object"==typeof e&&null!==e&&!Array.isArray(e);exports.addGTIdentifier=function r(t,a=0){let o=a;const l=e=>{const{type:t,props:a}=e;o+=1;const l={id:o};let s;try{s="function"==typeof t&&t.gtTransformation||""}catch(e){}if(s){const t=s.split("-");if("translate"===t[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"===t[0]&&(l.variableType=(null==t?void 0:t[1])||"variable"),"plural"===t[0]){const e=Object.entries(a).reduce(((e,[t,n])=>(function(e){return i.includes(e)}(t)&&(e[t]=r(n,o)),e)),{});Object.keys(e).length&&(l.b=e)}if("branch"===t[0]){const{children:e,branch:t}=a,i=n(a,["children","branch"]),s=Object.entries(i).reduce(((e,[t,n])=>(e[t]=r(n,o),e)),{});Object.keys(s).length&&(l.b=s)}l.t=t[0]}return l};function s(r){return e.isValidElement(r)?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));const n=l(r),a=Object.assign(Object.assign({},t),{"data-_gt":n});return t.children&&!n.variableType&&(a.children=c(t.children)),r.type===e.Fragment&&(a["data-_gt"].t="fragment"),e.cloneElement(r,a)}(r):r}function c(r){return Array.isArray(r)?e.Children.map(r,s):s(r)}return c(t)},exports.defaultLocaleCookieName="generaltranslation.locale",exports.defaultRenderSettings=E,exports.flattenDictionary=function e(r,n=""){const a={};for(const i in r)if(r.hasOwnProperty(i)){const o=n?`${n}.${i}`:i;if("object"!=typeof r[i]||null===r[i]||Array.isArray(r[i])){if(a.hasOwnProperty(o))throw new Error(t(o));a[o]=r[i]}else{const n=e(r[i],o);for(const e in n){if(a.hasOwnProperty(e))throw new Error(t(e));a[e]=n[e]}}}return a},exports.getDictionaryEntry=function(r,t){let n=r;const a=t.split(".");for(const r of a){if("object"!=typeof n||Array.isArray(n)||e.isValidElement(n))return;n=n[r]}return n},exports.getEntryAndMetadata=function(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}},exports.getPluralBranch=v,exports.getVariableName=c,exports.getVariableProps=h,exports.isValidDictionaryEntry=function(e){if("string"==typeof e)return!0;if(Array.isArray(e)){if("string"!=typeof(null==e?void 0:e[0]))return!1;const r=null==e?void 0:e[1];if(void 0===r)return!0;if(r&&"object"==typeof r)return!0}return!1},exports.isVariableObject=function(e){const r=e;if(r&&"object"==typeof r&&"string"==typeof r.k){const e=Object.keys(r);if(1===e.length)return!0;if(2===e.length){if("number"==typeof r.i)return!0;if("string"==typeof r.v)return!0}if(3===e.length&&"string"==typeof r.v&&"number"==typeof r.i)return!0}return!1},exports.mergeDictionaries=function e(r,t){const n=Object.assign(Object.assign({},Object.fromEntries(Object.entries(r).filter((([,e])=>w(e))))),Object.fromEntries(Object.entries(t).filter((([,e])=>w(e))))),a=Object.entries(r).filter((([,e])=>A(e))).map((([e])=>e)),i=Object.entries(t).filter((([,e])=>A(e))).map((([e])=>e)),o=new Set([...a,...i]);for(const a of o)n[a]=e(r[a]||{},t[a]||{});return n},exports.renderDefaultChildren=O,exports.renderSkeleton=function(){return""},exports.renderTranslatedChildren=_,exports.writeChildrenAsObjects=y;
|
package/dist/internal.d.ts
CHANGED
@@ -11,10 +11,11 @@ import renderDefaultChildren from './rendering/renderDefaultChildren';
|
|
11
11
|
import renderTranslatedChildren from './rendering/renderTranslatedChildren';
|
12
12
|
import { defaultRenderSettings } from './rendering/defaultRenderSettings';
|
13
13
|
import renderSkeleton from './rendering/renderSkeleton';
|
14
|
-
import { Dictionary, RenderMethod, TranslatedChildren,
|
14
|
+
import { Dictionary, RenderMethod, TranslatedChildren, Translations, RenderVariable, VariableProps, DictionaryEntry, FlattenedDictionary, MetaEntry, Entry, DictionaryTranslationOptions, InlineTranslationOptions, RuntimeTranslationOptions, LocalesDictionary, DictionaryContent, DictionaryObject, CustomLoader, TranslationsStatus } from './types/types';
|
15
15
|
import { GTContextType } from './types/context';
|
16
16
|
import { ClientProviderProps } from './types/config';
|
17
17
|
import { defaultLocaleCookieName } from './utils/cookies';
|
18
18
|
import mergeDictionaries from './dictionaries/mergeDictionaries';
|
19
|
-
|
19
|
+
import { GTProp } from 'generaltranslation/types';
|
20
|
+
export { addGTIdentifier, writeChildrenAsObjects, isVariableObject, Dictionary, flattenDictionary, getDictionaryEntry, isValidDictionaryEntry, getVariableProps, DictionaryEntry, FlattenedDictionary, MetaEntry as Metadata, getPluralBranch, getEntryAndMetadata, getVariableName, renderDefaultChildren, renderTranslatedChildren, renderSkeleton, RenderMethod, defaultRenderSettings, GTProp, Entry, TranslatedChildren, Translations, TranslationsStatus, GTContextType, ClientProviderProps, DictionaryTranslationOptions, InlineTranslationOptions, RuntimeTranslationOptions, DictionaryContent, DictionaryObject, LocalesDictionary, CustomLoader, RenderVariable, VariableProps, defaultLocaleCookieName, mergeDictionaries, };
|
20
21
|
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,sBAAsB,MAAM,mCAAmC,CAAC;AACvE,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,mBAAmB,MAAM,oCAAoC,CAAC;AACrE,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAC5D,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,qBAAqB,MAAM,mCAAmC,CAAC;AACtE,OAAO,wBAAwB,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,cAAc,MAAM,4BAA4B,CAAC;AACxD,OAAO,EACL,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AAC7D,OAAO,eAAe,MAAM,4BAA4B,CAAC;AACzD,OAAO,sBAAsB,MAAM,mCAAmC,CAAC;AACvE,OAAO,eAAe,MAAM,oCAAoC,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,mBAAmB,MAAM,oCAAoC,CAAC;AACrE,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,gBAAgB,MAAM,8BAA8B,CAAC;AAC5D,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,qBAAqB,MAAM,mCAAmC,CAAC;AACtE,OAAO,wBAAwB,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,cAAc,MAAM,4BAA4B,CAAC;AACxD,OAAO,EACL,UAAU,EACV,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,SAAS,EACT,KAAK,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,SAAS,IAAI,QAAQ,EACrB,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,MAAM,EACN,KAAK,EACL,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,mBAAmB,EACnB,4BAA4B,EAC5B,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,uBAAuB,EACvB,iBAAiB,GAClB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
import e,{isValidElement as r}from"react";import"generaltranslation";import{jsx as t}from"react/jsx-runtime";const n=e=>`Duplicate key found in dictionary: "${e}"`;function a(e,r=""){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=r?`${r}.${i}`:i;if("object"!=typeof e[i]||null===e[i]||Array.isArray(e[i])){if(t.hasOwnProperty(o))throw new Error(n(o));t[o]=e[i]}else{const r=a(e[i],o);for(const e in r){if(t.hasOwnProperty(e))throw new Error(n(e));t[e]=r[e]}}}return t}function i(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(t[n[a]]=e[n[a]])}return t}"function"==typeof SuppressedError&&SuppressedError;var o="en",l=["singular","plural","dual","zero","one","two","few","many","other"];var s=new(function(){function e(){this.cache=new Map}return e.prototype._generateKey=function(e,r,t){void 0===t&&(t={});var n=Array.isArray(r)?r.join(","):r,a=t?JSON.stringify(t,Object.keys(t).sort()):"{}";return"".concat(e,":").concat(n,":").concat(a)},e.prototype.get=function(e,r,t){void 0===t&&(t={});var n=this._generateKey(e,r,t);if(!this.cache.has(n)){var a=new Intl[e](r,t);this.cache.set(n,a)}return this.cache.get(n)},e}());function c(t,n=0){let a=n;const o=e=>{const{type:r,props:t}=e;a+=1;const n={id:a};let o;try{o="function"==typeof r&&r.gtTransformation||""}catch(e){o=""}if(o){const r=o.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]&&(n.variableType=(null==r?void 0:r[1])||"variable"),"plural"===r[0]){const e=Object.entries(t).reduce(((e,[r,t])=>{var n;return n=r,l.includes(n)&&(e[r]=c(t,a)),e}),{});Object.keys(e).length&&(n.branches=e)}if("branch"===r[0]){const{children:e,branch:r}=t,o=i(t,["children","branch"]),l=Object.entries(o).reduce(((e,[r,t])=>(e[r]=c(t,a),e)),{});Object.keys(l).length&&(n.branches=l)}n.transformation=r[0]}return n};function s(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));const n=o(r),a=Object.assign(Object.assign({},t),{"data-_gt":n});return t.children&&!n.variableType&&(a.children=u(t.children)),r.type===e.Fragment&&(a["data-_gt"].transformation="fragment"),e.cloneElement(r,a)}(t):t}function u(r){return Array.isArray(r)?e.Children.map(r,s):s(r)}return u(t)}const u={variable:"value",number:"n",datetime:"date",currency:"cost"};function d(e={},r){var t;if(e.name)return e.name;return`_gt_${u[r]||"value"}_${null===(t=e["data-_gt"])||void 0===t?void 0:t.id}`}const p=e=>{var r;if(!e)return"";const{type:t,props:n}=e;if(t&&"function"==typeof t){if("displayName"in t&&"string"==typeof t.displayName&&t.displayName)return t.displayName;if("name"in t&&"string"==typeof t.name&&t.name)return t.name}return t&&"string"==typeof t?t:n.href?"a":(null===(r=n["data-_gt"])||void 0===r?void 0:r.id)?`C${n["data-_gt"].id}`:"function"},f=r=>{return t=r,e.isValidElement(t)?(e=>{const{type:r,props:t}=e,n={type:p(e),props:{}};if(t["data-_gt"]){const e=t["data-_gt"];let r=Object.assign({},e);const a=e.transformation;if("variable"===a){const r=e.variableType||"variable";return{variable:r,key:d(t,r),id:e.id}}if("plural"===a&&e.branches){n.type="Plural";const t={};Object.entries(e.branches).forEach((([e,r])=>{t[e]=b(r)})),r=Object.assign(Object.assign({},r),{branches:t})}if("branch"===a&&e.branches){n.type="Branch";const t={};Object.entries(e.branches).forEach((([e,r])=>{t[e]=b(r)})),r=Object.assign(Object.assign({},r),{branches:t})}n.props["data-_gt"]=r}return t.children&&(n.props.children=b(t.children)),n})(r):"number"==typeof r?r.toString():r;var t};function b(e){return Array.isArray(e)?e.map(f):f(e)}function y(e,r,t){let n="",a=null;return"number"==typeof e&&!a&&t&&(n=function(e,r,t){void 0===r&&(r=l),void 0===t&&(t=["en"]);var n=s.get("PluralRules",t).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"===n&&r.includes("singular"))return"singular";if(2===a){if(r.includes("dual"))return"dual";if(r.includes("two"))return"two"}return"two"===n&&r.includes("dual")?"dual":r.includes(n)?n:"two"===n&&r.includes("dual")?"dual":"two"===n&&r.includes("plural")?"plural":"two"===n&&r.includes("other")?"other":"few"===n&&r.includes("plural")?"plural":"few"===n&&r.includes("other")?"other":"many"===n&&r.includes("plural")?"plural":"many"===n&&r.includes("other")?"other":"other"===n&&r.includes("plural")?"plural":""}(e,Object.keys(t),r)),n&&!a&&(a=t[n]),a}function h(e){if("string"==typeof e)return!0;if(Array.isArray(e)){if("string"!=typeof(null==e?void 0:e[0]))return!1;const r=null==e?void 0:e[1];if(void 0===r)return!0;if(r&&"object"==typeof r)return!0}return!1}function v(r,t){let n=r;const a=t.split(".");for(const r of a){if("object"!=typeof n||Array.isArray(n)||e.isValidElement(n))return;n=n[r]}return n}function g(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 m(e){var r;const t=(null===(r=e["data-_gt"])||void 0===r?void 0:r.variableType)||"variable";return{variableName:d(e,t),variableType:t,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 O(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 j(e){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function _({children:r,defaultLocale:t=o,renderVariable:n}){const a=r=>e.isValidElement(r)?(r=>{const a=j(r);if("variable"===(null==a?void 0:a.transformation)){const{variableType:e,variableValue:a,variableOptions:i}=m(r.props);return n({variableType:e,variableValue:a,variableOptions:i,locales:[t]})}if("plural"===(null==a?void 0:a.transformation)){const e=a.branches||{};return l(y(r.props.n,[t],e)||r.props.children)}if("branch"===(null==a?void 0:a.transformation)){let e=r.props,{children:t,name:n,branch:o,"data-_gt":s}=e,c=i(e,["children","name","branch","data-_gt"]);return n=n||r.props["data-_gt-name"]||"branch",c=a.branches||{},l(void 0!==c[o]?c[o]:t)}return"fragment"===(null==a?void 0:a.transformation)?e.createElement(r.type,{key:r.props.key,children:l(r.props.children)}):r.props.children?e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0,children:l(r.props.children)})):e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0}))})(r):r,l=r=>Array.isArray(r)?e.Children.map(r,a):a(r);return l(r)}function E({sourceElement:r,targetElement:t,locales:n=[o],renderVariable:a}){var i,l;const{props:s}=r,c=s["data-_gt"],u=null==c?void 0:c.transformation;if("plural"===u){const e=r.props.n;return w({source:y(e,n,c.branches||{})||r.props.children,target:y(e,n,t.props["data-_gt"].branches||{})||t.props.children,locales:n,renderVariable:a})}if("branch"===u){let{name:e,branch:i,children:o}=s;e=e||r.props["data-_gt-name"]||"branch";return w({source:(c.branches||{})[i]||o,target:(t.props["data-_gt"].branches||{})[i]||t.props.children,locales:n,renderVariable:a})}return"fragment"===u&&(null===(i=t.props)||void 0===i?void 0:i.children)?e.createElement(r.type,{key:r.props.key,children:w({source:s.children,target:t.props.children,locales:n,renderVariable:a})}):(null==s?void 0:s.children)&&(null===(l=t.props)||void 0===l?void 0:l.children)?e.cloneElement(r,Object.assign(Object.assign({},s),{"data-_gt":void 0,children:w({source:s.children,target:t.props.children,locales:n,renderVariable:a})})):_({children:r,defaultLocale:n[0],renderVariable:a})}function w({source:r,target:n,locales:a=[o],renderVariable:i}){if(null==n&&r)return _({children:r,defaultLocale:a[0],renderVariable:i});if("string"==typeof n)return n;if(Array.isArray(n)&&!Array.isArray(r)&&r&&(r=[r]),Array.isArray(r)&&Array.isArray(n)){const o={},l={},s=r.filter((r=>{if(e.isValidElement(r)){const e=j(r);if("variable"!==(null==e?void 0:e.transformation))return!0;{const{variableName:e,variableValue:t,variableOptions:n}=m(r.props);o[e]=t,l[e]=n}}})),c=e=>s.find((r=>{var t,n;const a=j(r);if(void 0!==(null==a?void 0:a.id)){return a.id===(null===(n=null===(t=null==e?void 0:e.props)||void 0===t?void 0:t["data-_gt"])||void 0===n?void 0:n.id)}return!1}))||s.shift();return n.map(((r,n)=>{if("string"==typeof r)return t(e.Fragment,{children:r},`string_${n}`);if(O(r))return t(e.Fragment,{children:i({variableType:r.variable||"variable",variableValue:o[r.key],variableOptions:l[r.key],locales:a})},`var_${n}`);const s=c(r);return s?t(e.Fragment,{children:E({sourceElement:s,targetElement:r,locales:a,renderVariable:i})},`element_${n}`):void 0}))}if(n&&"object"==typeof n&&!Array.isArray(n)){const t=O(n)?"variable":"element";if(e.isValidElement(r)){if("element"===t)return E({sourceElement:r,targetElement:n,locales:a,renderVariable:i});const e=j(r);if("variable"===(null==e?void 0:e.transformation)){const{variableValue:e,variableOptions:t,variableType:n}=m(r.props);return i({variableType:n,variableValue:e,variableOptions:t,locales:a})}}}return _({children:r,defaultLocale:a[0],renderVariable:i})}const A={method:"default",timeout:"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?8e3:12e3};function V(){return""}class T 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}}}const k="generaltranslation.locale",N=e=>"string"==typeof e||Array.isArray(e),$=e=>"object"==typeof e&&null!==e&&!Array.isArray(e);function P(e,r){const t=Object.assign(Object.assign({},Object.fromEntries(Object.entries(e).filter((([,e])=>N(e))))),Object.fromEntries(Object.entries(r).filter((([,e])=>N(e))))),n=Object.entries(e).filter((([,e])=>$(e))).map((([e])=>e)),a=Object.entries(r).filter((([,e])=>$(e))).map((([e])=>e)),i=new Set([...n,...a]);for(const n of i)t[n]=P(e[n]||{},r[n]||{});return t}export{T as GTTranslationError,c as addGTIdentifier,k as defaultLocaleCookieName,A as defaultRenderSettings,a as flattenDictionary,v as getDictionaryEntry,g as getEntryAndMetadata,y as getPluralBranch,d as getVariableName,m as getVariableProps,h as isValidDictionaryEntry,O as isVariableObject,P as mergeDictionaries,_ as renderDefaultChildren,V as renderSkeleton,w as renderTranslatedChildren,b as writeChildrenAsObjects};
|
1
|
+
import e,{isValidElement as r}from"react";import"generaltranslation";import{jsx as t}from"react/jsx-runtime";const n=e=>`Duplicate key found in dictionary: "${e}"`;function a(e,r=""){const t={};for(const i in e)if(e.hasOwnProperty(i)){const o=r?`${r}.${i}`:i;if("object"!=typeof e[i]||null===e[i]||Array.isArray(e[i])){if(t.hasOwnProperty(o))throw new Error(n(o));t[o]=e[i]}else{const r=a(e[i],o);for(const e in r){if(t.hasOwnProperty(e))throw new Error(n(e));t[e]=r[e]}}}return t}function i(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)r.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(t[n[a]]=e[n[a]])}return t}"function"==typeof SuppressedError&&SuppressedError;var o="en",l=["singular","plural","dual","zero","one","two","few","many","other"];var s=new(function(){function e(){this.cache=new Map}return e.prototype._generateKey=function(e,r,t){void 0===t&&(t={});var n=Array.isArray(r)?r.join(","):r,a=t?JSON.stringify(t,Object.keys(t).sort()):"{}";return"".concat(e,":").concat(n,":").concat(a)},e.prototype.get=function(e,r,t){void 0===t&&(t={});var n=this._generateKey(e,r,t);if(!this.cache.has(n)){var a=new Intl[e](r,t);this.cache.set(n,a)}return this.cache.get(n)},e}());function c(e){var r=e;if(r&&"object"==typeof r&&"string"==typeof r.k){var t=Object.keys(r);if(1===t.length)return!0;if(2===t.length){if("number"==typeof r.i)return!0;if("string"==typeof r.v)return!0}if(3===t.length&&"string"==typeof r.v&&"number"==typeof r.i)return!0}return!1}function u(t,n=0){let a=n;const o=e=>{const{type:r,props:t}=e;a+=1;const n={id:a};let o;try{o="function"==typeof r&&r.gtTransformation||""}catch(e){}if(o){const r=o.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]&&(n.variableType=(null==r?void 0:r[1])||"variable"),"plural"===r[0]){const e=Object.entries(t).reduce(((e,[r,t])=>(function(e){return l.includes(e)}(r)&&(e[r]=u(t,a)),e)),{});Object.keys(e).length&&(n.b=e)}if("branch"===r[0]){const{children:e,branch:r}=t,o=i(t,["children","branch"]),l=Object.entries(o).reduce(((e,[r,t])=>(e[r]=u(t,a),e)),{});Object.keys(l).length&&(n.b=l)}n.t=r[0]}return n};function s(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));const n=o(r),a=Object.assign(Object.assign({},t),{"data-_gt":n});return t.children&&!n.variableType&&(a.children=c(t.children)),r.type===e.Fragment&&(a["data-_gt"].t="fragment"),e.cloneElement(r,a)}(t):t}function c(r){return Array.isArray(r)?e.Children.map(r,s):s(r)}return c(t)}const d={variable:"value",number:"n",datetime:"date",currency:"cost"};function p(e={},r){var t;if(e.name)return e.name;return`_gt_${d[r]||"value"}_${null===(t=e["data-_gt"])||void 0===t?void 0:t.id}`}var f={pl:"placeholder",ti:"title",alt:"alt",arl:"aria-label",arb:"aria-labelledby",ard:"aria-describedby"},b={variable:"v",number:"n",datetime:"d",currency:"c"},y={v:"variable",n:"number",d:"datetime",c:"currency"};const v=e=>{var r;if(!e)return"";const{type:t,props:n}=e;if(t&&"function"==typeof t){if("displayName"in t&&"string"==typeof t.displayName&&t.displayName)return t.displayName;if("name"in t&&"string"==typeof t.name&&t.name)return t.name}return t&&"string"==typeof t?t:n.href?"a":(null===(r=n["data-_gt"])||void 0===r?void 0:r.id)?`C${n["data-_gt"].id}`:"function"},g=r=>{return t=r,e.isValidElement(t)?(e=>{const{type:r,props:t}=e,n={type:v(e),props:{}};if(t["data-_gt"]){const e=t["data-_gt"];let r=Object.assign({},e);Object.entries(f).forEach((([e,n])=>{t[n]&&(r[e]=t[n])}));const a=e.t;if("variable"===a){const r=b[e.variableType||"variable"];return{v:r,k:p(t,r),i:e.id}}if("plural"===a&&e.b){n.type="Plural";const t={};Object.entries(e.b).forEach((([e,r])=>{t[e]=h(r)})),r=Object.assign(Object.assign({},r),{b:t})}if("branch"===a&&e.b){n.type="Branch";const t={};Object.entries(e.b).forEach((([e,r])=>{t[e]=h(r)})),r=Object.assign(Object.assign({},r),{b:t})}n.props["data-_gt"]=r}return t.children&&(n.props.children=h(t.children)),n})(r):"number"==typeof r?r.toString():r;var t};function h(e){return Array.isArray(e)?e.map(g):g(e)}function m(e,r,t){let n="",a=null;return"number"==typeof e&&!a&&t&&(n=function(e,r,t){void 0===r&&(r=l),void 0===t&&(t=["en"]);var n=s.get("PluralRules",t).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"===n&&r.includes("singular"))return"singular";if(2===a){if(r.includes("dual"))return"dual";if(r.includes("two"))return"two"}return"two"===n&&r.includes("dual")?"dual":r.includes(n)?n:"two"===n&&r.includes("dual")?"dual":"two"===n&&r.includes("plural")?"plural":"two"===n&&r.includes("other")?"other":"few"===n&&r.includes("plural")?"plural":"few"===n&&r.includes("other")?"other":"many"===n&&r.includes("plural")?"plural":"many"===n&&r.includes("other")?"other":"other"===n&&r.includes("plural")?"plural":""}(e,Object.keys(t),r)),n&&!a&&(a=t[n]),a}function O(e){if("string"==typeof e)return!0;if(Array.isArray(e)){if("string"!=typeof(null==e?void 0:e[0]))return!1;const r=null==e?void 0:e[1];if(void 0===r)return!0;if(r&&"object"==typeof r)return!0}return!1}function j(r,t){let n=r;const a=t.split(".");for(const r of a){if("object"!=typeof n||Array.isArray(n)||e.isValidElement(n))return;n=n[r]}return n}function _(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 E(e){var r;return"object"==typeof e&&!!e&&"data-_gt"in e&&"object"==typeof e["data-_gt"]&&!!e["data-_gt"]&&"transformation"in e["data-_gt"]&&"variable"===(null===(r=e["data-_gt"])||void 0===r?void 0:r.transformation)}function w(e){var r;const t=(null===(r=e["data-_gt"])||void 0===r?void 0:r.variableType)||"variable";return{variableName:p(e,t),variableType:t,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({},void 0!==e.currency&&{currency:e.currency}),void 0!==e.options&&{options: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 A(e){const r=e;if(r&&"object"==typeof r&&"string"==typeof r.k){const e=Object.keys(r);if(1===e.length)return!0;if(2===e.length){if("number"==typeof r.i)return!0;if("string"==typeof r.v)return!0}if(3===e.length&&"string"==typeof r.v&&"number"==typeof r.i)return!0}return!1}function V(e){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function T({children:r,defaultLocale:t=o,renderVariable:n}){const a=r=>e.isValidElement(r)?(r=>{const a=V(r);if(E(r.props)){const{variableType:e,variableValue:a,variableOptions:i}=w(r.props);return n({variableType:e,variableValue:a,variableOptions:i,locales:[t]})}if("plural"===(null==a?void 0:a.transformation)){const e=a.branches||{};return l(m(r.props.n,[t],e)||r.props.children)}if("branch"===(null==a?void 0:a.transformation)){let e=r.props,{children:t,name:n,branch:o,"data-_gt":s}=e,c=i(e,["children","name","branch","data-_gt"]);return c=a.branches||{},l(void 0!==c[o]?c[o]:t)}return"fragment"===(null==a?void 0:a.transformation)?e.createElement(r.type,{key:r.props.key,children:l(r.props.children)}):r.props.children?e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0,children:l(r.props.children)})):e.cloneElement(r,Object.assign(Object.assign({},r.props),{"data-_gt":void 0}))})(r):r,l=r=>Array.isArray(r)?e.Children.map(r,a):a(r);return l(r)}function k({sourceElement:r,targetElement:t,locales:n=[o],renderVariable:a}){var i,l;const{props:s}=r,{props:c}=t,u=s["data-_gt"],d=null==u?void 0:u.t,p=c["data-_gt"],b={};if(p&&Object.entries(f).forEach((([e,r])=>{p[e]&&(b[r]=p[e])})),"plural"===d){const e=r.props.n;return N({source:m(e,n,u.b||{})||r.props.children,target:m(e,n,t.props["data-_gt"].b||{})||t.props.children,locales:n,renderVariable:a})}if("branch"===d){const{branch:e,children:r}=s;return N({source:(u.b||{})[e]||r,target:(t.props["data-_gt"].b||{})[e]||t.props.children,locales:n,renderVariable:a})}return"fragment"===d&&(null===(i=t.props)||void 0===i?void 0:i.children)?e.createElement(r.type,{key:r.props.key,children:N({source:s.children,target:t.props.children,locales:n,renderVariable:a})}):(null==s?void 0:s.children)&&(null===(l=t.props)||void 0===l?void 0:l.children)?e.cloneElement(r,Object.assign(Object.assign(Object.assign({},s),b),{"data-_gt":void 0,children:N({source:s.children,target:t.props.children,locales:n,renderVariable:a})})):T({children:r,defaultLocale:n[0],renderVariable:a})}function N({source:r,target:n,locales:a=[o],renderVariable:i}){if(null==n&&r)return T({children:r,defaultLocale:a[0],renderVariable:i});if("string"==typeof n)return n;if(Array.isArray(n)&&!Array.isArray(r)&&r&&(r=[r]),Array.isArray(r)&&Array.isArray(n)){const o={},l={},s=r.filter((r=>{if(e.isValidElement(r)){if(!E(r.props))return!0;{const{variableName:e,variableValue:t,variableOptions:n}=w(r.props);o[e]=t,l[e]=n}}return!1})),u=e=>s.find((r=>{var t,n;const a=V(r);if(void 0!==(null==a?void 0:a.id)){return a.id===(null===(n=null===(t=null==e?void 0:e.props)||void 0===t?void 0:t["data-_gt"])||void 0===n?void 0:n.id)}return!1}))||s.shift();return n.map(((r,n)=>{if("string"==typeof r)return t(e.Fragment,{children:r},`string_${n}`);if(c(r))return t(e.Fragment,{children:i({variableType:y[r.v||"v"],variableValue:o[r.k],variableOptions:l[r.k],locales:a})},`var_${n}`);const s=u(r);return s?t(e.Fragment,{children:k({sourceElement:s,targetElement:r,locales:a,renderVariable:i})},`element_${n}`):void 0}))}if(n&&"object"==typeof n&&!Array.isArray(n)){const t=c(n)?"variable":"element";if(e.isValidElement(r)){if("element"===t)return k({sourceElement:r,targetElement:n,locales:a,renderVariable:i});const e=V(r);if("variable"===(null==e?void 0:e.transformation)){const{variableValue:e,variableOptions:t,variableType:n}=w(r.props);return i({variableType:n,variableValue:e,variableOptions:t,locales:a})}}}return T({children:r,defaultLocale:a[0],renderVariable:i})}const $={method:"default",timeout:"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?8e3:12e3};function P(){return""}const S="generaltranslation.locale",x=e=>"string"==typeof e||Array.isArray(e),F=e=>"object"==typeof e&&null!==e&&!Array.isArray(e);function L(e,r){const t=Object.assign(Object.assign({},Object.fromEntries(Object.entries(e).filter((([,e])=>x(e))))),Object.fromEntries(Object.entries(r).filter((([,e])=>x(e))))),n=Object.entries(e).filter((([,e])=>F(e))).map((([e])=>e)),a=Object.entries(r).filter((([,e])=>F(e))).map((([e])=>e)),i=new Set([...n,...a]);for(const n of i)t[n]=L(e[n]||{},r[n]||{});return t}export{u as addGTIdentifier,S as defaultLocaleCookieName,$ as defaultRenderSettings,a as flattenDictionary,j as getDictionaryEntry,_ as getEntryAndMetadata,m as getPluralBranch,p as getVariableName,w as getVariableProps,O as isValidDictionaryEntry,A as isVariableObject,L as mergeDictionaries,T as renderDefaultChildren,P as renderSkeleton,N as renderTranslatedChildren,h as writeChildrenAsObjects};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAOtD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,MAAM,EAAE,OAAO,EACf,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,0BAA0B,EAC1B,OAAY,EACZ,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACV,yBAAyB,EACzB,qBAAqB,EACrB,gBAA0C,EAC1C,aAAa,GACd,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,
|
1
|
+
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAOtD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,UAAU,EACV,mBAAmB,EACnB,MAAM,EAAE,OAAO,EACf,UAAU,EACV,aAAa,EACb,mBAAmB,EACnB,0BAA0B,EAC1B,OAAY,EACZ,cAAc,EACd,SAAS,EACT,SAAS,EACT,UAAU,EACV,yBAAyB,EACzB,qBAAqB,EACrB,gBAA0C,EAC1C,aAAa,GACd,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAsKzC"}
|
@@ -16,7 +16,7 @@ import { GTProviderProps } from '../types/config';
|
|
16
16
|
* @param {object} [metadata] - Additional metadata to pass to the context.
|
17
17
|
* @param {boolean} [ssr=isSSREnabled()] - Whether to enable server-side rendering.
|
18
18
|
* @param {string} [localeCookieName=defaultLocaleCookieName] - The name of the cookie to store the locale.
|
19
|
-
* @param {
|
19
|
+
* @param {Translations | null} [translations=null] - The translations to use for the context.
|
20
20
|
* @param {React.ReactNode} [fallback = undefined] - Custom fallback to display while loading
|
21
21
|
*
|
22
22
|
* @returns {JSX.Element} The provider component for General Translation context.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMlD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,QAAQ,EACR,MAAM,EACN,SAAS,EAAE,UAAoC,EAC/C,SAAS,EAAE,UAAoC,EAC/C,UAAU,EAAE,WAAsC,EAClD,OAA+B,EAC/B,aAA6D,EAC7D,QAA8C,EAC9C,UAAuD,EACvD,cAAgE,EAChE,GAAmC,EACnC,gBAAsE,EACtE,MAAM,EAAE,OAAY,EACpB,cAAc,EACd,gBAAgB,EAChB,QAAoB,EACpB,YAAY,EAAE,aAAoB,EAClC,UAAU,EACV,aAAqC,EACrC,GAAG,QAAQ,EACZ,EAAE,eAAe,
|
1
|
+
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAMlD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,QAAQ,EACR,MAAM,EACN,SAAS,EAAE,UAAoC,EAC/C,SAAS,EAAE,UAAoC,EAC/C,UAAU,EAAE,WAAsC,EAClD,OAA+B,EAC/B,aAA6D,EAC7D,QAA8C,EAC9C,UAAuD,EACvD,cAAgE,EAChE,GAAmC,EACnC,gBAAsE,EACtE,MAAM,EAAE,OAAY,EACpB,cAAc,EACd,gBAAgB,EAChB,QAAoB,EACpB,YAAY,EAAE,aAAoB,EAClC,UAAU,EACV,aAAqC,EACrC,GAAG,QAAQ,EACZ,EAAE,eAAe,2CAuKjB"}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { InlineTranslationOptions,
|
2
|
-
import {
|
3
|
-
export default function useCreateInternalUseGTFunction(translations:
|
1
|
+
import { InlineTranslationOptions, TranslationsStatus, Translations, RenderMethod } from '../../types/types';
|
2
|
+
import { TranslateIcuCallback } from '../../types/runtime';
|
3
|
+
export default function useCreateInternalUseGTFunction(translations: Translations | null, translationsStatus: TranslationsStatus | null, locale: string, defaultLocale: string, translationRequired: boolean, dialectTranslationRequired: boolean, runtimeTranslationEnabled: boolean, registerIcuForTranslation: TranslateIcuCallback, renderSettings: {
|
4
4
|
method: RenderMethod;
|
5
5
|
}): (string: string, options?: InlineTranslationOptions) => string;
|
6
6
|
//# sourceMappingURL=useCreateInternalUseGTFunction.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCreateInternalUseGTFunction.d.ts","sourceRoot":"","sources":["../../../src/provider/hooks/useCreateInternalUseGTFunction.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useCreateInternalUseGTFunction.d.ts","sourceRoot":"","sources":["../../../src/provider/hooks/useCreateInternalUseGTFunction.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAG3D,MAAM,CAAC,OAAO,UAAU,8BAA8B,CACpD,YAAY,EAAE,YAAY,GAAG,IAAI,EACjC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,EAC7C,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,OAAO,EAC5B,0BAA0B,EAAE,OAAO,EACnC,yBAAyB,EAAE,OAAO,EAClC,yBAAyB,EAAE,oBAAoB,EAC/C,cAAc,EAAE;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GACvC,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB,KAAK,MAAM,CAgHhE"}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { Dictionary, DictionaryTranslationOptions, RenderMethod,
|
2
|
-
import {
|
3
|
-
export default function useCreateInternalUseTranslationsFunction(dictionary: Dictionary | undefined, translations:
|
1
|
+
import { Dictionary, DictionaryTranslationOptions, RenderMethod, TranslationsStatus, Translations } from '../../types/types';
|
2
|
+
import { TranslateIcuCallback } from '../../types/runtime';
|
3
|
+
export default function useCreateInternalUseTranslationsFunction(dictionary: Dictionary | undefined, translations: Translations | null, translationsStatus: TranslationsStatus | null, locale: string, defaultLocale: string, translationRequired: boolean, dialectTranslationRequired: boolean, runtimeTranslationEnabled: boolean, registerIcuForTranslation: TranslateIcuCallback, renderSettings: {
|
4
4
|
method: RenderMethod;
|
5
5
|
}): (id: string, options?: DictionaryTranslationOptions) => string;
|
6
6
|
//# sourceMappingURL=useCreateInternalUseTranslationsFunction.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useCreateInternalUseTranslationsFunction.d.ts","sourceRoot":"","sources":["../../../src/provider/hooks/useCreateInternalUseTranslationsFunction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,4BAA4B,EAC5B,YAAY,EACZ,kBAAkB,
|
1
|
+
{"version":3,"file":"useCreateInternalUseTranslationsFunction.d.ts","sourceRoot":"","sources":["../../../src/provider/hooks/useCreateInternalUseTranslationsFunction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,UAAU,EACV,4BAA4B,EAC5B,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,wCAAwC,CAC9D,UAAU,EAAE,UAAU,GAAG,SAAS,EAClC,YAAY,EAAE,YAAY,GAAG,IAAI,EACjC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,EAC7C,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,OAAO,EAC5B,0BAA0B,EAAE,OAAO,EACnC,yBAAyB,EAAE,OAAO,EAClC,yBAAyB,EAAE,oBAAoB,EAC/C,cAAc,EAAE;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,QAGjC,MAAM,YAAW,4BAA4B,KAAQ,MAAM,CA2GnE"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useErrorChecks.d.ts","sourceRoot":"","sources":["../../../src/provider/hooks/useErrorChecks.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"useErrorChecks.d.ts","sourceRoot":"","sources":["../../../src/provider/hooks/useErrorChecks.ts"],"names":[],"mappings":"AAeA,wBAAgB,cAAc,CAAC,EAC7B,SAAS,EACT,SAAS,EACT,UAAU,EACV,oBAAoB,EACpB,QAAQ,EACR,OAAO,GACR,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,QAgDA"}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { CustomLoader,
|
1
|
+
import { CustomLoader, TranslationsStatus, Translations } from '../../types/types';
|
2
2
|
export declare function useLoadTranslations({ _translations, translationRequired, loadTranslationsType, loadTranslations, locale, cacheUrl, projectId, _versionId, }: {
|
3
|
-
_translations:
|
3
|
+
_translations: Translations | null;
|
4
4
|
translationRequired: boolean;
|
5
5
|
loadTranslationsType: string;
|
6
6
|
loadTranslations?: CustomLoader;
|
@@ -9,7 +9,9 @@ export declare function useLoadTranslations({ _translations, translationRequired
|
|
9
9
|
projectId: string;
|
10
10
|
_versionId?: string;
|
11
11
|
}): {
|
12
|
-
translations:
|
13
|
-
setTranslations: import("react").Dispatch<import("react").SetStateAction<
|
12
|
+
translations: Translations | null;
|
13
|
+
setTranslations: import("react").Dispatch<import("react").SetStateAction<Translations | null>>;
|
14
|
+
translationsStatus: TranslationsStatus | null;
|
15
|
+
setTranslationsStatus: import("react").Dispatch<import("react").SetStateAction<TranslationsStatus | null>>;
|
14
16
|
};
|
15
17
|
//# sourceMappingURL=useLoadTranslations.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useLoadTranslations.d.ts","sourceRoot":"","sources":["../../../src/provider/hooks/useLoadTranslations.ts"],"names":[],"mappings":"AAEA,OAAO,
|
1
|
+
{"version":3,"file":"useLoadTranslations.d.ts","sourceRoot":"","sources":["../../../src/provider/hooks/useLoadTranslations.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAG3B,wBAAgB,mBAAmB,CAAC,EAClC,aAAa,EACb,mBAAmB,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,MAAM,EACN,QAAQ,EACR,SAAS,EACT,UAAU,GACX,EAAE;IACD,aAAa,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gBAAgB,CAAC,EAAE,YAAY,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;;;;;EAwGA"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as React from 'react';
|
2
|
-
import { RenderMethod } from '../../types/types';
|
3
|
-
import {
|
4
|
-
export default function useRuntimeTranslation({ projectId, devApiKey, locale, versionId, defaultLocale, runtimeUrl, renderSettings, setTranslations, ...globalMetadata }: {
|
2
|
+
import { RenderMethod, TranslationsStatus, Translations } from '../../types/types';
|
3
|
+
import { TranslateIcuCallback, TranslateChildrenCallback, TranslateI18nextCallback } from '../../types/runtime';
|
4
|
+
export default function useRuntimeTranslation({ projectId, devApiKey, locale, versionId, defaultLocale, runtimeUrl, renderSettings, setTranslations, setTranslationsStatus, ...globalMetadata }: {
|
5
5
|
projectId?: string;
|
6
6
|
devApiKey?: string;
|
7
7
|
locale: string;
|
@@ -12,10 +12,12 @@ export default function useRuntimeTranslation({ projectId, devApiKey, locale, ve
|
|
12
12
|
method: RenderMethod;
|
13
13
|
timeout?: number;
|
14
14
|
};
|
15
|
-
setTranslations: React.Dispatch<React.SetStateAction<
|
15
|
+
setTranslations: React.Dispatch<React.SetStateAction<Translations | null>>;
|
16
|
+
setTranslationsStatus: React.Dispatch<React.SetStateAction<TranslationsStatus | null>>;
|
16
17
|
[key: string]: any;
|
17
18
|
}): {
|
18
|
-
|
19
|
+
registerI18nextForTranslation: TranslateI18nextCallback;
|
20
|
+
registerIcuForTranslation: TranslateIcuCallback;
|
19
21
|
registerJsxForTranslation: TranslateChildrenCallback;
|
20
22
|
runtimeTranslationEnabled: boolean;
|
21
23
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useRuntimeTranslation.d.ts","sourceRoot":"","sources":["../../../src/provider/hooks/useRuntimeTranslation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EACL,YAAY,
|
1
|
+
{"version":3,"file":"useRuntimeTranslation.d.ts","sourceRoot":"","sources":["../../../src/provider/hooks/useRuntimeTranslation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,OAAO,EACL,YAAY,EAEZ,kBAAkB,EAClB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,qBAAqB,CAAC;AA8B7B,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,SAAS,EACT,SAAS,EACT,MAAM,EACN,SAAS,EACT,aAAa,EACb,UAAU,EACV,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,GAAG,cAAc,EAClB,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,EAAE;QACd,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,eAAe,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;IAC3E,qBAAqB,EAAE,KAAK,CAAC,QAAQ,CACnC,KAAK,CAAC,cAAc,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAChD,CAAC;IACF,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,GAAG;IACF,6BAA6B,EAAE,wBAAwB,CAAC;IACxD,yBAAyB,EAAE,oBAAoB,CAAC;IAChD,yBAAyB,EAAE,yBAAyB,CAAC;IACrD,yBAAyB,EAAE,OAAO,CAAC;CACpC,CA4WA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"isVariableObject.d.ts","sourceRoot":"","sources":["../../src/rendering/isVariableObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"isVariableObject.d.ts","sourceRoot":"","sources":["../../src/rendering/isVariableObject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,GAAG,IAAI,QAAQ,CAsBtE"}
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import React
|
2
|
-
import { RenderVariable } from '../types/types';
|
1
|
+
import React from 'react';
|
2
|
+
import { RenderVariable, TaggedChildren } from '../types/types';
|
3
3
|
export default function renderDefaultChildren({ children, defaultLocale, renderVariable, }: {
|
4
|
-
children:
|
4
|
+
children: TaggedChildren;
|
5
5
|
defaultLocale: string;
|
6
6
|
renderVariable: RenderVariable;
|
7
7
|
}): React.ReactNode;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"renderDefaultChildren.d.ts","sourceRoot":"","sources":["../../src/rendering/renderDefaultChildren.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"renderDefaultChildren.d.ts","sourceRoot":"","sources":["../../src/rendering/renderDefaultChildren.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAOzC,OAAO,EACL,cAAc,EAEd,cAAc,EAEf,MAAM,gBAAgB,CAAC;AAExB,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,QAAQ,EACR,aAAoC,EACpC,cAAc,GACf,EAAE;IACD,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,KAAK,CAAC,SAAS,CA0ElB"}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ReactNode } from 'react';
|
2
|
-
import {
|
2
|
+
import { TaggedChildren, TranslatedChildren, RenderVariable } from '../types/types';
|
3
3
|
export default function renderTranslatedChildren({ source, target, locales, renderVariable, }: {
|
4
|
-
source:
|
4
|
+
source: TaggedChildren;
|
5
5
|
target: TranslatedChildren;
|
6
6
|
locales: string[];
|
7
7
|
renderVariable: RenderVariable;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"renderTranslatedChildren.d.ts","sourceRoot":"","sources":["../../src/rendering/renderTranslatedChildren.tsx"],"names":[],"mappings":"AAAA,OAAc,
|
1
|
+
{"version":3,"file":"renderTranslatedChildren.d.ts","sourceRoot":"","sources":["../../src/rendering/renderTranslatedChildren.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EACL,cAAc,EAEd,kBAAkB,EAClB,cAAc,EAEf,MAAM,gBAAgB,CAAC;AAoHxB,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAC,EAC/C,MAAM,EACN,MAAM,EACN,OAAgC,EAChC,cAAc,GACf,EAAE;IACD,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,cAAc,CAAC;CAChC,GAAG,SAAS,CAoIZ"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"T.d.ts","sourceRoot":"","sources":["../../../src/translation/inline/T.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"T.d.ts","sourceRoot":"","sources":["../../../src/translation/inline/T.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAWzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,iBAAS,CAAC,CAAC,EACT,QAAQ,EACR,EAAE,EACF,OAAO,GACR,EAAE;IACD,QAAQ,EAAE,GAAG,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CA+I3B;kBAxJQ,CAAC;;;AA4JV,eAAe,CAAC,CAAC"}
|
package/dist/types/config.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { RenderMethod } from '../internal';
|
2
|
-
import { Dictionary,
|
2
|
+
import { Dictionary, Translations, CustomLoader } from './types';
|
3
3
|
import { CustomMapping } from 'generaltranslation/types';
|
4
4
|
export type GTConfig = {
|
5
5
|
projectId?: string;
|
@@ -35,7 +35,7 @@ export type GTProviderProps = {
|
|
35
35
|
_versionId?: string;
|
36
36
|
ssr?: boolean;
|
37
37
|
localeCookieName?: string;
|
38
|
-
translations?:
|
38
|
+
translations?: Translations | null;
|
39
39
|
loadDictionary?: CustomLoader;
|
40
40
|
loadTranslations?: CustomLoader;
|
41
41
|
config?: GTConfig;
|
@@ -46,7 +46,7 @@ export type GTProviderProps = {
|
|
46
46
|
export type ClientProviderProps = {
|
47
47
|
children: any;
|
48
48
|
dictionary: Dictionary;
|
49
|
-
initialTranslations:
|
49
|
+
initialTranslations: Translations;
|
50
50
|
locale: string;
|
51
51
|
locales: string[];
|
52
52
|
_versionId?: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,MAAM,QAAQ,GAAG;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE;QACf,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,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,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,YAAY,CAAC;IAC9B,gBAAgB,CAAC,EAAE,YAAY,CAAC;IAChC,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,GAAG,CAAC;IACd,UAAU,EAAE,UAAU,CAAC;IACvB,mBAAmB,EAAE,YAAY,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,0BAA0B,EAAE,OAAO,CAAC;IACpC,cAAc,EAAE;QACd,MAAM,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,yBAAyB,EAAE,OAAO,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC"}
|
package/dist/types/context.d.ts
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { Translations, RenderMethod, InlineTranslationOptions, DictionaryTranslationOptions, TranslationsStatus } from './types';
|
2
|
+
import { TranslateIcuCallback, TranslateChildrenCallback, TranslateI18nextCallback } from './runtime';
|
3
3
|
import { GT } from 'generaltranslation';
|
4
4
|
export type GTContextType = {
|
5
5
|
gt: GT;
|
6
|
-
|
6
|
+
registerI18nextForTranslation: TranslateI18nextCallback;
|
7
|
+
registerIcuForTranslation: TranslateIcuCallback;
|
7
8
|
registerJsxForTranslation: TranslateChildrenCallback;
|
8
9
|
_internalUseGTFunction: (string: string, options?: InlineTranslationOptions) => string;
|
9
10
|
_internalUseTranslationsFunction: (id: string, options?: DictionaryTranslationOptions) => string;
|
@@ -12,7 +13,8 @@ export type GTContextType = {
|
|
12
13
|
locales: string[];
|
13
14
|
setLocale: (locale: string) => void;
|
14
15
|
defaultLocale: string;
|
15
|
-
translations:
|
16
|
+
translations: Translations | null;
|
17
|
+
translationsStatus: TranslationsStatus | null;
|
16
18
|
translationRequired: boolean;
|
17
19
|
dialectTranslationRequired: boolean;
|
18
20
|
renderSettings: {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,wBAAwB,EACxB,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAExC,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,EAAE,CAAC;IACP,6BAA6B,EAAE,wBAAwB,CAAC;IACxD,yBAAyB,EAAE,oBAAoB,CAAC;IAChD,yBAAyB,EAAE,yBAAyB,CAAC;IACrD,sBAAsB,EAAE,CACtB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,KAC/B,MAAM,CAAC;IACZ,gCAAgC,EAAE,CAChC,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,4BAA4B,KACnC,MAAM,CAAC;IACZ,yBAAyB,EAAE,OAAO,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC9C,mBAAmB,EAAE,OAAO,CAAC;IAC7B,0BAA0B,EAAE,OAAO,CAAC;IACpC,cAAc,EAAE;QAAE,MAAM,EAAE,YAAY,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
package/dist/types/runtime.d.ts
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
1
|
+
import { JsxChildren } from 'generaltranslation/types';
|
2
|
+
import { TranslatedChildren } from './types';
|
3
|
+
export type TranslateIcuCallback = (params: {
|
4
|
+
source: string;
|
4
5
|
targetLocale: string;
|
5
6
|
metadata: {
|
6
7
|
hash: string;
|
7
8
|
context?: string;
|
8
9
|
} & Record<string, any>;
|
9
|
-
}) => Promise<
|
10
|
+
}) => Promise<TranslatedChildren>;
|
11
|
+
export type TranslateI18nextCallback = TranslateIcuCallback;
|
10
12
|
export type TranslateChildrenCallback = (params: {
|
11
|
-
source:
|
13
|
+
source: JsxChildren | undefined;
|
12
14
|
targetLocale: string;
|
13
15
|
metadata: {
|
14
16
|
hash: string;
|
15
17
|
context?: string;
|
16
18
|
} & Record<string, any>;
|
17
|
-
}) => Promise<
|
19
|
+
}) => Promise<TranslatedChildren>;
|
18
20
|
//# sourceMappingURL=runtime.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/types/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/types/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,MAAM,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpE,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAElC,MAAM,MAAM,wBAAwB,GAAG,oBAAoB,CAAC;AAE5D,MAAM,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE;IAC/C,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpE,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC"}
|
package/dist/types/types.d.ts
CHANGED
@@ -1,72 +1,60 @@
|
|
1
|
-
import {
|
1
|
+
import { JsxChildren } from 'generaltranslation/internal';
|
2
|
+
import { HtmlContentPropKeysRecord, GTProp, Variable, VariableTransformationSuffix } from 'generaltranslation/types';
|
2
3
|
import React from 'react';
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
id: number;
|
7
|
-
transformation?: string;
|
8
|
-
children?: Children;
|
9
|
-
} & Record<string, any>;
|
10
|
-
export type TaggedChild = React.ReactNode | TaggedElement;
|
11
|
-
export type TaggedChildren = TaggedChild[] | TaggedChild;
|
4
|
+
/**
|
5
|
+
* TaggedElement is a React element with a GTProp property.
|
6
|
+
*/
|
12
7
|
export type TaggedElementProps = Record<string, any> & {
|
13
8
|
'data-_gt': GTProp;
|
14
9
|
};
|
15
10
|
export type TaggedElement = React.ReactElement<TaggedElementProps>;
|
16
|
-
export type
|
17
|
-
export type
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
}>;
|
11
|
+
export type TaggedChild = Exclude<React.ReactNode, React.ReactElement> | TaggedElement;
|
12
|
+
export type TaggedChildren = TaggedChild[] | TaggedChild;
|
13
|
+
/**
|
14
|
+
* For dictionaries, we have Entry and MetaEntry
|
15
|
+
*/
|
22
16
|
export type Entry = string;
|
23
|
-
export type
|
17
|
+
export type MetaEntry = {
|
24
18
|
context?: string;
|
25
|
-
|
26
|
-
[key: string]: any;
|
19
|
+
[key: string]: unknown;
|
27
20
|
};
|
28
|
-
export type DictionaryEntry = Entry | [Entry] | [Entry,
|
21
|
+
export type DictionaryEntry = Entry | [Entry] | [Entry, MetaEntry];
|
29
22
|
export type Dictionary = {
|
30
23
|
[key: string]: Dictionary | DictionaryEntry;
|
31
24
|
};
|
32
25
|
export type FlattenedDictionary = {
|
33
26
|
[key: string]: DictionaryEntry;
|
34
27
|
};
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
variable?: 'variable' | 'number' | 'datetime' | 'currency';
|
39
|
-
};
|
28
|
+
/**
|
29
|
+
* Translated content types
|
30
|
+
*/
|
40
31
|
export type TranslatedElement = {
|
41
32
|
type: string;
|
42
33
|
props: {
|
43
34
|
'data-_gt': {
|
44
35
|
id: number;
|
45
|
-
|
46
|
-
|
36
|
+
transformation?: string;
|
37
|
+
b?: Record<string, JsxChildren>;
|
38
|
+
} & HtmlContentPropKeysRecord;
|
47
39
|
children?: TranslatedChildren;
|
48
40
|
};
|
49
41
|
};
|
50
42
|
export type TranslatedChild = TranslatedElement | string | Variable;
|
51
43
|
export type TranslatedChildren = TranslatedChild | TranslatedChild[];
|
52
|
-
export type
|
53
|
-
|
54
|
-
state: 'error';
|
55
|
-
error: string;
|
56
|
-
code?: number;
|
57
|
-
};
|
58
|
-
export type TranslationSuccess = {
|
59
|
-
state: 'success';
|
60
|
-
target: TranslatedChildren | TranslatedContent;
|
44
|
+
export type Translations = {
|
45
|
+
[hash: string]: TranslatedChildren;
|
61
46
|
};
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
export type
|
66
|
-
[hash: string]:
|
67
|
-
|
68
|
-
|
69
|
-
|
47
|
+
/**
|
48
|
+
* Mapping of hashes to translation result status.
|
49
|
+
*/
|
50
|
+
export type TranslationsStatus = {
|
51
|
+
[hash: string]: {
|
52
|
+
status: 'success' | 'loading';
|
53
|
+
} | {
|
54
|
+
status: 'error';
|
55
|
+
code?: number;
|
56
|
+
error?: string;
|
57
|
+
};
|
70
58
|
};
|
71
59
|
export type DictionaryContent = string;
|
72
60
|
export type DictionaryObject = {
|
@@ -87,15 +75,9 @@ export type InlineTranslationOptions = {
|
|
87
75
|
} & DictionaryTranslationOptions;
|
88
76
|
export type RuntimeTranslationOptions = {
|
89
77
|
locale?: string;
|
90
|
-
} & InlineTranslationOptions
|
91
|
-
export declare class GTTranslationError extends Error {
|
92
|
-
error: string;
|
93
|
-
code: number;
|
94
|
-
constructor(error: string, code: number);
|
95
|
-
toTranslationError(): TranslationError;
|
96
|
-
}
|
78
|
+
} & Omit<InlineTranslationOptions, 'id'>;
|
97
79
|
export type VariableProps = {
|
98
|
-
variableType:
|
80
|
+
variableType: VariableTransformationSuffix;
|
99
81
|
variableValue: any;
|
100
82
|
variableOptions: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions;
|
101
83
|
variableName: string;
|