@tolgee/react 5.27.1 → 5.28.1-prerelease.5080c26e.0
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/createServerInstance.d.ts +1 -1
- package/dist/tolgee-react-server.cjs.js +1 -1
- package/dist/tolgee-react-server.cjs.js.map +1 -1
- package/dist/tolgee-react-server.cjs.min.js +1 -1
- package/dist/tolgee-react-server.cjs.min.js.map +1 -1
- package/dist/tolgee-react-server.esm.js +1 -1
- package/dist/tolgee-react-server.esm.js.map +1 -1
- package/dist/tolgee-react-server.esm.min.js +1 -1
- package/dist/tolgee-react-server.esm.min.js.map +1 -1
- package/dist/tolgee-react-server.esm.min.mjs +1 -1
- package/dist/tolgee-react-server.esm.min.mjs.map +1 -1
- package/dist/tolgee-react-server.esm.mjs +1 -1
- package/dist/tolgee-react-server.esm.mjs.map +1 -1
- package/dist/tolgee-react-server.umd.js +1 -1
- package/dist/tolgee-react-server.umd.js.map +1 -1
- package/dist/tolgee-react-server.umd.min.js +1 -1
- package/dist/tolgee-react-server.umd.min.js.map +1 -1
- package/lib/createServerInstance.d.ts +1 -1
- package/package.json +7 -7
- package/src/createServerInstance.tsx +2 -2
- package/src/.DS_Store +0 -0
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { TolgeeInstance } from '@tolgee/web';
|
|
5
5
|
export type CreateServerInstanceOptions = {
|
|
6
6
|
createTolgee: (locale: string) => Promise<TolgeeInstance>;
|
|
7
|
-
getLocale: () => string
|
|
7
|
+
getLocale: () => Promise<string>;
|
|
8
8
|
};
|
|
9
9
|
export declare const createServerInstance: ({ createTolgee, getLocale, }: CreateServerInstanceOptions) => {
|
|
10
10
|
getTolgeeInstance: (locale: string) => Promise<TolgeeInstance>;
|
|
@@ -70,7 +70,7 @@ const createServerInstance = ({ createTolgee, getLocale, }) => {
|
|
|
70
70
|
return tolgee;
|
|
71
71
|
});
|
|
72
72
|
const getTolgee = async () => {
|
|
73
|
-
const locale = getLocale();
|
|
73
|
+
const locale = await getLocale();
|
|
74
74
|
const tolgee = await getTolgeeInstance(locale);
|
|
75
75
|
return tolgee;
|
|
76
76
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tolgee-react-server.cjs.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => string
|
|
1
|
+
{"version":3,"file":"tolgee-react-server.cjs.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => Promise<string>;\n};\n\nexport const createServerInstance = ({\n createTolgee,\n getLocale,\n}: CreateServerInstanceOptions) => {\n const getTolgeeInstance = cache(async (locale: string) => {\n const tolgee = await createTolgee(locale);\n await tolgee.run();\n return tolgee;\n }) as (locale: string) => Promise<TolgeeInstance>;\n\n const getTolgee = async () => {\n const locale = await getLocale();\n const tolgee = await getTolgeeInstance(locale);\n return tolgee;\n };\n\n const getTranslate = async () => {\n const tolgee = await getTolgee();\n return tolgee.t;\n };\n\n async function T(props: TProps) {\n const t = await getTranslate();\n return <TBase t={t as TFnType<ParamsTags>} {...props} />;\n }\n\n return { getTolgeeInstance, getTolgee, getTranslate, T };\n};\n"],"names":["React","cache"],"mappings":";;;;;;;;;;;AAKO,MAAM,eAAe,GAAG,CAC7B,MAA+C,KAC7C;IACF,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,SAAS,CAAC;AAClB,KAAA;IAED,MAAM,MAAM,GAAQ,EAAE,CAAC;AAEvB,IAAA,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AACpD,QAAA,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,YAAA,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAU,KAAI;AAC3B,gBAAA,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AACpC,aAAC,CAAC;AACH,SAAA;AAAM,aAAA,IAAIA,yBAAK,CAAC,cAAc,CAAC,KAAY,CAAC,EAAE;YAC7C,MAAM,EAAE,GAAG,KAA2B,CAAC;AACvC,YAAA,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAU,KAAI;AAC3B,gBAAA,OAAO,EAAE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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@tolgee/web");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("@tolgee/web");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=n(e);const r=e=>{if(!e)return;const t={};return Object.entries(e||{}).forEach((([e,n])=>{if("function"==typeof n)t[e]=e=>n(o(e));else if(a.default.isValidElement(n)){const r=n;t[e]=e=>void 0===r.props.children&&(null==e?void 0:e.length)?a.default.cloneElement(r,{},o(e)):a.default.cloneElement(r)}else t[e]=n})),t},o=e=>Array.isArray(e)?a.default.Children.toArray(e):e,l=e=>{const t=e.keyName||e.children;void 0===t&&console.error("T component: keyName not defined");const n=e.defaultValue||(e.keyName?e.children:void 0),l=o(e.t({key:t,params:r(e.params),defaultValue:n,noWrap:e.noWrap,ns:e.ns,language:e.language}));return a.default.createElement(a.default.Fragment,null,l)};exports.TBase=l,exports.createServerInstance=({createTolgee:t,getLocale:n})=>{const r=e.cache((async e=>{const n=await t(e);return await n.run(),n})),o=async()=>{const e=await n();return await r(e)},c=async()=>(await o()).t;return{getTolgeeInstance:r,getTolgee:o,getTranslate:c,T:async function(e){const t=await c();return a.default.createElement(l,Object.assign({t:t},e))}}},Object.keys(t).forEach((function(e){"default"===e||exports.hasOwnProperty(e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})}));
|
|
2
2
|
//# sourceMappingURL=tolgee-react-server.cjs.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tolgee-react-server.cjs.min.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => string
|
|
1
|
+
{"version":3,"file":"tolgee-react-server.cjs.min.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => Promise<string>;\n};\n\nexport const createServerInstance = ({\n createTolgee,\n getLocale,\n}: CreateServerInstanceOptions) => {\n const getTolgeeInstance = cache(async (locale: string) => {\n const tolgee = await createTolgee(locale);\n await tolgee.run();\n return tolgee;\n }) as (locale: string) => Promise<TolgeeInstance>;\n\n const getTolgee = async () => {\n const locale = await getLocale();\n const tolgee = await getTolgeeInstance(locale);\n return tolgee;\n };\n\n const getTranslate = async () => {\n const tolgee = await getTolgee();\n return tolgee.t;\n };\n\n async function T(props: TProps) {\n const t = await getTranslate();\n return <TBase t={t as TFnType<ParamsTags>} {...props} />;\n }\n\n return { getTolgeeInstance, getTolgee, getTranslate, T };\n};\n"],"names":["wrapTagHandlers","params","result","Object","entries","forEach","key","value","chunk","addReactKeys","React","isValidElement","el","undefined","props","children","length","cloneElement","val","Array","isArray","Children","toArray","TBase","keyName","console","error","defaultValue","translation","t","noWrap","ns","language","createElement","Fragment","createTolgee","getLocale","getTolgeeInstance","cache","async","locale","tolgee","run","getTolgee","getTranslate","T","assign"],"mappings":"uMAKO,MAAMA,EACXC,IAEA,IAAKA,EACH,OAGF,MAAMC,EAAc,CAAA,EAmBpB,OAjBAC,OAAOC,QAAQH,GAAU,CAAE,GAAEI,SAAQ,EAAEC,EAAKC,MAC1C,GAAqB,mBAAVA,EACTL,EAAOI,GAAQE,GACND,EAAME,EAAaD,SAEvB,GAAIE,EAAK,QAACC,eAAeJ,GAAe,CAC7C,MAAMK,EAAKL,EACXL,EAAOI,GAAQE,QACgBK,IAAtBD,EAAGE,MAAMC,WAA0BP,aAAK,EAALA,EAAOQ,QAC7CN,EAAK,QAACO,aAAaL,EAAI,CAAE,EAAEH,EAAaD,IACxCE,UAAMO,aAAaL,EAE1B,MACCV,EAAOI,GAAOC,CACf,IAGIL,CAAM,EAGFO,EACXS,GAEIC,MAAMC,QAAQF,GACTR,UAAMW,SAASC,QAAQJ,GAEvBA,ECpCEK,EAAyBT,IACpC,MAAMR,EAAOQ,EAA2BU,SAAWV,EAAMC,cAC7CF,IAARP,GAEFmB,QAAQC,MAAM,oCAEhB,MAAMC,EACJb,EAAMa,eACJb,EAA2BU,QAAUV,EAAMC,cAAWF,GAEpDe,EAAcnB,EAClBK,EAAMe,EAAE,CACNvB,IAAKA,EACLL,OAAQD,EAAgBc,EAAMb,QAC9B0B,eACAG,OAAQhB,EAAMgB,OACdC,GAAIjB,EAAMiB,GACVC,SAAUlB,EAAMkB,YAIpB,OAAOtB,EAAAA,QAAAuB,cAAAvB,EAAAA,QAAAwB,SAAA,KAAGN,EAAe,+CCXS,EAClCO,eACAC,gBAEA,MAAMC,EAAoBC,SAAMC,MAAOC,IACrC,MAAMC,QAAeN,EAAaK,GAElC,aADMC,EAAOC,MACND,CAAM,IAGTE,EAAYJ,UAChB,MAAMC,QAAeJ,IAErB,aADqBC,EAAkBG,EAC1B,EAGTI,EAAeL,gBACEI,KACPd,EAQhB,MAAO,CAAEQ,oBAAmBM,YAAWC,eAAcC,EALrDN,eAAiBzB,GACf,MAAMe,QAAUe,IAChB,OAAOlC,UAAAuB,cAACV,EAAMpB,OAAA2C,OAAA,CAAAjB,EAAGA,GAA8Bf,GAChD,EAEuD"}
|
|
@@ -62,7 +62,7 @@ const createServerInstance = ({ createTolgee, getLocale, }) => {
|
|
|
62
62
|
return tolgee;
|
|
63
63
|
});
|
|
64
64
|
const getTolgee = async () => {
|
|
65
|
-
const locale = getLocale();
|
|
65
|
+
const locale = await getLocale();
|
|
66
66
|
const tolgee = await getTolgeeInstance(locale);
|
|
67
67
|
return tolgee;
|
|
68
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tolgee-react-server.esm.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => string
|
|
1
|
+
{"version":3,"file":"tolgee-react-server.esm.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => Promise<string>;\n};\n\nexport const createServerInstance = ({\n createTolgee,\n getLocale,\n}: CreateServerInstanceOptions) => {\n const getTolgeeInstance = cache(async (locale: string) => {\n const tolgee = await createTolgee(locale);\n await tolgee.run();\n return tolgee;\n }) as (locale: string) => Promise<TolgeeInstance>;\n\n const getTolgee = async () => {\n const locale = await getLocale();\n const tolgee = await getTolgeeInstance(locale);\n return tolgee;\n };\n\n const getTranslate = async () => {\n const tolgee = await getTolgee();\n return tolgee.t;\n };\n\n async function T(props: TProps) {\n const t = await getTranslate();\n return <TBase t={t as TFnType<ParamsTags>} {...props} />;\n }\n\n return { getTolgeeInstance, getTolgee, getTranslate, T };\n};\n"],"names":[],"mappings":";;;AAKO,MAAM,eAAe,GAAG,CAC7B,MAA+C,KAC7C;IACF,IAAI,C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C,QAAA,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC/C,QAAA,OAAO,MAAM,CAAC;AAChB,KAAC,CAAC;AAEF,IAAA,MAAM,YAAY,GAAG,YAAW;AAC9B,QAAA,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,CAAC,CAAC;AAClB,KAAC,CAAC;IAEF,eAAe,CAAC,CAAC,KAAa,EAAA;AAC5B,QAAA,MAAM,CAAC,GAAG,MAAM,YAAY,EAAE,CAAC;QAC/B,OAAO,KAAA,CAAA,aAAA,CAAC,KAAK,EAAC,MAAA,CAAA,MAAA,CAAA,EAAA,CAAC,EAAE,CAAwB,EAAA,EAAM,KAAK,CAAA,CAAI,CAAC;KAC1D;IAED,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;AAC3D;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{cache as
|
|
1
|
+
import e,{cache as t}from"react";export*from"@tolgee/web";const n=t=>{if(!t)return;const n={};return Object.entries(t||{}).forEach((([t,r])=>{if("function"==typeof r)n[t]=e=>r(a(e));else if(e.isValidElement(r)){const o=r;n[t]=t=>void 0===o.props.children&&(null==t?void 0:t.length)?e.cloneElement(o,{},a(t)):e.cloneElement(o)}else n[t]=r})),n},a=t=>Array.isArray(t)?e.Children.toArray(t):t,r=t=>{const r=t.keyName||t.children;void 0===r&&console.error("T component: keyName not defined");const o=t.defaultValue||(t.keyName?t.children:void 0),l=a(t.t({key:r,params:n(t.params),defaultValue:o,noWrap:t.noWrap,ns:t.ns,language:t.language}));return e.createElement(e.Fragment,null,l)},o=({createTolgee:n,getLocale:a})=>{const o=t((async e=>{const t=await n(e);return await t.run(),t})),l=async()=>{const e=await a();return await o(e)},c=async()=>(await l()).t;return{getTolgeeInstance:o,getTolgee:l,getTranslate:c,T:async function(t){const n=await c();return e.createElement(r,Object.assign({t:n},t))}}};export{r as TBase,o as createServerInstance};
|
|
2
2
|
//# sourceMappingURL=tolgee-react-server.esm.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tolgee-react-server.esm.min.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => string
|
|
1
|
+
{"version":3,"file":"tolgee-react-server.esm.min.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => Promise<string>;\n};\n\nexport const createServerInstance = ({\n createTolgee,\n getLocale,\n}: CreateServerInstanceOptions) => {\n const getTolgeeInstance = cache(async (locale: string) => {\n const tolgee = await createTolgee(locale);\n await tolgee.run();\n return tolgee;\n }) as (locale: string) => Promise<TolgeeInstance>;\n\n const getTolgee = async () => {\n const locale = await getLocale();\n const tolgee = await getTolgeeInstance(locale);\n return tolgee;\n };\n\n const getTranslate = async () => {\n const tolgee = await getTolgee();\n return tolgee.t;\n };\n\n async function T(props: TProps) {\n const t = await getTranslate();\n return <TBase t={t as TFnType<ParamsTags>} {...props} />;\n }\n\n return { getTolgeeInstance, getTolgee, getTranslate, T };\n};\n"],"names":["wrapTagHandlers","params","result","Object","entries","forEach","key","value","chunk","addReactKeys","React","isValidElement","el","undefined","props","children","length","cloneElement","val","Array","isArray","Children","toArray","TBase","keyName","console","error","defaultValue","translation","t","noWrap","ns","language","createElement","Fragment","createServerInstance","createTolgee","getLocale","getTolgeeInstance","cache","async","locale","tolgee","run","getTolgee","getTranslate","T","assign"],"mappings":"0DAKO,MAAMA,EACXC,IAEA,IAAKA,EACH,OAGF,MAAMC,EAAc,CAAA,EAmBpB,OAjBAC,OAAOC,QAAQH,GAAU,CAAE,GAAEI,SAAQ,EAAEC,EAAKC,MAC1C,GAAqB,mBAAVA,EACTL,EAAOI,GAAQE,GACND,EAAME,EAAaD,SAEvB,GAAIE,EAAMC,eAAeJ,GAAe,CAC7C,MAAMK,EAAKL,EACXL,EAAOI,GAAQE,QACgBK,IAAtBD,EAAGE,MAAMC,WAA0BP,aAAK,EAALA,EAAOQ,QAC7CN,EAAMO,aAAaL,EAAI,CAAE,EAAEH,EAAaD,IACxCE,EAAMO,aAAaL,EAE1B,MACCV,EAAOI,GAAOC,CACf,IAGIL,CAAM,EAGFO,EACXS,GAEIC,MAAMC,QAAQF,GACTR,EAAMW,SAASC,QAAQJ,GAEvBA,ECpCEK,EAAyBT,IACpC,MAAMR,EAAOQ,EAA2BU,SAAWV,EAAMC,cAC7CF,IAARP,GAEFmB,QAAQC,MAAM,oCAEhB,MAAMC,EACJb,EAAMa,eACJb,EAA2BU,QAAUV,EAAMC,cAAWF,GAEpDe,EAAcnB,EAClBK,EAAMe,EAAE,CACNvB,IAAKA,EACLL,OAAQD,EAAgBc,EAAMb,QAC9B0B,eACAG,OAAQhB,EAAMgB,OACdC,GAAIjB,EAAMiB,GACVC,SAAUlB,EAAMkB,YAIpB,OAAOtB,EAAAuB,cAAAvB,EAAAwB,SAAA,KAAGN,EAAe,ECXdO,EAAuB,EAClCC,eACAC,gBAEA,MAAMC,EAAoBC,GAAMC,MAAOC,IACrC,MAAMC,QAAeN,EAAaK,GAElC,aADMC,EAAOC,MACND,CAAM,IAGTE,EAAYJ,UAChB,MAAMC,QAAeJ,IAErB,aADqBC,EAAkBG,EAC1B,EAGTI,EAAeL,gBACEI,KACPf,EAQhB,MAAO,CAAES,oBAAmBM,YAAWC,eAAcC,EALrDN,eAAiB1B,GACf,MAAMe,QAAUgB,IAChB,OAAOnC,EAAAuB,cAACV,EAAMpB,OAAA4C,OAAA,CAAAlB,EAAGA,GAA8Bf,GAChD,EAEuD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{cache as
|
|
1
|
+
import e,{cache as t}from"react";export*from"@tolgee/web";const n=t=>{if(!t)return;const n={};return Object.entries(t||{}).forEach((([t,r])=>{if("function"==typeof r)n[t]=e=>r(a(e));else if(e.isValidElement(r)){const o=r;n[t]=t=>void 0===o.props.children&&(null==t?void 0:t.length)?e.cloneElement(o,{},a(t)):e.cloneElement(o)}else n[t]=r})),n},a=t=>Array.isArray(t)?e.Children.toArray(t):t,r=t=>{const r=t.keyName||t.children;void 0===r&&console.error("T component: keyName not defined");const o=t.defaultValue||(t.keyName?t.children:void 0),l=a(t.t({key:r,params:n(t.params),defaultValue:o,noWrap:t.noWrap,ns:t.ns,language:t.language}));return e.createElement(e.Fragment,null,l)},o=({createTolgee:n,getLocale:a})=>{const o=t((async e=>{const t=await n(e);return await t.run(),t})),l=async()=>{const e=await a();return await o(e)},c=async()=>(await l()).t;return{getTolgeeInstance:o,getTolgee:l,getTranslate:c,T:async function(t){const n=await c();return e.createElement(r,Object.assign({t:n},t))}}};export{r as TBase,o as createServerInstance};
|
|
2
2
|
//# sourceMappingURL=tolgee-react-server.esm.min.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tolgee-react-server.esm.min.mjs","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => string
|
|
1
|
+
{"version":3,"file":"tolgee-react-server.esm.min.mjs","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => Promise<string>;\n};\n\nexport const createServerInstance = ({\n createTolgee,\n getLocale,\n}: CreateServerInstanceOptions) => {\n const getTolgeeInstance = cache(async (locale: string) => {\n const tolgee = await createTolgee(locale);\n await tolgee.run();\n return tolgee;\n }) as (locale: string) => Promise<TolgeeInstance>;\n\n const getTolgee = async () => {\n const locale = await getLocale();\n const tolgee = await getTolgeeInstance(locale);\n return tolgee;\n };\n\n const getTranslate = async () => {\n const tolgee = await getTolgee();\n return tolgee.t;\n };\n\n async function T(props: TProps) {\n const t = await getTranslate();\n return <TBase t={t as TFnType<ParamsTags>} {...props} />;\n }\n\n return { getTolgeeInstance, getTolgee, getTranslate, T };\n};\n"],"names":["wrapTagHandlers","params","result","Object","entries","forEach","key","value","chunk","addReactKeys","React","isValidElement","el","undefined","props","children","length","cloneElement","val","Array","isArray","Children","toArray","TBase","keyName","console","error","defaultValue","translation","t","noWrap","ns","language","createElement","Fragment","createServerInstance","createTolgee","getLocale","getTolgeeInstance","cache","async","locale","tolgee","run","getTolgee","getTranslate","T","assign"],"mappings":"0DAKO,MAAMA,EACXC,IAEA,IAAKA,EACH,OAGF,MAAMC,EAAc,CAAA,EAmBpB,OAjBAC,OAAOC,QAAQH,GAAU,CAAE,GAAEI,SAAQ,EAAEC,EAAKC,MAC1C,GAAqB,mBAAVA,EACTL,EAAOI,GAAQE,GACND,EAAME,EAAaD,SAEvB,GAAIE,EAAMC,eAAeJ,GAAe,CAC7C,MAAMK,EAAKL,EACXL,EAAOI,GAAQE,QACgBK,IAAtBD,EAAGE,MAAMC,WAA0BP,aAAK,EAALA,EAAOQ,QAC7CN,EAAMO,aAAaL,EAAI,CAAE,EAAEH,EAAaD,IACxCE,EAAMO,aAAaL,EAE1B,MACCV,EAAOI,GAAOC,CACf,IAGIL,CAAM,EAGFO,EACXS,GAEIC,MAAMC,QAAQF,GACTR,EAAMW,SAASC,QAAQJ,GAEvBA,ECpCEK,EAAyBT,IACpC,MAAMR,EAAOQ,EAA2BU,SAAWV,EAAMC,cAC7CF,IAARP,GAEFmB,QAAQC,MAAM,oCAEhB,MAAMC,EACJb,EAAMa,eACJb,EAA2BU,QAAUV,EAAMC,cAAWF,GAEpDe,EAAcnB,EAClBK,EAAMe,EAAE,CACNvB,IAAKA,EACLL,OAAQD,EAAgBc,EAAMb,QAC9B0B,eACAG,OAAQhB,EAAMgB,OACdC,GAAIjB,EAAMiB,GACVC,SAAUlB,EAAMkB,YAIpB,OAAOtB,EAAAuB,cAAAvB,EAAAwB,SAAA,KAAGN,EAAe,ECXdO,EAAuB,EAClCC,eACAC,gBAEA,MAAMC,EAAoBC,GAAMC,MAAOC,IACrC,MAAMC,QAAeN,EAAaK,GAElC,aADMC,EAAOC,MACND,CAAM,IAGTE,EAAYJ,UAChB,MAAMC,QAAeJ,IAErB,aADqBC,EAAkBG,EAC1B,EAGTI,EAAeL,gBACEI,KACPf,EAQhB,MAAO,CAAES,oBAAmBM,YAAWC,eAAcC,EALrDN,eAAiB1B,GACf,MAAMe,QAAUgB,IAChB,OAAOnC,EAAAuB,cAACV,EAAMpB,OAAA4C,OAAA,CAAAlB,EAAGA,GAA8Bf,GAChD,EAEuD"}
|
|
@@ -62,7 +62,7 @@ const createServerInstance = ({ createTolgee, getLocale, }) => {
|
|
|
62
62
|
return tolgee;
|
|
63
63
|
});
|
|
64
64
|
const getTolgee = async () => {
|
|
65
|
-
const locale = getLocale();
|
|
65
|
+
const locale = await getLocale();
|
|
66
66
|
const tolgee = await getTolgeeInstance(locale);
|
|
67
67
|
return tolgee;
|
|
68
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tolgee-react-server.esm.mjs","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => string
|
|
1
|
+
{"version":3,"file":"tolgee-react-server.esm.mjs","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => Promise<string>;\n};\n\nexport const createServerInstance = ({\n createTolgee,\n getLocale,\n}: CreateServerInstanceOptions) => {\n const getTolgeeInstance = cache(async (locale: string) => {\n const tolgee = await createTolgee(locale);\n await tolgee.run();\n return tolgee;\n }) as (locale: string) => Promise<TolgeeInstance>;\n\n const getTolgee = async () => {\n const locale = await getLocale();\n const tolgee = await getTolgeeInstance(locale);\n return tolgee;\n };\n\n const getTranslate = async () => {\n const tolgee = await getTolgee();\n return tolgee.t;\n };\n\n async function T(props: TProps) {\n const t = await getTranslate();\n return <TBase t={t as TFnType<ParamsTags>} {...props} />;\n }\n\n return { getTolgeeInstance, getTolgee, getTranslate, T };\n};\n"],"names":[],"mappings":";;;AAKO,MAAM,eAAe,GAAG,CAC7B,MAA+C,KAC7C;IACF,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,SAAS,CAAC;AAClB,KAAA;IAED,MAAM,MAAM,GAAQ,EAAE,CAAC;AAEvB,IAAA,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;AACpD,QAAA,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;AAC/B,YAAA,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAU,KAAI;AAC3B,gBAAA,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;AACpC,aAAC,CAAC;AACH,SAAA;AAAM,aAAA,IAAI,KAAK,CAAC,cAAc,CAAC,KAAY,CAAC,EAAE;YAC7C,MAAM,EAAE,GAAG,KAA2B,CAAC;AACvC,YAAA,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAU,KAAI;AAC3B,gBAAA,OAAO,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,KAAI,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,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A,CAAC,CACH,CAAC;IAEF,OAAO,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAG,WAAW,CAAI,CAAC;AAC5B;;AC1BA;AAca,MAAA,oBAAoB,GAAG,CAAC,EACnC,YAAY,EACZ,SAAS,GACmB,KAAI;IAChC,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,MAAc,KAAI;AACvD,QAAA,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;AAC1C,QAAA,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;AACnB,QAAA,OAAO,MAAM,CAAC;AAChB,KAAC,CAAgD,CAAC;AAElD,IAAA,MAAM,SAAS,GAAG,YAAW;AAC3B,QAAA,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;AACjC,QAAA,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC/C,QAAA,OAAO,MAAM,CAAC;AAChB,KAAC,CAAC;AAEF,IAAA,MAAM,YAAY,GAAG,YAAW;AAC9B,QAAA,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,CAAC,CAAC;AAClB,KAAC,CAAC;IAEF,eAAe,CAAC,CAAC,KAAa,EAAA;AAC5B,QAAA,MAAM,CAAC,GAAG,MAAM,YAAY,EAAE,CAAC;QAC/B,OAAO,KAAA,CAAA,aAAA,CAAC,KAAK,EAAC,MAAA,CAAA,MAAA,CAAA,EAAA,CAAC,EAAE,CAAwB,EAAA,EAAM,KAAK,CAAA,CAAI,CAAC;KAC1D;IAED,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;AAC3D;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tolgee-react-server.umd.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => string
|
|
1
|
+
{"version":3,"file":"tolgee-react-server.umd.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => Promise<string>;\n};\n\nexport const createServerInstance = ({\n createTolgee,\n getLocale,\n}: CreateServerInstanceOptions) => {\n const getTolgeeInstance = cache(async (locale: string) => {\n const tolgee = await createTolgee(locale);\n await tolgee.run();\n return tolgee;\n }) as (locale: string) => Promise<TolgeeInstance>;\n\n const getTolgee = async () => {\n const locale = await getLocale();\n const tolgee = await getTolgeeInstance(locale);\n return tolgee;\n };\n\n const getTranslate = async () => {\n const tolgee = await getTolgee();\n return tolgee.t;\n };\n\n async function T(props: TProps) {\n const t = await getTranslate();\n return <TBase t={t as TFnType<ParamsTags>} {...props} />;\n }\n\n return { getTolgeeInstance, getTolgee, getTranslate, T };\n};\n"],"names":["React","cache"],"mappings":";;;;;;;;;;IAKO,MAAM,eAAe,GAAG,CAC7B,MAA+C,KAC7C;QACF,IAAI,CAAC,MAAM,EAAE;IACX,QAAA,OAAO,SAAS,CAAC;IAClB,KAAA;QAED,MAAM,MAAM,GAAQ,EAAE,CAAC;IAEvB,IAAA,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,KAAI;IACpD,QAAA,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;IAC/B,YAAA,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAU,KAAI;IAC3B,gBAAA,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC;IACpC,aAAC,CAAC;IACH,SAAA;IAAM,aAAA,IAAIA,yBAAK,CAAC,cAAc,CAAC,KAAY,CAAC,EAAE;gBAC7C,MAAM,EAAE,GAAG,KAA2B,CAAC;IACvC,YAAA,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,KAAU,KAAI;IAC3B,gBAAA,OAAO,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,SAAS,KAAI,KAAK,aAAL,KAAK,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAL,KAAK,CAAE,MAAM,CAAA;IACrD,sBAAEA,yBAAK,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACjD,sBAAEA,yBAAK,CAAC,YAAY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AA,oBAAoB,GAAG,CAAC,EACnC,YAAY,EACZ,SAAS,GACmB,KAAI;QAChC,MAAM,iBAAiB,GAAGC,WAAK,CAAC,OAAO,MAAc,KAAI;IACvD,QAAA,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAA,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;IACnB,QAAA,OAAO,MAAM,CAAC;IAChB,KAAC,CAAgD,CAAC;IAElD,IAAA,MAAM,SAAS,GAAG,YAAW;IAC3B,QAAA,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,QAAA,MAAM,MAAM,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC/C,QAAA,OAAO,MAAM,CAAC;IAChB,KAAC,CAAC;IAEF,IAAA,MAAM,YAAY,GAAG,YAAW;IAC9B,QAAA,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;YACjC,OAAO,MAAM,CAAC,CAAC,CAAC;IAClB,KAAC,CAAC;QAEF,eAAe,CAAC,CAAC,KAAa,EAAA;IAC5B,QAAA,MAAM,CAAC,GAAG,MAAM,YAAY,EAAE,CAAC;YAC/B,OAAOD,yBAAA,CAAA,aAAA,CAAC,KAAK,EAAC,MAAA,CAAA,MAAA,CAAA,EAAA,CAAC,EAAE,CAAwB,EAAA,EAAM,KAAK,CAAA,CAAI,CAAC;SAC1D;QAED,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC,EAAE,CAAC;IAC3D;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@tolgee/web")):"function"==typeof define&&define.amd?define(["exports","react","@tolgee/web"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/react"]={},e.React,e["@tolgee/web"])}(this,(function(e,t,n){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=a(t);const o=e=>{if(!e)return;const t={};return Object.entries(e||{}).forEach((([e,n])=>{if("function"==typeof n)t[e]=e=>n(l(e));else if(r.default.isValidElement(n)){const a=n;t[e]=e=>void 0===a.props.children&&(null==e?void 0:e.length)?r.default.cloneElement(a,{},l(e)):r.default.cloneElement(a)}else t[e]=n})),t},l=e=>Array.isArray(e)?r.default.Children.toArray(e):e,c=e=>{const t=e.keyName||e.children;void 0===t&&console.error("T component: keyName not defined");const n=e.defaultValue||(e.keyName?e.children:void 0),a=l(e.t({key:t,params:o(e.params),defaultValue:n,noWrap:e.noWrap,ns:e.ns,language:e.language}));return r.default.createElement(r.default.Fragment,null,a)};e.TBase=c,e.createServerInstance=({createTolgee:e,getLocale:n})=>{const a=t.cache((async t=>{const n=await e(t);return await n.run(),n})),o=async()=>{const e=n();return await a(e)},l=async()=>(await o()).t;return{getTolgeeInstance:a,getTolgee:o,getTranslate:l,T:async function(e){const t=await l();return r.default.createElement(c,Object.assign({t:t},e))}}},Object.keys(n).forEach((function(t){"default"===t||e.hasOwnProperty(t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@tolgee/web")):"function"==typeof define&&define.amd?define(["exports","react","@tolgee/web"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["@tolgee/react"]={},e.React,e["@tolgee/web"])}(this,(function(e,t,n){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=a(t);const o=e=>{if(!e)return;const t={};return Object.entries(e||{}).forEach((([e,n])=>{if("function"==typeof n)t[e]=e=>n(l(e));else if(r.default.isValidElement(n)){const a=n;t[e]=e=>void 0===a.props.children&&(null==e?void 0:e.length)?r.default.cloneElement(a,{},l(e)):r.default.cloneElement(a)}else t[e]=n})),t},l=e=>Array.isArray(e)?r.default.Children.toArray(e):e,c=e=>{const t=e.keyName||e.children;void 0===t&&console.error("T component: keyName not defined");const n=e.defaultValue||(e.keyName?e.children:void 0),a=l(e.t({key:t,params:o(e.params),defaultValue:n,noWrap:e.noWrap,ns:e.ns,language:e.language}));return r.default.createElement(r.default.Fragment,null,a)};e.TBase=c,e.createServerInstance=({createTolgee:e,getLocale:n})=>{const a=t.cache((async t=>{const n=await e(t);return await n.run(),n})),o=async()=>{const e=await n();return await a(e)},l=async()=>(await o()).t;return{getTolgeeInstance:a,getTolgee:o,getTranslate:l,T:async function(e){const t=await l();return r.default.createElement(c,Object.assign({t:t},e))}}},Object.keys(n).forEach((function(t){"default"===t||e.hasOwnProperty(t)||Object.defineProperty(e,t,{enumerable:!0,get:function(){return n[t]}})})),Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
2
2
|
//# sourceMappingURL=tolgee-react-server.umd.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tolgee-react-server.umd.min.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => string
|
|
1
|
+
{"version":3,"file":"tolgee-react-server.umd.min.js","sources":["../src/tagsTools.tsx","../src/TBase.tsx","../src/createServerInstance.tsx"],"sourcesContent":["import { TranslateParams } from '@tolgee/web';\nimport React from 'react';\n\nimport { ParamsTags } from './types';\n\nexport const wrapTagHandlers = (\n params: TranslateParams<ParamsTags> | undefined\n) => {\n if (!params) {\n return undefined;\n }\n\n const result: any = {};\n\n Object.entries(params || {}).forEach(([key, value]) => {\n if (typeof value === 'function') {\n result[key] = (chunk: any) => {\n return value(addReactKeys(chunk));\n };\n } else if (React.isValidElement(value as any)) {\n const el = value as React.ReactElement;\n result[key] = (chunk: any) => {\n return el.props.children === undefined && chunk?.length\n ? React.cloneElement(el, {}, addReactKeys(chunk))\n : React.cloneElement(el);\n };\n } else {\n result[key] = value;\n }\n });\n\n return result;\n};\n\nexport const addReactKeys = (\n val: React.ReactNode | React.ReactNode[] | undefined\n) => {\n if (Array.isArray(val)) {\n return React.Children.toArray(val);\n } else {\n return val;\n }\n};\n","import React from 'react';\nimport { addReactKeys, wrapTagHandlers } from './tagsTools';\nimport type { PropsWithKeyName, TBaseInterface } from './types';\n\nexport const TBase: TBaseInterface = (props) => {\n const key = (props as PropsWithKeyName).keyName || props.children;\n if (key === undefined) {\n // eslint-disable-next-line no-console\n console.error('T component: keyName not defined');\n }\n const defaultValue =\n props.defaultValue ||\n ((props as PropsWithKeyName).keyName ? props.children : undefined);\n\n const translation = addReactKeys(\n props.t({\n key: key!,\n params: wrapTagHandlers(props.params),\n defaultValue,\n noWrap: props.noWrap,\n ns: props.ns,\n language: props.language,\n })\n );\n\n return <>{translation}</>;\n};\n","// @ts-ignore\nimport { cache } from 'react';\nimport { TFnType } from '@tolgee/web';\n\nimport { TBase } from './TBase';\nimport { TProps, ParamsTags } from './types';\nimport React from 'react';\nimport { TolgeeInstance } from '@tolgee/web';\n\nexport type CreateServerInstanceOptions = {\n createTolgee: (locale: string) => Promise<TolgeeInstance>;\n getLocale: () => Promise<string>;\n};\n\nexport const createServerInstance = ({\n createTolgee,\n getLocale,\n}: CreateServerInstanceOptions) => {\n const getTolgeeInstance = cache(async (locale: string) => {\n const tolgee = await createTolgee(locale);\n await tolgee.run();\n return tolgee;\n }) as (locale: string) => Promise<TolgeeInstance>;\n\n const getTolgee = async () => {\n const locale = await getLocale();\n const tolgee = await getTolgeeInstance(locale);\n return tolgee;\n };\n\n const getTranslate = async () => {\n const tolgee = await getTolgee();\n return tolgee.t;\n };\n\n async function T(props: TProps) {\n const t = await getTranslate();\n return <TBase t={t as TFnType<ParamsTags>} {...props} />;\n }\n\n return { getTolgeeInstance, getTolgee, getTranslate, T };\n};\n"],"names":["wrapTagHandlers","params","result","Object","entries","forEach","key","value","chunk","addReactKeys","React","isValidElement","el","undefined","props","children","length","cloneElement","val","Array","isArray","Children","toArray","TBase","keyName","console","error","defaultValue","translation","t","noWrap","ns","language","createElement","Fragment","createTolgee","getLocale","getTolgeeInstance","cache","async","locale","tolgee","run","getTolgee","getTranslate","T","assign"],"mappings":"saAKO,MAAMA,EACXC,IAEA,IAAKA,EACH,OAGF,M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,EAAGA,GAA8Bf,GAChD,EAEuD"}
|
|
@@ -4,7 +4,7 @@ import React from 'react';
|
|
|
4
4
|
import { TolgeeInstance } from '@tolgee/web';
|
|
5
5
|
export type CreateServerInstanceOptions = {
|
|
6
6
|
createTolgee: (locale: string) => Promise<TolgeeInstance>;
|
|
7
|
-
getLocale: () => string
|
|
7
|
+
getLocale: () => Promise<string>;
|
|
8
8
|
};
|
|
9
9
|
export declare const createServerInstance: ({ createTolgee, getLocale, }: CreateServerInstanceOptions) => {
|
|
10
10
|
getTolgeeInstance: (locale: string) => Promise<TolgeeInstance>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolgee/react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.28.1-prerelease.5080c26e.0",
|
|
4
4
|
"description": "React implementation for Tolgee localization framework",
|
|
5
5
|
"main": "./dist/tolgee-react.cjs.js",
|
|
6
6
|
"module": "./dist/tolgee-react.esm.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"react": "^16.14.0 || ^17.0.1 || ^18.1.0"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@tolgee/web": "5.
|
|
41
|
+
"@tolgee/web": "5.28.1-prerelease.5080c26e.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@rollup/plugin-node-resolve": "^14.1.0",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@testing-library/dom": "^8.7.2",
|
|
47
47
|
"@testing-library/jest-dom": "^5.11.4",
|
|
48
48
|
"@testing-library/react": "^14.0.0",
|
|
49
|
-
"@tolgee/format-icu": "5.
|
|
50
|
-
"@tolgee/testing": "5.
|
|
49
|
+
"@tolgee/format-icu": "5.28.1-prerelease.5080c26e.0",
|
|
50
|
+
"@tolgee/testing": "5.28.1-prerelease.5080c26e.0",
|
|
51
51
|
"@types/jest": "^27.0.2",
|
|
52
52
|
"@types/node": "^17.0.8",
|
|
53
53
|
"@types/react": "^18.2.42",
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"jest": "~27.5.1",
|
|
58
58
|
"jest-environment-jsdom": "~27.5.1",
|
|
59
59
|
"jest-fetch-mock": "^3.0.3",
|
|
60
|
-
"react": "^18.
|
|
61
|
-
"react-dom": "^18.
|
|
60
|
+
"react": "^18.3.1",
|
|
61
|
+
"react-dom": "^18.3.1",
|
|
62
62
|
"reflect-metadata": "^0.1.13",
|
|
63
63
|
"regenerator-runtime": "^0.13.3",
|
|
64
64
|
"rollup": "2.78.1",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
90
|
"sideEffects": false,
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "fdec933a3fb711a076214bfae886bdee201f13d3"
|
|
92
92
|
}
|
|
@@ -9,7 +9,7 @@ import { TolgeeInstance } from '@tolgee/web';
|
|
|
9
9
|
|
|
10
10
|
export type CreateServerInstanceOptions = {
|
|
11
11
|
createTolgee: (locale: string) => Promise<TolgeeInstance>;
|
|
12
|
-
getLocale: () => string
|
|
12
|
+
getLocale: () => Promise<string>;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export const createServerInstance = ({
|
|
@@ -23,7 +23,7 @@ export const createServerInstance = ({
|
|
|
23
23
|
}) as (locale: string) => Promise<TolgeeInstance>;
|
|
24
24
|
|
|
25
25
|
const getTolgee = async () => {
|
|
26
|
-
const locale = getLocale();
|
|
26
|
+
const locale = await getLocale();
|
|
27
27
|
const tolgee = await getTolgeeInstance(locale);
|
|
28
28
|
return tolgee;
|
|
29
29
|
};
|
package/src/.DS_Store
DELETED
|
Binary file
|