gt-react 9.2.17-alpha.1 → 9.2.17-alpha.3
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 +8 -12
- package/dist/client.esm.min.mjs +3 -3
- package/dist/errors/createErrors.d.ts +1 -1
- package/dist/errors/createErrors.d.ts.map +1 -1
- package/dist/hooks/internal/useCreateInternalUseDictFunction.d.ts +3 -14
- package/dist/hooks/internal/useCreateInternalUseDictFunction.d.ts.map +1 -1
- package/dist/index.cjs.min.cjs +3 -3
- package/dist/index.esm.min.mjs +3 -3
- package/dist/internal/flattenDictionary.d.ts +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/provider/ClientProvider.d.ts +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/helpers/getDictionaryEntry.d.ts +1 -1
- package/dist/provider/helpers/getDictionaryEntry.d.ts.map +1 -1
- package/dist/provider/helpers/getEntryAndMetadata.d.ts +1 -2
- package/dist/provider/helpers/getEntryAndMetadata.d.ts.map +1 -1
- package/dist/provider/helpers/isValidDictionaryEntry.d.ts +11 -0
- package/dist/provider/helpers/isValidDictionaryEntry.d.ts.map +1 -0
- package/dist/provider/helpers/loadDictionaryHelper.d.ts +1 -2
- package/dist/provider/helpers/loadDictionaryHelper.d.ts.map +1 -1
- package/dist/provider/helpers/mergeDictionaries.d.ts +3 -0
- package/dist/provider/helpers/mergeDictionaries.d.ts.map +1 -0
- package/dist/types/providers.d.ts +2 -3
- package/dist/types/providers.d.ts.map +1 -1
- package/dist/types/types.d.ts +22 -0
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/types/dictionary.d.ts +0 -17
- package/dist/types/dictionary.d.ts.map +0 -1
package/dist/internal.d.ts
CHANGED
@@ -11,9 +11,9 @@ 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 { RenderMethod, TranslatedChildren, TranslatedContent, TranslationError, TranslationsObject, TranslationSuccess, TranslationLoading, Children, Metadata, Child, GTProp, GTTranslationError, DictionaryTranslationOptions, InlineTranslationOptions, RuntimeTranslationOptions, CustomLoader, RenderVariable, VariableProps } from './types/types';
|
14
|
+
import { Dictionary, RenderMethod, TranslatedChildren, TranslatedContent, TranslationError, TranslationsObject, DictionaryEntry, TranslationSuccess, TranslationLoading, Children, FlattenedDictionary, Metadata, Child, GTProp, Entry, GTTranslationError, DictionaryTranslationOptions, InlineTranslationOptions, RuntimeTranslationOptions, LocalesDictionary, DictionaryContent, DictionaryObject, CustomLoader, RenderVariable, VariableProps } from './types/types';
|
15
15
|
import { GTContextType, ClientProviderProps } from './types/providers';
|
16
16
|
import { defaultLocaleCookieName } from './utils/cookies';
|
17
|
-
import
|
18
|
-
export { addGTIdentifier, writeChildrenAsObjects, isVariableObject, Dictionary, flattenDictionary, getDictionaryEntry, isValidDictionaryEntry, getVariableProps, DictionaryEntry, GTTranslationError, Metadata, getPluralBranch, getEntryAndMetadata, getVariableName, renderDefaultChildren, renderTranslatedChildren, renderSkeleton, RenderMethod, defaultRenderSettings, Children, Child, GTProp, Entry, TranslatedChildren, TranslatedContent, TranslationsObject, TranslationLoading, TranslationError, TranslationSuccess, GTContextType, ClientProviderProps, DictionaryTranslationOptions, InlineTranslationOptions, RuntimeTranslationOptions, DictionaryContent, DictionaryObject, CustomLoader, RenderVariable, VariableProps, defaultLocaleCookieName,
|
17
|
+
import mergeDictionaries from './provider/helpers/mergeDictionaries';
|
18
|
+
export { addGTIdentifier, writeChildrenAsObjects, isVariableObject, Dictionary, flattenDictionary, getDictionaryEntry, isValidDictionaryEntry, getVariableProps, DictionaryEntry, FlattenedDictionary, GTTranslationError, Metadata, getPluralBranch, getEntryAndMetadata, getVariableName, renderDefaultChildren, renderTranslatedChildren, renderSkeleton, RenderMethod, defaultRenderSettings, Children, Child, GTProp, Entry, TranslatedChildren, TranslatedContent, TranslationsObject, TranslationLoading, TranslationError, TranslationSuccess, GTContextType, ClientProviderProps, DictionaryTranslationOptions, InlineTranslationOptions, RuntimeTranslationOptions, DictionaryContent, DictionaryObject, LocalesDictionary, CustomLoader, RenderVariable, VariableProps, defaultLocaleCookieName, mergeDictionaries, };
|
19
19
|
//# 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,EAAE,EACzB,sBAAsB,EACvB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,mBAAmB,MAAM,wCAAwC,CAAC;AACzE,OAAO,gBAAgB,MAAM,+BAA+B,CAAC;AAC7D,OAAO,gBAAgB,MAAM,qCAAqC,CAAC;AACnE,OAAO,eAAe,MAAM,6BAA6B,CAAC;AAC1D,OAAO,qBAAqB,MAAM,4CAA4C,CAAC;AAC/E,OAAO,wBAAwB,MAAM,+CAA+C,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AACnF,OAAO,cAAc,MAAM,qCAAqC,CAAC;AACjE,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,iBAAi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,wBAAwB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,aAAa,EACd,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AAErE,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,qBAAqB,EACrB,wBAAwB,EACxB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,QAAQ,EACR,KAAK,EACL,MAAM,EACN,KAAK,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,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"generaltranslation";import e,{isValidElement as r}from"react";import{jsx as t}from"react/jsx-runtime";const n=e=>`gt-react: Error: 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;let n,o={id:a};try{n="function"==typeof r&&r.gtTransformation||""}catch(e){n=""}if(n){const r=n.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]&&(o.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&&(o.branches=e)}if("branch"===r[0]){const e=i(t,["children","branch"]),r=Object.entries(e).reduce(((e,[r,t])=>(e[r]=c(t,a),e)),{});Object.keys(r).length&&(o.branches=r)}o.transformation=r[0]}return o};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));let 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;let 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";let 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";let 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 h(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 y(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,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(h(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:h(e,n,c.branches||{})||r.props.children,target:h(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;{let{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";export{T as GTTranslationError,c as addGTIdentifier,k as defaultLocaleCookieName,A as defaultRenderSettings,a as flattenDictionary,v as getDictionaryEntry,g as getEntryAndMetadata,h as getPluralBranch,d as getVariableName,m as getVariableProps,y as isValidDictionaryEntry,O as isVariableObject,_ 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(t,n=0){let a=n;const o=e=>{const{type:r,props:t}=e;a+=1;let n,o={id:a};try{n="function"==typeof r&&r.gtTransformation||""}catch(e){n=""}if(n){const r=n.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]&&(o.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&&(o.branches=e)}if("branch"===r[0]){const e=i(t,["children","branch"]),r=Object.entries(e).reduce(((e,[r,t])=>(e[r]=c(t,a),e)),{});Object.keys(r).length&&(o.branches=r)}o.transformation=r[0]}return o};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));let 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;let 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";let 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";let 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,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;{let{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,4 +1,4 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { ClientProviderProps } from '../types/providers';
|
3
|
-
export default function ClientProvider({ children,
|
3
|
+
export default function ClientProvider({ children, dictionary, initialTranslations, locale: _locale, _versionId, defaultLocale, translationRequired, dialectTranslationRequired, locales, renderSettings, projectId, devApiKey, runtimeUrl, runtimeTranslationEnabled, resetLocaleCookieName, localeCookieName, }: 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,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAQzD,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EACrC,QAAQ,EACR,
|
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,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,qBAAqB,EACrB,gBAA0C,GAC3C,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA8HzC"}
|
@@ -22,7 +22,7 @@ import { CustomLoader, RenderMethod, TranslationsObject } from '../types/types';
|
|
22
22
|
*
|
23
23
|
* @returns {JSX.Element} The provider component for General Translation context.
|
24
24
|
*/
|
25
|
-
export default function GTProvider({ children, projectId: _projectId, devApiKey: _devApiKey, dictionary, locales, defaultLocale, locale: _locale, cacheUrl, runtimeUrl, renderSettings, loadDictionary, loadTranslations, fallback, ssr, localeCookieName, translations: _translations, _versionId, ...metadata }: {
|
25
|
+
export default function GTProvider({ children, projectId: _projectId, devApiKey: _devApiKey, dictionary: _dictionary, locales, defaultLocale, locale: _locale, cacheUrl, runtimeUrl, renderSettings, loadDictionary, loadTranslations, fallback, ssr, localeCookieName, translations: _translations, _versionId, ...metadata }: {
|
26
26
|
children?: React.ReactNode;
|
27
27
|
projectId?: string;
|
28
28
|
devApiKey?: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"GTProvider.d.ts","sourceRoot":"","sources":["../../src/provider/GTProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAO5D,OAAO,EACL,YAAY,EAGZ,YAAY,EACZ,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AA6BxB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CA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
export declare function isValidDictionaryEntry(value: unknown): value is DictionaryEntry;
|
3
3
|
export default function getDictionaryEntry<T extends Dictionary>(dictionary: T, id: string): Dictionary | DictionaryEntry | undefined;
|
4
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,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,
|
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,5 +1,4 @@
|
|
1
|
-
import { Metadata } from '../../types/types';
|
2
|
-
import { DictionaryEntry } from '../../types/dictionary';
|
1
|
+
import { DictionaryEntry, Metadata } from '../../types/types';
|
3
2
|
export default function getEntryAndMetadata(value: DictionaryEntry): {
|
4
3
|
entry: string;
|
5
4
|
metadata?: Metadata;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"getEntryAndMetadata.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/getEntryAndMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,
|
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"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export type Entry = string;
|
2
|
+
export type Metadata = {
|
3
|
+
context?: string;
|
4
|
+
variablesOptions?: Record<string, any>;
|
5
|
+
[key: string]: any;
|
6
|
+
};
|
7
|
+
export type DictionaryEntry = Entry | [Entry] | [Entry, Metadata];
|
8
|
+
export type Dictionary = {
|
9
|
+
[key: string]: Dictionary | DictionaryEntry;
|
10
|
+
};
|
11
|
+
//# sourceMappingURL=isValidDictionaryEntry.d.ts.map
|
@@ -0,0 +1 @@
|
|
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,4 +1,3 @@
|
|
1
|
-
import { Dictionary } from '../../types/
|
2
|
-
import { CustomLoader } from '../../types/types';
|
1
|
+
import { CustomLoader, Dictionary } from '../../types/types';
|
3
2
|
export default function loadDictionaryHelper(locale: string, loadDictionary: CustomLoader): Promise<Dictionary | undefined>;
|
4
3
|
//# sourceMappingURL=loadDictionaryHelper.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"loadDictionaryHelper.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/loadDictionaryHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"loadDictionaryHelper.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/loadDictionaryHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE7D,wBAA8B,oBAAoB,CAChD,MAAM,EAAE,MAAM,EACd,cAAc,EAAE,YAAY,GAC3B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAmBjC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"mergeDictionaries.d.ts","sourceRoot":"","sources":["../../../src/provider/helpers/mergeDictionaries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAQ/C,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,uBAAuB,EAAE,UAAU,EACnC,gBAAgB,EAAE,UAAU,GAC3B,UAAU,CAkCZ"}
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import { TranslationsObject, RenderMethod, InlineTranslationOptions, DictionaryTranslationOptions } from './types';
|
2
|
-
import { Dictionaries } from './dictionary';
|
1
|
+
import { TranslationsObject, RenderMethod, InlineTranslationOptions, DictionaryTranslationOptions, Dictionary } from './types';
|
3
2
|
import { TranslateContentCallback, TranslateChildrenCallback } from './runtime';
|
4
3
|
export type GTContextType = {
|
5
4
|
registerContentForTranslation: TranslateContentCallback;
|
@@ -22,7 +21,7 @@ export type GTContextType = {
|
|
22
21
|
};
|
23
22
|
export type ClientProviderProps = {
|
24
23
|
children: any;
|
25
|
-
|
24
|
+
dictionary: Dictionary;
|
26
25
|
initialTranslations: TranslationsObject;
|
27
26
|
locale: string;
|
28
27
|
locales: string[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/types/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,wBAAwB,EACxB,4BAA4B,
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/types/providers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,wBAAwB,EACxB,4BAA4B,EAC5B,UAAU,EAEX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAEhF,MAAM,MAAM,aAAa,GAAG;IAC1B,6BAA6B,EAAE,wBAAwB,CAAC;IACxD,yBAAyB,EAAE,yBAAyB,CAAC;IACrD,sBAAsB,EAAE,CACtB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,KAC/B,MAAM,CAAC;IACZ,wBAAwB,EAAE,CACxB,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,kBAAkB,GAAG,IAAI,CAAC;IACxC,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;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,GAAG,CAAC;IACd,UAAU,EAAE,UAAU,CAAC;IACvB,mBAAmB,EAAE,kBAAkB,CAAC;IACxC,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;CAC/B,CAAC"}
|
package/dist/types/types.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Content } from 'generaltranslation/internal';
|
1
2
|
import React from 'react';
|
2
3
|
export type Child = React.ReactNode;
|
3
4
|
export type Children = Child[] | Child;
|
@@ -12,11 +13,25 @@ export type TaggedElementProps = Record<string, any> & {
|
|
12
13
|
'data-_gt': GTProp;
|
13
14
|
};
|
14
15
|
export type TaggedElement = React.ReactElement<TaggedElementProps>;
|
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;
|
15
23
|
export type Metadata = {
|
16
24
|
context?: string;
|
17
25
|
variablesOptions?: Record<string, any>;
|
18
26
|
[key: string]: any;
|
19
27
|
};
|
28
|
+
export type DictionaryEntry = Entry | [Entry] | [Entry, Metadata];
|
29
|
+
export type Dictionary = {
|
30
|
+
[key: string]: Dictionary | DictionaryEntry;
|
31
|
+
};
|
32
|
+
export type FlattenedDictionary = {
|
33
|
+
[key: string]: DictionaryEntry;
|
34
|
+
};
|
20
35
|
export type Variable = {
|
21
36
|
key: string;
|
22
37
|
id?: number;
|
@@ -53,6 +68,13 @@ export type TranslationsObject = {
|
|
53
68
|
export type LocalesTranslations = {
|
54
69
|
[locale: string]: TranslationsObject | null;
|
55
70
|
};
|
71
|
+
export type DictionaryContent = string;
|
72
|
+
export type DictionaryObject = {
|
73
|
+
[id: string]: DictionaryContent;
|
74
|
+
};
|
75
|
+
export type LocalesDictionary = {
|
76
|
+
[locale: string]: DictionaryObject;
|
77
|
+
};
|
56
78
|
export type CustomLoader = (locale: string) => Promise<any>;
|
57
79
|
export type RenderMethod = 'skeleton' | 'replace' | 'default';
|
58
80
|
export type DictionaryTranslationOptions = {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"
|
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,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,CAAC,OAAO,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "gt-react",
|
3
|
-
"version": "9.2.17-alpha.
|
3
|
+
"version": "9.2.17-alpha.3",
|
4
4
|
"description": "A React library for automatic internationalization.",
|
5
5
|
"main": "./dist/index.cjs.min.cjs",
|
6
6
|
"module": "./dist/index.esm.min.mjs",
|
@@ -11,7 +11,7 @@
|
|
11
11
|
},
|
12
12
|
"dependencies": {
|
13
13
|
"@generaltranslation/supported-locales": "^2.0.7",
|
14
|
-
"generaltranslation": "^6.2.
|
14
|
+
"generaltranslation": "^6.2.3"
|
15
15
|
},
|
16
16
|
"scripts": {
|
17
17
|
"patch": "npm version patch",
|
@@ -26,12 +26,12 @@
|
|
26
26
|
},
|
27
27
|
"repository": {
|
28
28
|
"type": "git",
|
29
|
-
"url": "git+https://github.com/
|
29
|
+
"url": "git+https://github.com/generaltranslation/gt.git"
|
30
30
|
},
|
31
31
|
"author": "General Translation, Inc.",
|
32
32
|
"license": "FSL-1.1-ALv2",
|
33
33
|
"bugs": {
|
34
|
-
"url": "https://github.com/
|
34
|
+
"url": "https://github.com/generaltranslation/gt/issues"
|
35
35
|
},
|
36
36
|
"homepage": "https://generaltranslation.com/",
|
37
37
|
"devDependencies": {
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import { Metadata } from './types';
|
2
|
-
export type DictionaryContent = string;
|
3
|
-
export type DictionaryObject = {
|
4
|
-
[id: string]: DictionaryContent;
|
5
|
-
};
|
6
|
-
export type Entry = string;
|
7
|
-
export type DictionaryEntry = Entry | [Entry] | [Entry, Metadata];
|
8
|
-
export type Dictionary = {
|
9
|
-
[key: string]: Dictionary | DictionaryEntry;
|
10
|
-
};
|
11
|
-
export type FlattenedDictionary = {
|
12
|
-
[key: string]: DictionaryEntry;
|
13
|
-
};
|
14
|
-
export type Dictionaries = {
|
15
|
-
[locale: string]: FlattenedDictionary;
|
16
|
-
};
|
17
|
-
//# sourceMappingURL=dictionary.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"dictionary.d.ts","sourceRoot":"","sources":["../../src/types/dictionary.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAGvC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,EAAE,EAAE,MAAM,GAAG,iBAAiB,CAAC;CACjC,CAAC;AAGF,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAG3B,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAGlE,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,eAAe,CAAC;CAC7C,CAAC;AAGF,MAAM,MAAM,mBAAmB,GAAG;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC;CAChC,CAAC;AAGF,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB,CAAC;CACvC,CAAC"}
|