@tachybase/plugin-i18n-editor 0.23.22 → 0.23.35
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/index.js +1 -1
- package/dist/client/schemas/localization.d.ts +1 -0
- package/dist/externalVersion.js +7 -7
- package/dist/node_modules/deepmerge/package.json +1 -1
- package/dist/server/actions/localization.d.ts +1 -0
- package/dist/server/actions/localization.js +16 -1
- package/dist/server/actions/localizationTexts.d.ts +1 -0
- package/dist/server/actions/localizationTexts.js +57 -1
- package/dist/server/plugin.js +4 -4
- package/package.json +10 -10
package/dist/client/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("react-i18next"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("@ant-design/icons"),require("ahooks"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react-i18next","react/jsx-runtime","react","@tachybase/schema","@ant-design/icons","ahooks","antd"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@tachybase/plugin-i18n-editor"]={},n["@tachybase/client"],n["react-i18next"],n.jsxRuntime,n.react,n["@tachybase/schema"],n["@ant-design/icons"],n.ahooks,n.antd))})(this,function(n,e,i,o,d,m,v,C,r){"use strict";var U=Object.defineProperty,_=Object.defineProperties;var H=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var P=(n,e,i)=>e in n?U(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,A=(n,e)=>{for(var i in e||(e={}))$.call(e,i)&&P(n,i,e[i]);if(z)for(var i of z(e))J.call(e,i)&&P(n,i,e[i]);return n},b=(n,e)=>_(n,H(e));var g=(n,e,i)=>new Promise((o,d)=>{var m=r=>{try{C(i.next(r))}catch(y){d(y)}},v=r=>{try{C(i.throw(r))}catch(y){d(y)}},C=r=>r.done?o(r.value):Promise.resolve(r.value).then(m,v);C((i=i.apply(n,e)).next())});const y="localization-management",f=()=>i.useTranslation([y,"core"],{nsMode:"fallback"}),S={name:"localization",fields:[{interface:"input",type:"string",name:"text",uiSchema:{type:"string",title:'{{t("Text")}}',"x-component":"Input.TextArea",required:!0}},{interface:"input",type:"string",name:"translation",uiSchema:{type:"string",title:'{{t("Translation")}}',"x-component":"Input.TextArea"}},{interface:"select",type:"string",name:"moduleTitle",uiSchema:{type:"string",title:'{{t("Module")}}',"x-component":"Select",enum:[{value:"Menu",label:'{{t("Menu")}}'},{value:"Collections & Fields",label:'{{t("Collections & Fields", {ns:"localization-management"})}}'}]}}]},L={type:"void",name:"localization","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:S,resourceName:"localizationTexts",request:{resource:"localizationTexts",action:"list",params:{pageSize:50}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:S},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{currentLang:{type:"void","x-align":"left","x-component":"CurrentLang"},filter:{type:"void",title:'{{t("Filter")}}',"x-align":"left","x-component":"Filter"},deleteTranslation:{type:"void",title:'{{t("Delete translation")}}',"x-component":"Action","x-component-props":{icon:"DeleteOutlined",useAction:"{{ useBulkDestroyTranslationAction }}",confirm:{title:"{{t('Delete translation')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},sync:{type:"void",title:'{{t("Sync")}}',"x-component":"Sync"},publish:{type:"void",title:'{{t("Publish")}}',"x-component":"Action","x-component-props":{icon:"UploadOutlined",type:"primary",useAction:"{{ usePublishAction }}"}}}},table:{type:"void","x-uid":"input","x-component":"Table.Void","x-component-props":{rowKey:"translationId",rowSelection:{type:"checkbox"},useDataSource:"{{ cm.useDataSourceFromRAC }}"},properties:{text:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{text:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},translation:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{translation:{type:"string","x-component":"CollectionField","x-component-props":{component:"TranslationField"},"x-read-pretty":!0}}},moduleTitle:{type:"void","x-decorator":"Table.Column.Decorator","x-component":"Table.Column",properties:{moduleTitle:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"Table.Column",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{update:{type:"void",title:'{{t("Edit")}}',"x-component":"Action.Link","x-component-props":{type:"primary"},properties:{drawer:{type:"void","x-component":"Action.Drawer","x-decorator":"Form","x-decorator-props":{useValues:"{{ cm.useValuesFromRecord }}"},title:'{{t("Edit")}}',properties:{moduleTitle:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},text:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},translation:{"x-component":"CollectionField","x-decorator":"FormItem",required:!0},footer:{type:"void","x-component":"Action.Drawer.Footer",properties:{cancel:{title:'{{t("Cancel")}}',"x-component":"Action","x-component-props":{useAction:"{{ cm.useCancelAction }}"}},submit:{title:'{{t("Submit")}}',"x-component":"Action","x-component-props":{type:"primary",useAction:"{{ useUpdateTranslationAction }}"}}}}}}}},deleteTranslation:{type:"void",title:'{{ t("Delete translation") }}',"x-component":"Action.Link","x-component-props":{confirm:{title:"{{t('Delete translation')}}",content:"{{t('Are you sure you want to delete it?')}}"},useAction:"{{useDestroyTranslationAction}}"},"x-visible":"{{useHasTranslation()}}"}}}}}}}}},{Text:I}=r.Typography,D=()=>{const t=m.useField(),l=m.useForm(),a=e.useActionContext(),{refresh:c}=e.useResourceActionContext(),{targetKey:u}=e.useResourceContext(),{[u]:s}=e.useRecord(),p=e.useAPIClient(),x=p.auth.getLocale();return{run(){return g(this,null,function*(){yield l.submit(),t.data=t.data||{},t.data.loading=!0;try{yield p.resource("localizationTranslations").updateOrCreate({filterKeys:["textId","locale"],values:{textId:s,locale:x,translation:l.values.translation}}),a.setVisible(!1),yield l.reset(),c()}catch(T){console.log(T)}finally{t.data.loading=!1}})}}},M=()=>{const{refresh:t}=e.useResourceActionContext(),l=e.useAPIClient(),{translationId:a}=e.useRecord();return{run(){return g(this,null,function*(){yield l.resource("localizationTranslations").destroy({filterByTk:a}),t()})}}},q=()=>{const{state:t,setState:l,refresh:a}=e.useResourceActionContext(),c=e.useAPIClient(),{t:u}=f();return{run(){return g(this,null,function*(){var p;if(!((p=t==null?void 0:t.selectedRowKeys)!=null&&p.length))return r.message.error(u("Please select the records you want to delete"));yield c.resource("localizationTranslations").destroy({filterByTk:t==null?void 0:t.selectedRowKeys}),l==null||l({selectedRowKeys:[]}),a()})}}},B=()=>{const t=e.useAPIClient();return{run(){return g(this,null,function*(){yield t.resource("localization").publish(),window.location.reload()})}}},K=()=>{const{t}=f(),{refresh:l}=e.useResourceActionContext(),a=e.useAPIClient(),[c,u]=d.useState(!1),s=["local","menu","db"],[p,x]=d.useState(s),[j,T]=d.useState(!1),[E,k]=d.useState(!0),G=h=>{x(h),T(!!h.length&&h.length<s.length),k(h.length===s.length)},N=h=>{x(h.target.checked?s:[]),T(!1),k(h.target.checked)};return o.jsx(e.StablePopover,{placement:"bottomRight",content:o.jsxs(o.Fragment,{children:[o.jsx(r.Checkbox,{indeterminate:j,onChange:N,checked:E,children:t("All")}),o.jsx(r.Divider,{style:{margin:"5px 0"}}),o.jsx(r.Checkbox.Group,{onChange:G,value:p,children:o.jsxs(r.Col,{children:[o.jsx(r.Row,{children:o.jsx(r.Checkbox,{value:"local",children:t("System & Plugins")})}),o.jsx(r.Row,{children:o.jsx(r.Checkbox,{value:"db",children:t("Collections & Fields")})}),o.jsx(r.Row,{children:o.jsx(r.Checkbox,{value:"menu",children:t("Menu")})})]})})]}),children:o.jsx(r.Button,{icon:o.jsx(v.SyncOutlined,{}),loading:c,onClick:()=>g(this,null,function*(){if(!p.length)return r.message.error(t("Please select the resources you want to synchronize"));u(!0),yield a.resource("localization").sync({values:{type:p}}),u(!1),l()}),children:t("Sync")})})},w=()=>{var c;const{t}=f(),l=C.useMemoizedFn(t),{data:a}=e.useResourceActionContext();return d.useMemo(()=>{var u,s;return((s=(u=a==null?void 0:a.meta)==null?void 0:u.modules)==null?void 0:s.map(p=>({value:p.value,label:l(p.label)})))||[]},[(c=a==null?void 0:a.meta)==null?void 0:c.modules,l])},O=()=>{const{t}=f(),{run:l}=e.useResourceActionContext(),a=w(),c=d.useMemo(()=>m.createForm({initialValues:{hasTranslation:!0}}),[]),u=s=>{l(A({},s||c.values))};return d.useEffect(()=>{const s=c.query("module").take();s.dataSource=a},[c,a]),o.jsx(e.FormProvider,{form:c,children:o.jsxs("div",{style:{display:"flex"},children:[o.jsx(m.FieldComponent,{name:"module",dataSource:a,component:[e.Select,{allowClear:!0,placeholder:t("Module"),onChange:s=>u(b(A({},c.values),{module:s}))}]}),o.jsx(m.FieldComponent,{name:"keyword",component:[r.Input.Search,{placeholder:t("Keyword"),allowClear:!0,style:{marginLeft:"8px",width:"fit-content"},onSearch:s=>u(b(A({},c.values),{keyword:s}))}]}),o.jsx(m.FieldComponent,{name:"hasTranslation",dataSource:[{label:t("All"),value:!0},{label:t("No translation"),value:!1}],component:[e.Radio.Group,{defaultValue:!0,style:{marginLeft:"8px",width:"fit-content"},optionType:"button",onChange:()=>u()}]})]})})},V=()=>{var p;const{t}=f(),a=e.useAPIClient().auth.getLocale(),c=((p=e.locale[a])==null?void 0:p.label)||a,u=()=>o.jsxs(r.Typography,{children:[o.jsx(I,{strong:!0,children:t("Current language")}),o.jsx(r.Tag,{style:{marginLeft:"10px"},children:c})]}),s=x=>x.value!==void 0?o.jsx(e.Input.TextArea,A({},x)):o.jsx("div",{});return o.jsx(r.Card,{bordered:!1,children:o.jsx(e.SchemaComponent,{schema:L,components:{TranslationField:s,CurrentLang:u,Sync:K,Filter:O},scope:{t,useDestroyTranslationAction:M,useBulkDestroyTranslationAction:q,useUpdateTranslationAction:D,usePublishAction:B,useModules:w}})})};class F extends e.Plugin{load(){return g(this,null,function*(){this.app.systemSettingsManager.add("system-services."+y,{title:`{{t("Localization", { ns: "${y}" })}}`,icon:"GlobalOutlined",Component:V,aclSnippet:"pm.localization-management.localization"})})}}n.LocalizationManagementPlugin=F,n.default=F,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
1
|
+
(function(n,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@tachybase/client"),require("react-i18next"),require("react/jsx-runtime"),require("react"),require("@tachybase/schema"),require("@ant-design/icons"),require("ahooks"),require("antd")):typeof define=="function"&&define.amd?define(["exports","@tachybase/client","react-i18next","react/jsx-runtime","react","@tachybase/schema","@ant-design/icons","ahooks","antd"],e):(n=typeof globalThis!="undefined"?globalThis:n||self,e(n["@tachybase/plugin-i18n-editor"]={},n["@tachybase/client"],n["react-i18next"],n.jsxRuntime,n.react,n["@tachybase/schema"],n["@ant-design/icons"],n.ahooks,n.antd))})(this,function(n,e,c,o,d,x,k,g,a){"use strict";var U=Object.defineProperty,H=Object.defineProperties;var $=Object.getOwnPropertyDescriptors;var z=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var B=(n,e,c)=>e in n?U(n,e,{enumerable:!0,configurable:!0,writable:!0,value:c}):n[e]=c,v=(n,e)=>{for(var c in e||(e={}))J.call(e,c)&&B(n,c,e[c]);if(z)for(var c of z(e))Q.call(e,c)&&B(n,c,e[c]);return n},S=(n,e)=>H(n,$(e));var C=(n,e,c)=>new Promise((o,d)=>{var x=a=>{try{g(c.next(a))}catch(y){d(y)}},k=a=>{try{g(c.throw(a))}catch(y){d(y)}},g=a=>a.done?o(a.value):Promise.resolve(a.value).then(x,k);g((c=c.apply(n,e)).next())});const y="localization-management",f=()=>c.useTranslation([y,"core"],{nsMode:"fallback"}),F={name:"localizationTexts",fields:[{interface:"input",type:"string",name:"text",uiSchema:{type:"string",title:'{{t("Text")}}',"x-component":"Input.TextArea",required:!0}},{interface:"input",type:"string",name:"translation",uiSchema:{type:"string",title:'{{t("Translation")}}',"x-component":"Input.TextArea"}},{interface:"select",type:"string",name:"moduleTitle",uiSchema:{type:"string",title:'{{t("Module")}}',"x-component":"Select",enum:[{value:"Menu",label:'{{t("Menu")}}'},{value:"Collections & Fields",label:'{{t("Collections & Fields", {ns:"localization-management"})}}'}]}}]},L={type:"void",name:"localizationTexts","x-decorator":"TableBlockProvider","x-decorator-props":{collection:F,action:"list",params:{pageSize:50,append:["moduleTitle","translation"]}},properties:{actions:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:16}},properties:{currentLang:{type:"void","x-align":"left","x-component":"CurrentLang"},filter:{type:"void",title:'{{t("Filter")}}',"x-align":"left","x-component":"Filter"},deleteTranslation:{type:"void",title:'{{t("Delete translation")}}',"x-component":"Action","x-use-component-props":"useBulkDestroyTranslationAction","x-component-props":{icon:"DeleteOutlined",confirm:{title:"{{t('Delete translation')}}",content:"{{t('Are you sure you want to delete it?')}}"}}},sync:{type:"void",title:'{{t("Sync")}}',"x-component":"Sync"},publish:{type:"void",title:'{{t("Publish")}}',"x-component":"Action","x-use-component-props":"usePublishAction","x-component-props":{icon:"UploadOutlined",type:"primary"}}}},table:{type:"array","x-uid":"input","x-component":"TableV2","x-use-component-props":"useTableBlockProps","x-use-decorator-props":"useTableBlockDecoratorProps","x-component-props":{rowKey:"translationId",rowSelection:{type:"checkbox"}},properties:{text:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{text:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},translation:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{translation:{type:"string","x-component":"CollectionField","x-component-props":{component:"TranslationField"},"x-read-pretty":!0}}},moduleTitle:{type:"void","x-decorator":"TableV2.Column.Decorator","x-component":"TableV2.Column",properties:{moduleTitle:{type:"string","x-component":"CollectionField","x-read-pretty":!0}}},actions:{type:"void",title:'{{t("Actions")}}',"x-component":"TableV2.Column","x-decorator":"TableV2.Column.Decorator",properties:{actions:{type:"void","x-component":"Space","x-component-props":{split:"|"},properties:{updatelocalization:{type:"void",title:'{{ t("Edit") }}',"x-action":"update","x-component":"Action.Link","x-component-props":{openMode:"drawer",icon:"EditOutlined"},"x-decorator":"ACLActionProvider",properties:{drawer:{type:"void",title:'{{ t("Edit record") }}',"x-component":"Action.Container","x-component-props":{className:"tb-action-popup"},properties:{card:{type:"void","x-acl-action-props":{skipScopeCheck:!1},"x-acl-action":"localizationTexts:get","x-decorator":"FormBlockProvider","x-use-decorator-props":"useEditFormBlockDecoratorProps","x-decorator-props":{action:"get",dataSource:"main",collection:F},"x-component":"CardItem",properties:{form:{type:"void","x-component":"FormV2","x-use-component-props":"useEditFormBlockProps",properties:{actionBar:{type:"void","x-component":"ActionBar","x-component-props":{style:{marginBottom:24}},properties:{cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-use-component-props":"useUpdateTranslationAction","x-component-props":{type:"primary"}}}},moduleTitle:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},text:{"x-component":"CollectionField","x-decorator":"FormItem","x-read-pretty":!0},translation:{"x-component":"CollectionField","x-decorator":"FormItem",required:!0}}}}}}}}},deleteTranslation:{type:"void",title:'{{ t("Delete translation") }}',"x-component":"Action.Link","x-use-component-props":"useDestroyTranslationAction","x-component-props":{confirm:{title:"{{t('Delete translation')}}",content:"{{t('Are you sure you want to delete it?')}}"}},"x-visible":"{{useHasTranslation()}}"}}}}}}}}},{Text:I}=a.Typography,q=()=>{const t=x.useField(),i=x.useForm(),r=e.useActionContext(),{__parent:s}=e.useBlockRequestContext();e.useDataBlockRequest();const p=e.useCollectionRecordData(),l=p==null?void 0:p.id,u=e.useAPIClient(),m=u.auth.getLocale();return{onClick(){return C(this,null,function*(){var T;yield i.submit(),t.data=t.data||{},t.data.loading=!0;try{yield u.resource("localizationTranslations").updateOrCreate({filterKeys:["textId","locale"],values:{textId:l,locale:m,translation:i.values.translation}}),r.setVisible(!1),yield i.reset(),(T=s==null?void 0:s.service)==null||T.refresh()}catch(A){console.log(A)}finally{t.data.loading=!1}})}}},M=()=>{const{refresh:t}=e.useDataBlockRequest(),i=e.useAPIClient(),{translationId:r}=e.useCollectionRecordData();return{onClick(){return C(this,null,function*(){yield i.resource("localizationTranslations").destroy({filterByTk:r}),t()})}}},V=()=>{const{field:t}=e.useBlockRequestContext(),{setState:i,refresh:r}=e.useDataBlockRequest(),s=e.useAPIClient(),{t:p}=f();return{onClick(){return C(this,null,function*(){var u,m,b;if(!((m=(u=t==null?void 0:t.data)==null?void 0:u.selectedRowKeys)!=null&&m.length))return a.message.error(p("Please select the records you want to delete"));yield s.resource("localization").destroyTrans({values:{textIds:(b=t==null?void 0:t.data)==null?void 0:b.selectedRowKeys}}),i==null||i({selectedRowKeys:[]}),r()})}}},E=()=>{const t=e.useAPIClient();return{onClick(){return C(this,null,function*(){yield t.resource("localization").publish(),window.location.reload()})}}},O=()=>{const{t}=f(),{refresh:i}=e.useDataBlockRequest(),r=e.useAPIClient(),[s,p]=d.useState(!1),l=["local","menu","db"],[u,m]=d.useState(l),[b,T]=d.useState(!1),[A,D]=d.useState(!0),G=h=>{m(h),T(!!h.length&&h.length<l.length),D(h.length===l.length)},N=h=>{m(h.target.checked?l:[]),T(!1),D(h.target.checked)};return o.jsx(e.StablePopover,{placement:"bottomRight",content:o.jsxs(o.Fragment,{children:[o.jsx(a.Checkbox,{indeterminate:b,onChange:N,checked:A,children:t("All")}),o.jsx(a.Divider,{style:{margin:"5px 0"}}),o.jsx(a.Checkbox.Group,{onChange:G,value:u,children:o.jsxs(a.Col,{children:[o.jsx(a.Row,{children:o.jsx(a.Checkbox,{value:"local",children:t("System & Plugins")})}),o.jsx(a.Row,{children:o.jsx(a.Checkbox,{value:"db",children:t("Collections & Fields")})}),o.jsx(a.Row,{children:o.jsx(a.Checkbox,{value:"menu",children:t("Menu")})})]})})]}),children:o.jsx(a.Button,{icon:o.jsx(k.SyncOutlined,{}),loading:s,onClick:()=>C(this,null,function*(){if(!u.length)return a.message.error(t("Please select the resources you want to synchronize"));p(!0),yield r.resource("localization").sync({values:{type:u}}),p(!1),i()}),children:t("Sync")})})},w=()=>{var s;const{t}=f(),i=g.useMemoizedFn(t),{data:r}=e.useDataBlockRequest();return d.useMemo(()=>{var p,l;return((l=(p=r==null?void 0:r.meta)==null?void 0:p.modules)==null?void 0:l.map(u=>({value:u.value,label:i(u.label)})))||[]},[(s=r==null?void 0:r.meta)==null?void 0:s.modules,i])},K=()=>{const{t}=f(),{run:i}=e.useDataBlockRequest(),r=w(),s=d.useMemo(()=>x.createForm({initialValues:{hasTranslation:!0}}),[]),p=l=>{i(v({},l||s.values))};return d.useEffect(()=>{const l=s.query("module").take();l.dataSource=r},[s,r]),o.jsx(e.FormProvider,{form:s,children:o.jsxs("div",{style:{display:"flex"},children:[o.jsx(x.FieldComponent,{name:"module",dataSource:r,component:[e.Select,{allowClear:!0,placeholder:t("Module"),onChange:l=>p(S(v({},s.values),{module:l}))}]}),o.jsx(x.FieldComponent,{name:"keyword",component:[a.Input.Search,{placeholder:t("Keyword"),allowClear:!0,style:{marginLeft:"8px",width:"fit-content"},onSearch:l=>p(S(v({},s.values),{keyword:l}))}]}),o.jsx(x.FieldComponent,{name:"hasTranslation",dataSource:[{label:t("All"),value:!0},{label:t("No translation"),value:!1}],component:[e.Radio.Group,{defaultValue:!0,style:{marginLeft:"8px",width:"fit-content"},optionType:"button",onChange:()=>p()}]})]})})},j=()=>{var u;const{t}=f(),r=e.useAPIClient().auth.getLocale(),s=((u=e.locale[r])==null?void 0:u.label)||r,p=()=>o.jsxs(a.Typography,{children:[o.jsx(I,{strong:!0,children:t("Current language")}),o.jsx(a.Tag,{style:{marginLeft:"10px"},children:s})]}),l=m=>m.value!==void 0?o.jsx(e.Input.TextArea,v({},m)):o.jsx("div",{});return o.jsx(a.Card,{bordered:!1,children:o.jsx(e.SchemaComponent,{schema:L,components:{TranslationField:l,CurrentLang:p,Sync:O,Filter:K},scope:{t,useDestroyTranslationAction:M,useBulkDestroyTranslationAction:V,useUpdateTranslationAction:q,usePublishAction:E,useModules:w}})})};class P extends e.Plugin{load(){return C(this,null,function*(){this.app.systemSettingsManager.add("system-services."+y,{title:`{{t("Localization", { ns: "${y}" })}}`,icon:"GlobalOutlined",Component:j,aclSnippet:"pm.localization-management.localization"})})}}n.LocalizationManagementPlugin=P,n.default=P,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.3.1",
|
|
3
|
-
"@tachybase/client": "0.23.
|
|
4
|
-
"@tachybase/schema": "0.23.
|
|
3
|
+
"@tachybase/client": "0.23.35",
|
|
4
|
+
"@tachybase/schema": "0.23.35",
|
|
5
5
|
"@ant-design/icons": "5.5.2",
|
|
6
6
|
"ahooks": "3.8.4",
|
|
7
7
|
"antd": "5.22.5",
|
|
8
|
-
"@tachybase/database": "0.23.
|
|
9
|
-
"@tachybase/module-ui-schema": "0.23.
|
|
10
|
-
"@tachybase/server": "0.23.
|
|
11
|
-
"@tachybase/cache": "0.23.
|
|
8
|
+
"@tachybase/database": "0.23.35",
|
|
9
|
+
"@tachybase/module-ui-schema": "0.23.35",
|
|
10
|
+
"@tachybase/server": "0.23.35",
|
|
11
|
+
"@tachybase/cache": "0.23.35",
|
|
12
12
|
"react-i18next": "15.2.0",
|
|
13
|
-
"@tachybase/actions": "0.23.
|
|
13
|
+
"@tachybase/actions": "0.23.35"
|
|
14
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"deepmerge","description":"A library for deep (recursive) merging of Javascript objects","keywords":["merge","deep","extend","copy","clone","recursive"],"version":"4.3.1","homepage":"https://github.com/TehShrike/deepmerge","repository":{"type":"git","url":"git://github.com/TehShrike/deepmerge.git"},"main":"dist/cjs.js","engines":{"node":">=0.10.0"},"scripts":{"build":"rollup -c","test":"npm run build && tape test/*.js && jsmd readme.md && npm run test:typescript","test:typescript":"tsc --noEmit test/typescript.ts && ts-node test/typescript.ts","size":"npm run build && uglifyjs --compress --mangle -- ./dist/umd.js | gzip -c | wc -c"},"devDependencies":{"@types/node":"^8.10.54","is-mergeable-object":"1.1.0","is-plain-object":"^5.0.0","jsmd":"^1.0.2","rollup":"^1.23.1","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","tape":"^4.11.0","ts-node":"7.0.1","typescript":"=2.2.2","uglify-js":"^3.6.1"},"license":"MIT","_lastModified":"
|
|
1
|
+
{"name":"deepmerge","description":"A library for deep (recursive) merging of Javascript objects","keywords":["merge","deep","extend","copy","clone","recursive"],"version":"4.3.1","homepage":"https://github.com/TehShrike/deepmerge","repository":{"type":"git","url":"git://github.com/TehShrike/deepmerge.git"},"main":"dist/cjs.js","engines":{"node":">=0.10.0"},"scripts":{"build":"rollup -c","test":"npm run build && tape test/*.js && jsmd readme.md && npm run test:typescript","test:typescript":"tsc --noEmit test/typescript.ts && ts-node test/typescript.ts","size":"npm run build && uglifyjs --compress --mangle -- ./dist/umd.js | gzip -c | wc -c"},"devDependencies":{"@types/node":"^8.10.54","is-mergeable-object":"1.1.0","is-plain-object":"^5.0.0","jsmd":"^1.0.2","rollup":"^1.23.1","rollup-plugin-commonjs":"^10.1.0","rollup-plugin-node-resolve":"^5.2.0","tape":"^4.11.0","ts-node":"7.0.1","typescript":"=2.2.2","uglify-js":"^3.6.1"},"license":"MIT","_lastModified":"2025-01-16T06:26:42.053Z"}
|
|
@@ -7,5 +7,6 @@ export declare const getTextsFromMenu: (db: Database, migrate?: boolean) => Prom
|
|
|
7
7
|
declare const _default: {
|
|
8
8
|
publish: (ctx: Context, next: Next) => Promise<void>;
|
|
9
9
|
sync: (ctx: Context, next: Next) => Promise<void>;
|
|
10
|
+
destroyTrans: (ctx: Context, next: Next) => Promise<void>;
|
|
10
11
|
};
|
|
11
12
|
export default _default;
|
|
@@ -226,7 +226,22 @@ const publish = async (ctx, next) => {
|
|
|
226
226
|
ctx.body = await resources.resetCache(ctx.get("X-Locale") || "en-US");
|
|
227
227
|
await next();
|
|
228
228
|
};
|
|
229
|
-
|
|
229
|
+
const destroyTrans = async (ctx, next) => {
|
|
230
|
+
var _a, _b;
|
|
231
|
+
const textIds = ((_b = (_a = ctx.action.params) == null ? void 0 : _a.values) == null ? void 0 : _b.textIds) || [];
|
|
232
|
+
const repo = ctx.db.getRepository("localizationTranslations");
|
|
233
|
+
await repo.destroy({
|
|
234
|
+
filter: {
|
|
235
|
+
textId: {
|
|
236
|
+
$in: textIds
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
ctx.body = { success: true, message: "Records deleted successfully" };
|
|
241
|
+
ctx.status = 200;
|
|
242
|
+
await next();
|
|
243
|
+
};
|
|
244
|
+
var localization_default = { publish, sync, destroyTrans };
|
|
230
245
|
// Annotate the CommonJS export names for ESM import in node:
|
|
231
246
|
0 && (module.exports = {
|
|
232
247
|
getResources,
|
|
@@ -127,4 +127,60 @@ const list = async (ctx, next) => {
|
|
|
127
127
|
};
|
|
128
128
|
await next();
|
|
129
129
|
};
|
|
130
|
-
|
|
130
|
+
const getTranslations = async (db, row, locale) => {
|
|
131
|
+
if (!row || !row.id) {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const repo = db.getRepository("localizationTranslations");
|
|
135
|
+
const translation = await repo.findOne({
|
|
136
|
+
filter: {
|
|
137
|
+
locale,
|
|
138
|
+
textId: row.id
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
if (translation) {
|
|
142
|
+
row.set("translation", translation.translation, { raw: true });
|
|
143
|
+
row.set("translationId", translation.id, { raw: true });
|
|
144
|
+
} else {
|
|
145
|
+
row.set("translation", null, { raw: true });
|
|
146
|
+
row.set("translationId", null, { raw: true });
|
|
147
|
+
}
|
|
148
|
+
return row;
|
|
149
|
+
};
|
|
150
|
+
const getText = async (db, params) => {
|
|
151
|
+
const { filterByTk, hasTranslation, locale, options } = params;
|
|
152
|
+
const row = await db.getRepository("localizationTexts").findOne({
|
|
153
|
+
filterByTk
|
|
154
|
+
});
|
|
155
|
+
return await getTranslations(db, row, locale);
|
|
156
|
+
};
|
|
157
|
+
const get = async (ctx, next) => {
|
|
158
|
+
const locale = ctx.get("X-Locale") || "en-US";
|
|
159
|
+
let { hasTranslation, filterByTk } = ctx.action.params;
|
|
160
|
+
hasTranslation = hasTranslation === "true" || hasTranslation === void 0;
|
|
161
|
+
const options = {
|
|
162
|
+
context: ctx
|
|
163
|
+
};
|
|
164
|
+
const row = await getText(ctx.db, { filterByTk, hasTranslation, locale });
|
|
165
|
+
if (!row) {
|
|
166
|
+
ctx.throw(404, ctx.t("Record not found"));
|
|
167
|
+
}
|
|
168
|
+
const cache = ctx.app.cache;
|
|
169
|
+
const pm = ctx.app.pm;
|
|
170
|
+
const plugins = await cache.wrap(`lm-plugins:${locale}`, () => pm.list({ locale }));
|
|
171
|
+
const modules = [
|
|
172
|
+
...import_constans.EXTEND_MODULES,
|
|
173
|
+
...plugins.map((plugin) => ({
|
|
174
|
+
value: plugin.alias || plugin.name,
|
|
175
|
+
label: plugin.displayName
|
|
176
|
+
}))
|
|
177
|
+
];
|
|
178
|
+
const moduleName = row.get("module").replace("resources.", "");
|
|
179
|
+
const module2 = modules.find((module3) => module3.value === moduleName);
|
|
180
|
+
if (module2) {
|
|
181
|
+
row.set("moduleTitle", module2.label, { raw: true });
|
|
182
|
+
}
|
|
183
|
+
ctx.body = row;
|
|
184
|
+
await next();
|
|
185
|
+
};
|
|
186
|
+
var localizationTexts_default = { list, get };
|
package/dist/server/plugin.js
CHANGED
|
@@ -125,15 +125,15 @@ class LocalizationManagementPlugin extends import_server.Plugin {
|
|
|
125
125
|
await next();
|
|
126
126
|
const { resourceName, actionName } = ctx.action;
|
|
127
127
|
if (resourceName === "app" && actionName === "getLang") {
|
|
128
|
-
const pluginETag = await this.resources.getETag(ctx.get("X-Locale") || "
|
|
128
|
+
const pluginETag = await this.resources.getETag(ctx.get("X-Locale") || "zh-CN");
|
|
129
129
|
const responseETag = ctx.response.get("ETag") || "";
|
|
130
|
-
if (ctx.status === 304 && responseETag && responseETag.substring(37, 37 + 36) === pluginETag) {
|
|
130
|
+
if (ctx.status === 304 && responseETag && responseETag.substring(37 + 2, 37 + 36 + 2) === pluginETag) {
|
|
131
131
|
ctx.status = 304;
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
ctx.status = 200;
|
|
135
|
-
ctx.res.setHeader("ETag",
|
|
136
|
-
const custom = await this.resources.getResources(ctx.get("X-Locale") || "
|
|
135
|
+
ctx.res.setHeader("ETag", `W/${responseETag.substring(0 + 2, 36 + 2)}-${pluginETag}`);
|
|
136
|
+
const custom = await this.resources.getResources(ctx.get("X-Locale") || "zh-CN");
|
|
137
137
|
const appLang = ctx.body;
|
|
138
138
|
const resources = { ...appLang.resources };
|
|
139
139
|
Object.keys(custom).forEach((key) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/plugin-i18n-editor",
|
|
3
3
|
"displayName": "Localization",
|
|
4
|
-
"version": "0.23.
|
|
4
|
+
"version": "0.23.35",
|
|
5
5
|
"description": "Allows to manage localization resources of the application.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"System management"
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"antd": "5.22.5",
|
|
16
16
|
"deepmerge": "^4.3.1",
|
|
17
17
|
"react-i18next": "^15.2.0",
|
|
18
|
-
"@tachybase/schema": "0.23.
|
|
18
|
+
"@tachybase/schema": "0.23.35"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@tachybase/actions": "0.23.
|
|
22
|
-
"@tachybase/
|
|
23
|
-
"@tachybase/
|
|
24
|
-
"@tachybase/module-ui-schema": "0.23.
|
|
25
|
-
"@tachybase/
|
|
26
|
-
"@tachybase/module-web": "0.23.
|
|
27
|
-
"@tachybase/test": "0.23.
|
|
28
|
-
"@tachybase/server": "0.23.
|
|
21
|
+
"@tachybase/actions": "0.23.35",
|
|
22
|
+
"@tachybase/client": "0.23.35",
|
|
23
|
+
"@tachybase/cache": "0.23.35",
|
|
24
|
+
"@tachybase/module-ui-schema": "0.23.35",
|
|
25
|
+
"@tachybase/database": "0.23.35",
|
|
26
|
+
"@tachybase/module-web": "0.23.35",
|
|
27
|
+
"@tachybase/test": "0.23.35",
|
|
28
|
+
"@tachybase/server": "0.23.35"
|
|
29
29
|
},
|
|
30
30
|
"description.zh-CN": "支持管理应用程序的本地化资源。",
|
|
31
31
|
"displayName.zh-CN": "本地化",
|