gt-react 9.2.0-alpha.2 → 9.2.0-alpha.4
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.d.ts +34 -63
- package/dist/client.esm.min.mjs +3 -3
- package/dist/hooks/internal/useCreateInternalUseDictFunction.d.ts +6 -0
- package/dist/hooks/internal/useCreateInternalUseDictFunction.d.ts.map +1 -0
- package/dist/hooks/internal/useCreateInternalUseGTFunction.d.ts +6 -0
- package/dist/hooks/internal/useCreateInternalUseGTFunction.d.ts.map +1 -0
- package/dist/hooks/internal/useRuntimeTranslation.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.map +1 -1
- package/dist/internal/flattenDictionary.d.ts.map +1 -1
- package/dist/internal.cjs.min.cjs +1 -1
- package/dist/internal.d.ts +3 -3
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.esm.min.mjs +1 -1
- package/dist/messages/createMessages.d.ts +4 -4
- package/dist/messages/createMessages.d.ts.map +1 -1
- package/dist/provider/ClientProvider.d.ts +1 -1
- package/dist/provider/ClientProvider.d.ts.map +1 -1
- package/dist/provider/GTProvider.d.ts.map +1 -1
- package/dist/provider/helpers/getDictionaryEntry.d.ts +3 -2
- package/dist/provider/helpers/getDictionaryEntry.d.ts.map +1 -1
- package/dist/provider/helpers/getEntryAndMetadata.d.ts +3 -3
- package/dist/provider/helpers/getEntryAndMetadata.d.ts.map +1 -1
- package/dist/provider/helpers/isValidDictionaryEntry.d.ts +3 -12
- package/dist/provider/helpers/isValidDictionaryEntry.d.ts.map +1 -1
- package/dist/translation/hooks/useDict.d.ts +2 -2
- package/dist/translation/hooks/useDict.d.ts.map +1 -1
- package/dist/translation/hooks/useGT.d.ts +2 -2
- package/dist/translation/hooks/useGT.d.ts.map +1 -1
- package/dist/translation/inline/T.d.ts +13 -15
- package/dist/translation/inline/T.d.ts.map +1 -1
- package/dist/types/providers.d.ts +4 -6
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/types.d.ts +18 -23
- package/dist/types/types.d.ts.map +1 -1
- package/dist/ui/LocaleSelector.d.ts +1 -1
- package/dist/ui/LocaleSelector.d.ts.map +1 -1
- package/dist/utils/utils.d.ts +1 -2
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/variables/Var.d.ts +2 -6
- package/dist/variables/Var.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/hooks/internal/useTranslateContent.d.ts +0 -4
- package/dist/hooks/internal/useTranslateContent.d.ts.map +0 -1
package/dist/internal.d.ts
CHANGED
@@ -2,7 +2,7 @@ import flattenDictionary from './internal/flattenDictionary';
|
|
2
2
|
import addGTIdentifier from './internal/addGTIdentifier';
|
3
3
|
import writeChildrenAsObjects from './internal/writeChildrenAsObjects';
|
4
4
|
import getPluralBranch from './branches/plurals/getPluralBranch';
|
5
|
-
import getDictionaryEntry from './provider/helpers/getDictionaryEntry';
|
5
|
+
import getDictionaryEntry, { isValidDictionaryEntry } from './provider/helpers/getDictionaryEntry';
|
6
6
|
import getEntryAndMetadata from './provider/helpers/getEntryAndMetadata';
|
7
7
|
import getVariableProps from './variables/_getVariableProps';
|
8
8
|
import isVariableObject from './provider/helpers/isVariableObject';
|
@@ -11,7 +11,7 @@ import renderDefaultChildren from './provider/rendering/renderDefaultChildren';
|
|
11
11
|
import renderTranslatedChildren from './provider/rendering/renderTranslatedChildren';
|
12
12
|
import { defaultRenderSettings } from './provider/rendering/defaultRenderSettings';
|
13
13
|
import renderSkeleton from './provider/rendering/renderSkeleton';
|
14
|
-
import { Dictionary, RenderMethod, TranslatedChildren, TranslatedContent, TranslationError, TranslationsObject, DictionaryEntry, TranslationSuccess, TranslationLoading,
|
14
|
+
import { Dictionary, RenderMethod, TranslatedChildren, TranslatedContent, TranslationError, TranslationsObject, DictionaryEntry, TranslationSuccess, TranslationLoading, Children, FlattenedDictionary, Metadata, Child, GTProp, Entry, GTTranslationError, DictionaryTranslationOptions, InlineTranslationOptions, RuntimeTranslationOptions } from './types/types';
|
15
15
|
import { GTContextType, ClientProviderProps } from './types/providers';
|
16
|
-
export { addGTIdentifier, writeChildrenAsObjects, isVariableObject, Dictionary, flattenDictionary, getDictionaryEntry, getVariableProps, DictionaryEntry, FlattenedDictionary,
|
16
|
+
export { addGTIdentifier, writeChildrenAsObjects, isVariableObject, Dictionary, flattenDictionary, getDictionaryEntry, isValidDictionaryEntry, getVariableProps, DictionaryEntry, FlattenedDictionary, GTTranslationError, Metadata, getPluralBranch, getEntryAndMetadata, getVariableName, getFallbackVariableName, renderDefaultChildren, renderTranslatedChildren, renderSkeleton, RenderMethod, defaultRenderSettings, Children, Child, GTProp, Entry, TranslatedChildren, TranslatedContent, TranslationsObject, TranslationLoading, TranslationError, TranslationSuccess, GTContextType, ClientProviderProps, DictionaryTranslationOptions, InlineTranslationOptions, RuntimeTranslationOptions };
|
17
17
|
//# 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,kBAAkB,MAAM,uCAAuC,CAAC;
|
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,kBAAkB,EAAE,EAAE,sBAAsB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,EAC1B,CAAC"}
|
@@ -1 +1 @@
|
|
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}`}const f=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"},v=r=>{return n=r,e.isValidElement(n)?(e=>{const{type:r,props:n}=e;let t={type:f(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]=y(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]=y(r)})),r=Object.assign(Object.assign({},r),{branches:n})}t.props["data-_gt"]=r}return n.children&&(t.props.children=y(n.children)),t})(r):"number"==typeof r?r.toString():r;var n};function y(e){return Array.isArray(e)?e.map(v):v(e)}function h(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 g(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 m(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 O(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 j(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){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function E({children:r,variables:n={},variablesOptions:t={},defaultLocale:a=o,renderVariable:l}){const s=r=>e.isValidElement(r)?(r=>{const o=_(r);if("variable"===(null==o?void 0:o.transformation)){let{variableName:e,variableType:i,variableValue:o,variableOptions:s}=O(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(h(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 w({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=h(e,i,u.branches||{})||r.props.children,s=h(e,i,n.props["data-_gt"].branches||{})||n.props.children;return"number"==typeof e&&void 0===t.n&&(t.n=e),V({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 V({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:V({source:c.children,target:n.props.children,variables:t,variablesOptions:a,locales:i,renderVariable:l})})):E({children:r,variables:t,variablesOptions:a,defaultLocale:i[0],renderVariable:l})}function V({source:r,target:t,variables:a={},variablesOptions:i={},locales:l=[o],renderVariable:s}){if(null==t&&r)return E({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=_(r);if(O(r.props),"variable"!==(null==e?void 0:e.transformation))return!0;{let{variableName:e,variableValue:n,variableOptions:t,variableType:o}=O(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=_(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(j(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:w({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=j(t)?"variable":"element";if(e.isValidElement(r)){if("element"===n)return w({sourceElement:r,targetElement:t,variables:a,variablesOptions:i,locales:l,renderVariable:s});const e=_(r);if("variable"===(null==e?void 0:e.transformation)){let{variableName:e,variableValue:n,variableOptions:t}=O(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 E({children:r,variables:a,variablesOptions:i,defaultLocale:l[0],renderVariable:s})}const A={method:"default",timeout:"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?8e3:12e3};function T(){return""}class k 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{k as GTTranslationError,c as addGTIdentifier,A as defaultRenderSettings,a as flattenDictionary,g as getDictionaryEntry,m as getEntryAndMetadata,d as getFallbackVariableName,h as getPluralBranch,b as getVariableName,O as getVariableProps,j as isVariableObject,E as renderDefaultChildren,T as renderSkeleton,V as renderTranslatedChildren,y as writeChildrenAsObjects};
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import r,{isValidElement as n}from"react";import"generaltranslation";const t=e=>`Duplicate key found in dictionary: "${e}"`;function a(e,r=""){const n={};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(n.hasOwnProperty(o))throw new Error(t(o));n[o]=e[i]}else{const r=a(e[i],o);for(const e in r){if(n.hasOwnProperty(e))throw new Error(t(e));n[e]=r[e]}}}return n}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"];function s(t,a=0){let o=a;const c=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]=s(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]=s(n,o),e)),{});Object.keys(r).length&&(a.branches=r)}a.transformation=r[0]}return a};function u(t){return n(t)?function(n){const{props:t}=n;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.`)(n));let a=c(n),i=Object.assign(Object.assign({},t),{"data-_gt":a});if(t.children&&!a.variableType&&(i.children=d(t.children)),n.type===r.Fragment)return i["data-_gt"].transformation,e("span",Object.assign({style:{all:"unset",display:"contents"}},i));return r.cloneElement(n,i)}(t):t}function d(e){return Array.isArray(e)?r.Children.map(e,u):u(e)}return d(t)}const c={variable:"value",number:"n",datetime:"date",currency:"cost"};function u(e="variable"){return c[e]||"variable"}const d="_gt_";function p(e={},r){var n;if(e.name)return e.name;if(e["data-_gt-variable-name"])return e["data-_gt-variable-name"];return`${d}${c[r]||"value"}_${null===(n=e["data-_gt"])||void 0===n?void 0:n.id}`}const b=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"},f=e=>{return n=e,r.isValidElement(n)?(e=>{const{type:r,props:n}=e;let t={type:b(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:p(n,r),id:e.id}}if("plural"===a&&e.branches){t.type="Plural";let n={};Object.entries(e.branches).forEach((([e,r])=>{n[e]=v(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]=v(r)})),r=Object.assign(Object.assign({},r),{branches:n})}t.props["data-_gt"]=r}return n.children&&(t.props.children=v(n.children)),t})(e):"number"==typeof e?e.toString():e;var n};function v(e){return Array.isArray(e)?e.map(f):f(e)}function y(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 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 g(e,n){let t=e,a=n.split(".");for(const e of a){if("object"!=typeof t||Array.isArray(t)||r.isValidElement(t))return;t=t[e]}return t}function m(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 O(e){var r;const n=(null===(r=e["data-_gt"])||void 0===r?void 0:r.variableType)||"variable";return{variableType:n,variableName:p(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 j(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){return e&&e.props&&e.props["data-_gt"]?e.props["data-_gt"]:null}function w({children:e,variables:n={},variablesOptions:t={},defaultLocale:a=o,renderVariable:l}){const s=e=>r.isValidElement(e)?(e=>{const o=_(e);if("variable"===(null==o?void 0:o.transformation)){let{variableName:r,variableType:i,variableValue:o,variableOptions:s}=O(e.props);return o=(()=>{if(void 0!==n[r])return n[r];if(void 0!==o)return o;if(r.startsWith(d)){const e=u(i);if(void 0!==n[e])return n[e]}})(),s=Object.assign(Object.assign({},t[r]),s),l({variableName:r,variableType:i,variableValue:o,variableOptions:s,locales:[a]})}if("plural"===(null==o?void 0:o.transformation)){const r="number"==typeof n.n?n.n:"number"==typeof e.props.n?e.props.n:e.props["data-_gt-n"];"number"==typeof r&&void 0===n.n&&(n.n=r);const t=o.branches||{};return c(y(r,[a],t)||e.props.children)}if("branch"===(null==o?void 0:o.transformation)){let r=e.props,{children:t,name:a,branch:l,"data-_gt":s}=r,u=i(r,["children","name","branch","data-_gt"]);return a=a||e.props["data-_gt-name"]||"branch",l=n[a]||l||e.props["data-_gt-branch-name"],u=o.branches||{},c(void 0!==u[l]?u[l]:t)}return e.props.children?r.cloneElement(e,Object.assign(Object.assign({},e.props),{"data-_gt":void 0,children:c(e.props.children)})):r.cloneElement(e,Object.assign(Object.assign({},e.props),{"data-_gt":void 0}))})(e):e,c=e=>Array.isArray(e)?r.Children.map(e,s):s(e);return c(e)}function E({sourceElement:e,targetElement:n,variables:t={},variablesOptions:a={},locales:i=[o],renderVariable:l}){var s;const{props:c}=e,u=c["data-_gt"],d=null==u?void 0:u.transformation;if("plural"===d){const r="number"==typeof t.n?t.n:"number"==typeof e.props.n?e.props.n:e.props["data-_gt-n"],o=y(r,i,u.branches||{})||e.props.children,s=y(r,i,n.props["data-_gt"].branches||{})||n.props.children;return"number"==typeof r&&void 0===t.n&&(t.n=r),A({source:o,target:s,variables:t,variablesOptions:a,locales:i,renderVariable:l})}if("branch"===d){let{name:r,branch:o,children:s}=c;r=r||e.props["data-_gt-name"]||"branch",o=t[r]||o||e.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)?r.cloneElement(e,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:e,variables:t,variablesOptions:a,defaultLocale:i[0],renderVariable:l})}function A({source:n,target:t,variables:a={},variablesOptions:i={},locales:l=[o],renderVariable:s}){if(null==t&&n)return w({children:n,variables:a,variablesOptions:i,defaultLocale:l[0],renderVariable:s});if("string"==typeof t)return t;if(Array.isArray(t)&&!Array.isArray(n)&&n&&(n=[n]),Array.isArray(n)&&Array.isArray(t)){const o=n.filter((e=>{if(r.isValidElement(e)){const r=_(e);if(O(e.props),"variable"!==(null==r?void 0:r.transformation))return!0;{let{variableName:r,variableValue:n,variableOptions:t,variableType:o}=O(e.props);void 0===a[r]&&(a[r]=n);const l=u(o);void 0===a[l]&&(a[l]=n),i[r]=Object.assign(Object.assign({},i[r]),t)}}})),c=e=>o.find((r=>{var n,t;const a=_(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(((n,t)=>{if("string"==typeof n)return e(r.Fragment,{children:n},`string_${t}`);if(j(n)){const o=n.key,c=n.variable||"variable",p=(()=>{if(void 0!==a[n.key])return a[n.key];if(o.startsWith(d)){const e=u(c);if(void 0!==a[e])return a[e]}})();return e(r.Fragment,{children:s({variableType:c,variableName:o,variableValue:p,variableOptions:i[n.key],locales:l})},`var_${t}`)}const o=c(n);return o?e(r.Fragment,{children:E({sourceElement:o,targetElement:n,variables:a,variablesOptions:i,locales:l,renderVariable:s})},`element_${t}`):void 0}))}if(t&&"object"==typeof t&&!Array.isArray(t)){const e=j(t)?"variable":"element";if(r.isValidElement(n)){if("element"===e)return E({sourceElement:n,targetElement:t,variables:a,variablesOptions:i,locales:l,renderVariable:s});const r=_(n);if("variable"===(null==r?void 0:r.transformation)){let{variableName:e,variableValue:r,variableOptions:t}=O(n.props);void 0===a[e]&&(a[e]=r),i[e]=Object.assign(Object.assign({},i[e]),t)}}if("variable"===e){const e=t,r=e.key,n=e.variable||"variable",o=(()=>{if(void 0!==a[e.key])return a[e.key];if(r.startsWith(d)){const e=u(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:n,variables:a,variablesOptions:i,defaultLocale:l[0],renderVariable:s})}const V={method:"default",timeout:"undefined"!=typeof process&&"development"!==process.env.NODE_ENV?8e3:1e9};function T(){return""}class k 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{k as GTTranslationError,s as addGTIdentifier,V as defaultRenderSettings,a as flattenDictionary,g as getDictionaryEntry,m as getEntryAndMetadata,u as getFallbackVariableName,y as getPluralBranch,p as getVariableName,O as getVariableProps,h as isValidDictionaryEntry,j as isVariableObject,w as renderDefaultChildren,T as renderSkeleton,A as renderTranslatedChildren,v as writeChildrenAsObjects};
|
@@ -2,7 +2,6 @@ export declare const projectIdMissingError = "gt-react Error: General Translatio
|
|
2
2
|
export declare const devApiKeyProductionError = "gt-react Error: Production environments cannot include a development api key.";
|
3
3
|
export declare const createNoAuthError = "gt-react Error: Configuration is missing a projectId and/or devApiKey. Please add these values to your environment or pass them to the <GTProvider> directly.";
|
4
4
|
export declare const createPluralMissingError: (children: any) => string;
|
5
|
-
export declare const createStringTranslationError: (content: string, id?: string) => string;
|
6
5
|
export declare const createClientSideTDictionaryCollisionError: (id: string) => string;
|
7
6
|
export declare const createClientSideTHydrationError: (id: string) => string;
|
8
7
|
export declare const createNestedDataGTError: (child: any) => string;
|
@@ -13,10 +12,11 @@ export declare const createGenericRuntimeTranslationError: (id: string | undefin
|
|
13
12
|
export declare const dictionaryDisabledError: string;
|
14
13
|
export declare const runtimeTranslationError = "gt-react Error: Runtime translation failed: ";
|
15
14
|
export declare const projectIdMissingWarning = "gt-react warn: Translation cloud services require a project ID! Find yours at generaltranslation.com/dashboard.";
|
16
|
-
export declare const
|
17
|
-
export declare const
|
18
|
-
export declare const
|
15
|
+
export declare const createNoEntryFoundWarning: (id: string) => string;
|
16
|
+
export declare const createInvalidDictionaryEntryWarning: (id: string) => string;
|
17
|
+
export declare const createNoEntryTranslationWarning: (id: string, prefixedId: string) => string;
|
19
18
|
export declare const createMismatchingHashWarning: (expectedHash: string, receivedHash: string) => string;
|
20
19
|
export declare const APIKeyMissingWarn: string;
|
21
20
|
export declare const createUnsupportedLocalesWarning: (locales: string[]) => string;
|
21
|
+
export declare const runtimeTranslationTimeoutWarning = "gt-react: Runtime translation timed out.";
|
22
22
|
//# sourceMappingURL=createMessages.d.ts.map
|
@@ -1 +1 @@
|
|
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,
|
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,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,QAI0G,CAAC;AAE/I,eAAO,MAAM,uBAAuB,iDAAiD,CAAC;AAItF,eAAO,MAAM,uBAAuB,oHAC+E,CAAC;AAEpH,eAAO,MAAM,yBAAyB,OAAQ,MAAM,WACS,CAAC;AAE9D,eAAO,MAAM,mCAAmC,OAAQ,MAAM,WACF,CAAC;AAE7D,eAAO,MAAM,+BAA+B,OACtC,MAAM,cACE,MAAM,WACwD,CAAC;AAE7E,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;AAElB,eAAO,MAAM,gCAAgC,6CAA6C,CAAC"}
|
@@ -1,4 +1,4 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import { ClientProviderProps } from '../types/providers';
|
3
|
-
export default function ClientProvider({ children, dictionary, initialTranslations,
|
3
|
+
export default function ClientProvider({ children, dictionary, initialTranslations, locale: _locale, _versionId, defaultLocale, translationRequired, dialectTranslationRequired, locales, renderSettings, projectId, devApiKey, runtimeUrl, runtimeTranslationEnabled, onLocaleChange, cookieName, }: ClientProviderProps): React.JSX.Element;
|
4
4
|
//# sourceMappingURL=ClientProvider.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"AACA,OAAO,
|
1
|
+
{"version":3,"file":"ClientProvider.d.ts","sourceRoot":"","sources":["../../src/provider/ClientProvider.tsx"],"names":[],"mappings":"AACA,OAAO,KAAmC,MAAM,OAAO,CAAC;AAGxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAQzD,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,cAAyB,EACzB,UAA6B,GAC9B,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAiHzC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAgBlE,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B;;;;;;;;;;;;;;;;;GAiBG;AACH,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,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,CA2PpB"}
|
@@ -1,3 +1,4 @@
|
|
1
|
-
import { Dictionary, DictionaryEntry
|
2
|
-
export
|
1
|
+
import { Dictionary, DictionaryEntry } from '../../types/types';
|
2
|
+
export declare function isValidDictionaryEntry(value: unknown): value is DictionaryEntry;
|
3
|
+
export default function getDictionaryEntry<T extends Dictionary>(dictionary: T, id: string): Dictionary | DictionaryEntry | undefined;
|
3
4
|
//# sourceMappingURL=getDictionaryEntry.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getDictionaryEntry.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/getDictionaryEntry.ts"],"names":[],"mappings":"AACA,OAAO,
|
1
|
+
{"version":3,"file":"getDictionaryEntry.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/getDictionaryEntry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEhE,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,eAAe,CAc1B;AAED,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,CAAC,SAAS,UAAU,EAC7D,UAAU,EAAE,CAAC,EACb,EAAE,EAAE,MAAM,GACT,UAAU,GAAG,eAAe,GAAG,SAAS,CAc1C"}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { DictionaryEntry,
|
2
|
-
export default function getEntryAndMetadata(value: DictionaryEntry
|
3
|
-
entry:
|
1
|
+
import { DictionaryEntry, Metadata } from '../../types/types';
|
2
|
+
export default function getEntryAndMetadata(value: DictionaryEntry): {
|
3
|
+
entry: string;
|
4
4
|
metadata?: Metadata;
|
5
5
|
};
|
6
6
|
//# sourceMappingURL=getEntryAndMetadata.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getEntryAndMetadata.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/getEntryAndMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,
|
1
|
+
{"version":3,"file":"getEntryAndMetadata.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/getEntryAndMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAEf,QAAQ,EACT,MAAM,mBAAmB,CAAC;AAE3B,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,KAAK,EAAE,eAAe,GACrB;IACD,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,CAUA"}
|
@@ -1,16 +1,7 @@
|
|
1
|
-
|
2
|
-
export type Entry = string | ReactElement | ((params: any) => ReactNode);
|
1
|
+
export type Entry = string;
|
3
2
|
export type Metadata = {
|
4
|
-
|
5
|
-
|
6
|
-
zero?: Entry;
|
7
|
-
dual?: Entry;
|
8
|
-
one?: Entry;
|
9
|
-
two?: Entry;
|
10
|
-
few?: Entry;
|
11
|
-
many?: Entry;
|
12
|
-
other?: Entry;
|
13
|
-
variableOptions?: Record<string, any>;
|
3
|
+
context?: string;
|
4
|
+
variablesOptions?: Record<string, any>;
|
14
5
|
[key: string]: any;
|
15
6
|
};
|
16
7
|
export type DictionaryEntry = Entry | [Entry] | [Entry, Metadata];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"isValidDictionaryEntry.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/isValidDictionaryEntry.ts"],"names":[],"mappings":"AAAA,
|
1
|
+
{"version":3,"file":"isValidDictionaryEntry.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/isValidDictionaryEntry.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAElE,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,eAAe,CAAC;CAC7C,CAAC"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import {
|
2
|
+
import { DictionaryTranslationOptions } from '../../types/types';
|
3
3
|
/**
|
4
4
|
* Gets the dictionary access function `d` provided by `<GTProvider>`.
|
5
5
|
*
|
@@ -13,5 +13,5 @@ import { TranslationOptions } from '../../types/types';
|
|
13
13
|
* const d = useDict();
|
14
14
|
* console.log(d('hello')); // Translates item 'hello'
|
15
15
|
*/
|
16
|
-
export default function useDict(id
|
16
|
+
export default function useDict(id: string): (id: string, options?: DictionaryTranslationOptions) => React.ReactNode;
|
17
17
|
//# sourceMappingURL=useDict.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useDict.d.ts","sourceRoot":"","sources":["../../../src/translation/hooks/useDict.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"useDict.d.ts","sourceRoot":"","sources":["../../../src/translation/hooks/useDict.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AAEjE;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAC7B,EAAE,EAAE,MAAM,GACT,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,4BAA4B,KAAK,KAAK,CAAC,SAAS,CAqCzE"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { InlineTranslationOptions } from '../../types/types';
|
2
2
|
/**
|
3
3
|
* Gets the translation function `t` provided by `<GTProvider>`.
|
4
4
|
*
|
@@ -16,5 +16,5 @@ import { TranslationOptions } from '../../types/types';
|
|
16
16
|
* </>);
|
17
17
|
*
|
18
18
|
*/
|
19
|
-
export default function useGT(): (
|
19
|
+
export default function useGT(): (string: string, options?: InlineTranslationOptions) => string;
|
20
20
|
//# sourceMappingURL=useGT.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../../src/translation/hooks/useGT.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"useGT.d.ts","sourceRoot":"","sources":["../../../src/translation/hooks/useGT.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,aAWjB,MAAM,YACL,wBAAwB,KAChC,MAAM,CAKV"}
|
@@ -1,36 +1,34 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
/**
|
3
|
-
*
|
4
|
-
* Used with the required `id` parameter instead of `const t = useGT()`.
|
5
|
-
*
|
6
|
-
* @param {string} [id] - Required identifier for the translation string.
|
7
|
-
* @param {React.ReactNode} children - The content to be translated or displayed.
|
8
|
-
* @param {any} [context] - Additional context used for translation.
|
9
|
-
* @param {Object} [props] - Additional props for the component.
|
10
|
-
* @returns {JSX.Element} The rendered translation or fallback content based on the provided configuration.
|
11
|
-
*
|
12
|
-
* @throws {Error} If a plural translation is requested but the `n` option is not provided.
|
3
|
+
* Build-time translation component that renders its children in the user's given locale.
|
13
4
|
*
|
14
5
|
* @example
|
15
6
|
* ```jsx
|
16
7
|
* // Basic usage:
|
17
8
|
* <T id="welcome_message">
|
18
|
-
* Hello, <Var name="name"
|
9
|
+
* Hello, <Var name="name" value={firstname}>!
|
19
10
|
* </T>
|
20
11
|
* ```
|
21
12
|
*
|
22
13
|
* @example
|
23
14
|
* ```jsx
|
24
|
-
* //
|
15
|
+
* // Translating a plural
|
25
16
|
* <T id="item_count">
|
26
|
-
* <Plural n={
|
27
|
-
* You have <Num value={n}/> items
|
17
|
+
* <Plural n={3} singular={<>You have <Num value={n}/> item.</>}>
|
18
|
+
* You have <Num value={n}/> items.
|
28
19
|
* </Plural>
|
29
20
|
* </T>
|
30
21
|
* ```
|
31
22
|
*
|
23
|
+
* @param {React.ReactNode} children - The content to be translated or displayed.
|
24
|
+
* @param {string} [id] - Optional identifier for the translation string. If not provided, a hash will be generated from the content.
|
25
|
+
* @param {any} [context] - Additional context for translation key generation.
|
26
|
+
*
|
27
|
+
* @returns {JSX.Element} The rendered translation or fallback content based on the provided configuration.
|
28
|
+
*
|
29
|
+
* @throws {Error} If a plural translation is requested but the `n` option is not provided.
|
32
30
|
*/
|
33
|
-
declare function T({ children, id,
|
31
|
+
declare function T({ children, id, context }: {
|
34
32
|
children: any;
|
35
33
|
id?: string;
|
36
34
|
context?: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"T.d.ts","sourceRoot":"","sources":["../../../src/translation/inline/T.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAWzC
|
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,EACR,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,SAAS,CAwHhC;kBAjIQ,CAAC;;;AAqIV,eAAe,CAAC,CAAC"}
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import { TranslationsObject, RenderMethod,
|
1
|
+
import { TranslationsObject, RenderMethod, InlineTranslationOptions, DictionaryTranslationOptions, Dictionary } from './types';
|
2
2
|
import { TranslateContentCallback, TranslateChildrenCallback } from './runtime';
|
3
3
|
export type GTContextType = {
|
4
4
|
registerContentForTranslation: TranslateContentCallback;
|
5
5
|
registerJsxForTranslation: TranslateChildrenCallback;
|
6
|
-
|
7
|
-
|
6
|
+
_internalUseGTFunction: (string: string, options?: InlineTranslationOptions) => string;
|
7
|
+
_internalUseDictFunction: (id: string, options?: DictionaryTranslationOptions) => string;
|
8
8
|
runtimeTranslationEnabled: boolean;
|
9
9
|
locale: string;
|
10
10
|
locales: string[];
|
@@ -21,9 +21,8 @@ export type GTContextType = {
|
|
21
21
|
};
|
22
22
|
export type ClientProviderProps = {
|
23
23
|
children: any;
|
24
|
-
dictionary:
|
24
|
+
dictionary: Dictionary;
|
25
25
|
initialTranslations: TranslationsObject;
|
26
|
-
translationPromises: Record<string, Promise<TranslatedChildren>>;
|
27
26
|
locale: string;
|
28
27
|
locales: string[];
|
29
28
|
_versionId?: string;
|
@@ -31,7 +30,6 @@ export type ClientProviderProps = {
|
|
31
30
|
defaultLocale: string;
|
32
31
|
translationRequired: boolean;
|
33
32
|
dialectTranslationRequired: boolean;
|
34
|
-
requiredPrefix: string | undefined;
|
35
33
|
renderSettings: {
|
36
34
|
method: RenderMethod;
|
37
35
|
timeout?: number;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/types/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/types/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EAEZ,wBAAwB,EACxB,4BAA4B,EAC5B,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAEh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,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC"}
|
package/dist/types/types.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import
|
1
|
+
import { Content } from 'generaltranslation/internal';
|
2
|
+
import React from 'react';
|
2
3
|
export type Child = React.ReactNode;
|
3
4
|
export type Children = Child[] | Child;
|
4
5
|
export type GTProp = {
|
@@ -12,25 +13,14 @@ export type TaggedElementProps = Record<string, any> & {
|
|
12
13
|
'data-_gt': GTProp;
|
13
14
|
};
|
14
15
|
export type TaggedElement = React.ReactElement<TaggedElementProps>;
|
15
|
-
export type TaggedEntry =
|
16
|
-
export type
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
};
|
23
|
-
export type Entry = string | ReactElement;
|
16
|
+
export type TaggedEntry = Content | TaggedChildren;
|
17
|
+
export type FlattenedContentDictionary = Record<string, {
|
18
|
+
hash: string;
|
19
|
+
source: Content;
|
20
|
+
metadata?: Record<string, any>;
|
21
|
+
}>;
|
22
|
+
export type Entry = string;
|
24
23
|
export type Metadata = {
|
25
|
-
singular?: Entry;
|
26
|
-
plural?: Entry;
|
27
|
-
zero?: Entry;
|
28
|
-
dual?: Entry;
|
29
|
-
one?: Entry;
|
30
|
-
two?: Entry;
|
31
|
-
few?: Entry;
|
32
|
-
many?: Entry;
|
33
|
-
other?: Entry;
|
34
24
|
context?: string;
|
35
25
|
variablesOptions?: Record<string, any>;
|
36
26
|
[key: string]: any;
|
@@ -79,12 +69,17 @@ export type LocalesTranslations = {
|
|
79
69
|
[locale: string]: TranslationsObject | null;
|
80
70
|
};
|
81
71
|
export type RenderMethod = 'skeleton' | 'replace' | 'default';
|
82
|
-
export type
|
83
|
-
context?: string;
|
72
|
+
export type DictionaryTranslationOptions = {
|
84
73
|
variables?: Record<string, any>;
|
85
|
-
|
86
|
-
[key: string]: any;
|
74
|
+
variablesOptions?: Record<string, Intl.NumberFormatOptions | Intl.DateTimeFormatOptions>;
|
87
75
|
};
|
76
|
+
export type InlineTranslationOptions = {
|
77
|
+
context?: string;
|
78
|
+
id?: string;
|
79
|
+
} & DictionaryTranslationOptions;
|
80
|
+
export type RuntimeTranslationOptions = {
|
81
|
+
locale?: string;
|
82
|
+
} & InlineTranslationOptions;
|
88
83
|
export declare class GTTranslationError extends Error {
|
89
84
|
error: string;
|
90
85
|
code: number;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAuB,MAAM,OAAO,CAAC;AAE5C,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC;AACpC,MAAM,MAAM,QAAQ,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC;AACvC,MAAM,MAAM,MAAM,GAAG;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAExB,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,SAAS,GAAG,aAAa,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,WAAW,EAAE,GAAG,WAAW,CAAC;AACzD,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9E,MAAM,MAAM,aAAa,GAA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4BAA4B,CAAC;AACjC,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,wBAAwB,CAAC;AAE7B,qBAAa,kBAAmB,SAAQ,KAAK;IAElC,KAAK,EAAE,MAAM;IACb,IAAI,EAAE,MAAM;gBADZ,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM;IAMrB,kBAAkB,IAAI,gBAAgB;CAOvC"}
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
4
4
|
* @param {string[]} locales - The list of supported locales. By default this is the user's list of supported locales from the `<GTProvider>` context.
|
5
5
|
* @returns {React.ReactElement | null} The rendered locale dropdown component or null to prevent rendering.
|
6
6
|
*/
|
7
|
-
export default function LocaleSelector({ locales, }: {
|
7
|
+
export default function LocaleSelector({ locales, ...props }: {
|
8
8
|
locales?: string[];
|
9
9
|
}): React.ReactElement | null;
|
10
10
|
//# sourceMappingURL=LocaleSelector.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"LocaleSelector.d.ts","sourceRoot":"","sources":["../../src/ui/LocaleSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAoB1B;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,OAA6B,
|
1
|
+
{"version":3,"file":"LocaleSelector.d.ts","sourceRoot":"","sources":["../../src/ui/LocaleSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAoB1B;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,OAA6B,EAC7B,GAAG,KAAK,EACT,EAAE;IACD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CA6B5B"}
|
package/dist/utils/utils.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import { TaggedElement
|
2
|
-
export declare function isTranslatedContent(target: unknown): target is TranslatedContent;
|
1
|
+
import { TaggedElement } from '../types/types';
|
3
2
|
export declare function isValidTaggedElement(target: unknown): target is TaggedElement;
|
4
3
|
export declare function readAuthFromEnv(projectId?: string, devApiKey?: string): {
|
5
4
|
projectId: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAEd,MAAM,gBAAgB,CAAC;AAExB,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,aAAa,CAE7E;AAED,wBAAgB,eAAe,CAC7B,SAAS,CAAC,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CA6BA"}
|
package/dist/variables/Var.d.ts
CHANGED
@@ -18,13 +18,9 @@ import React from 'react';
|
|
18
18
|
*
|
19
19
|
* @example Dictionary Usage:
|
20
20
|
* ```jsx
|
21
|
-
* // dictionary.
|
21
|
+
* // dictionary.js
|
22
22
|
* const dictionary = {
|
23
|
-
* user:
|
24
|
-
* <>
|
25
|
-
* Hello, <Var name="user-name" />! Your dog's name is <Var name="dog-name"/>.
|
26
|
-
* </>
|
27
|
-
* ),
|
23
|
+
* user: "Hello {user-name}! Your dog's name is {dog-name}",
|
28
24
|
* }
|
29
25
|
*
|
30
26
|
* // component.jsx
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Var.d.ts","sourceRoot":"","sources":["../../src/variables/Var.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B
|
1
|
+
{"version":3,"file":"Var.d.ts","sourceRoot":"","sources":["../../src/variables/Var.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,iBAAS,GAAG,CAAC,EACX,QAAQ,EACR,IAAI,EACJ,KAAK,GACN,EAAE;IACD,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,GAAG,CAAC;CACb,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAYpB;kBApBQ,GAAG;;;AAwBZ,eAAe,GAAG,CAAC"}
|
package/package.json
CHANGED
@@ -1,4 +0,0 @@
|
|
1
|
-
import { TranslationOptions, TranslationsObject } from '../../types/types';
|
2
|
-
import { TranslateContentCallback } from '../../types/runtime';
|
3
|
-
export default function useTranslateContent(translations: TranslationsObject | null, locale: string, defaultLocale: string, translationRequired: boolean, runtimeTranslationEnabled: boolean, registerContentForTranslation: TranslateContentCallback): (content: string, options?: TranslationOptions) => string;
|
4
|
-
//# sourceMappingURL=useTranslateContent.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"useTranslateContent.d.ts","sourceRoot":"","sources":["../../../src/hooks/internal/useTranslateContent.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,CAAC,OAAO,UAAU,mBAAmB,CACzC,YAAY,EAAE,kBAAkB,GAAG,IAAI,EACvC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,OAAO,EAC5B,yBAAyB,EAAE,OAAO,EAClC,6BAA6B,EAAE,wBAAwB,GACtD,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,KAAK,MAAM,CAmF3D"}
|