@nocobase/plugin-localization 2.1.0-alpha.1 → 2.1.0-alpha.10

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/README.md CHANGED
@@ -1,17 +1,24 @@
1
1
  # NocoBase
2
2
 
3
3
  <video width="100%" controls>
4
- <source src="https://static-docs.nocobase.com/NocoBase0510.mp4" type="video/mp4">
4
+ <source src="https://github.com/user-attachments/assets/4d11a87b-00e2-48f3-9bf7-389d21072d13" type="video/mp4">
5
5
  </video>
6
6
 
7
+ <p align="center">
8
+ <a href="https://trendshift.io/repositories/4112" target="_blank"><img src="https://trendshift.io/api/badge/repositories/4112" alt="nocobase%2Fnocobase | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
9
+ <a href="https://www.producthunt.com/posts/nocobase?embed=true&utm_source=badge-top-post-topic-badge&utm_medium=badge&utm_souce=badge-nocobase" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/top-post-topic-badge.svg?post_id=456520&theme=light&period=weekly&topic_id=267" alt="NocoBase - Scalability&#0045;first&#0044;&#0032;open&#0045;source&#0032;no&#0045;code&#0032;platform | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
10
+ </p>
7
11
 
8
12
  ## What is NocoBase
9
13
 
10
- NocoBase is a scalability-first, open-source no-code development platform.
11
- Instead of investing years of time and millions of dollars in research and development, deploy NocoBase in a few minutes and you'll have a private, controllable, and extremely scalable no-code development platform!
14
+ NocoBase is the most extensible AI-powered no-code platform.
15
+ Total control. Infinite extensibility. AI collaboration.
16
+ Enable your team to adapt quickly and cut costs dramatically.
17
+ No years of development. No millions wasted.
18
+ Deploy NocoBase in minutes — and take control of everything.
12
19
 
13
20
  Homepage:
14
- https://www.nocobase.com/
21
+ https://www.nocobase.com/
15
22
 
16
23
  Online Demo:
17
24
  https://demo.nocobase.com/new
@@ -19,12 +26,74 @@ https://demo.nocobase.com/new
19
26
  Documents:
20
27
  https://docs.nocobase.com/
21
28
 
22
- Commericial license & plugins:
23
- https://www.nocobase.com/en/commercial
29
+ Forum:
30
+ https://forum.nocobase.com/
24
31
 
25
- License agreement:
26
- https://www.nocobase.com/en/agreement
32
+ Use Cases:
33
+ https://www.nocobase.com/en/blog/tags/customer-stories
27
34
 
35
+ ## Release Notes
28
36
 
29
- ## Contact Us:
30
- hello@nocobase.com
37
+ Our [blog](https://www.nocobase.com/en/blog/timeline) is regularly updated with release notes and provides a weekly summary.
38
+
39
+ ## Distinctive features
40
+
41
+ ### 1. Data model-driven, not form/table–driven
42
+
43
+ Instead of being constrained by forms or tables, NocoBase adopts a data model–driven approach, separating data structure from user interface to unlock unlimited possibilities.
44
+
45
+ - UI and data structure are fully decoupled
46
+ - Multiple blocks and actions can be created for the same table or record in any quantity or form
47
+ - Supports the main database, external databases, and third-party APIs as data sources
48
+
49
+ ![model](https://static-docs.nocobase.com/model.png)
50
+
51
+ ### 2. AI employees, integrated into your business systems
52
+ Unlike standalone AI demos, NocoBase allows you to embed AI capabilities seamlessly into your interfaces, workflows, and data context, making AI truly useful in real business scenarios.
53
+
54
+ - Define AI employees for roles such as translator, analyst, researcher, or assistant
55
+ - Seamless AI–human collaboration in interfaces and workflows
56
+ - Ensure AI usage is secure, transparent, and customizable for your business needs
57
+
58
+ ![AI-employee](https://static-docs.nocobase.com/ai-employee-home.png)
59
+
60
+ ### 3. What you see is what you get, incredibly easy to use
61
+
62
+ While enabling the development of complex business systems, NocoBase keeps the experience simple and intuitive.
63
+
64
+ - One-click switch between usage mode and configuration mode
65
+ - Pages serve as a canvas to arrange blocks and actions, similar to Notion
66
+ - Configuration mode is designed for ordinary users, not just programmers
67
+
68
+ ![wysiwyg](https://static-docs.nocobase.com/wysiwyg.gif)
69
+
70
+ ### 4. Everything is a plugin, designed for extension
71
+ Adding more no-code features will never cover every business case. NocoBase is built for extension through its plugin-based microkernel architecture.
72
+
73
+ - All functionalities are plugins, similar to WordPress
74
+ - Plugins are ready to use upon installation
75
+ - Pages, blocks, actions, APIs, and data sources can all be extended through custom plugins
76
+
77
+ ![plugins](https://static-docs.nocobase.com/plugins.png)
78
+
79
+ ## Installation
80
+
81
+ NocoBase supports three installation methods:
82
+
83
+ - <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/docker-compose">Installing With Docker (👍Recommended)</a>
84
+
85
+ Suitable for no-code scenarios, no code to write. When upgrading, just download the latest image and reboot.
86
+
87
+ - <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/create-nocobase-app">Installing from create-nocobase-app CLI</a>
88
+
89
+ The business code of the project is completely independent and supports low-code development.
90
+
91
+ - <a target="_blank" href="https://docs.nocobase.com/welcome/getting-started/installation/git-clone">Installing from Git source code</a>
92
+
93
+ If you want to experience the latest unreleased version, or want to participate in the contribution, you need to make changes and debug on the source code, it is recommended to choose this installation method, which requires a high level of development skills, and if the code has been updated, you can git pull the latest code.
94
+
95
+ ## How NocoBase works
96
+
97
+ <video width="100%" controls>
98
+ <source src="https://github.com/user-attachments/assets/8d183b44-9bb5-4792-b08f-bc08fe8dfaaf" type="video/mp4">
99
+ </video>
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ "use strict";(self.webpackChunk_nocobase_plugin_localization=self.webpackChunk_nocobase_plugin_localization||[]).push([["536"],{555:function(e,t,n){n.r(t),n.d(t,{Localization:function(){return F}});var o=n(375),r=n(452),l=n(230),a=n(342),i=n(625),c=n(59),u=n(155),s=n.n(u),p=n(404),m={name:"localization",disableTranslation:!0,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"})}}'}]}}]},d={type:"void",name:"localization","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:m,resourceName:"localizationTexts",request:{resource:"localizationTexts",action:"list",params:{pageSize:50}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:m},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:"id",rowSelection:{type:"checkbox",getCheckboxProps:function(e){return{disabled:!(null==e?void 0:e.translationId)}}},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":"ModuleTitle"}}},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:{title:'{{t("Module")}}',"x-component":"ModuleTitle","x-decorator":"FormItem"},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()}}"}}}}}}}}};function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function y(e,t,n,o,r,l,a){try{var i=e[l](a),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(o,r)}function h(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var l=e.apply(t,n);function a(e){y(l,o,r,a,i,"next",e)}function i(e){y(l,o,r,a,i,"throw",e)}a(void 0)})}}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}function v(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,o,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var l=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(i)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){var n,o,r,l={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),i=Object.defineProperty;return i(a,"next",{value:c(0)}),i(a,"throw",{value:c(1)}),i(a,"return",{value:c(2)}),"function"==typeof Symbol&&i(a,Symbol.iterator,{value:function(){return this}}),a;function c(i){return function(c){var u=[i,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(l=0)),l;)try{if(n=1,o&&(r=2&u[0]?o.return:u[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,u[1])).done)return r;switch(o=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return l.label++,{value:u[1],done:!1};case 5:l.label++,o=u[1],u=[0];continue;case 7:u=l.ops.pop(),l.trys.pop();continue;default:if(!(r=(r=l.trys).length>0&&r[r.length-1])&&(6===u[0]||2===u[0])){l=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){l.label=u[1];break}if(6===u[0]&&l.label<r[1]){l.label=r[1],r=u;break}if(r&&l.label<r[2]){l.label=r[2],l.ops.push(u);break}r[2]&&l.ops.pop(),l.trys.pop();continue}u=t.call(e,l)}catch(e){u=[6,e],o=0}finally{n=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var A=c.Typography.Text,C=function(){var e=(0,l.useField)(),t=(0,l.useForm)(),n=(0,a.useActionContext)(),o=(0,a.useResourceActionContext)().refresh,r=(0,a.useResourceContext)().targetKey,i=(0,a.useRecord)()[r],c=(0,a.useAPIClient)(),u=c.auth.getLocale();return{run:function(){return h(function(){return g(this,function(r){switch(r.label){case 0:return[4,t.submit()];case 1:r.sent(),e.data=e.data||{},e.data.loading=!0,r.label=2;case 2:return r.trys.push([2,5,6,7]),[4,c.resource("localizationTranslations").updateOrCreate({filterKeys:["textId","locale"],values:{textId:i,locale:u,translation:t.values.translation}})];case 3:return r.sent(),n.setVisible(!1),[4,t.reset()];case 4:return r.sent(),o(),[3,7];case 5:return console.log(r.sent()),[3,7];case 6:return e.data.loading=!1,[7];case 7:return[2]}})})()}}},T=function(){var e=(0,a.useResourceActionContext)().refresh,t=(0,a.useAPIClient)(),n=(0,a.useRecord)().translationId;return{run:function(){return h(function(){return g(this,function(o){switch(o.label){case 0:if(!n)return[2];return[4,t.resource("localizationTranslations").destroy({filterByTk:n})];case 1:return o.sent(),e(),[2]}})})()}}},w=function(){var e=(0,a.useResourceActionContext)(),t=e.state,n=e.setState,o=e.refresh,r=e.data,l=(0,a.useAPIClient)(),i=(0,p.Q)().t;return{run:function(){return h(function(){var e,a,u,s,p;return g(this,function(m){switch(m.label){case 0:if(!(a=(null==t?void 0:t.selectedRowKeys)||[]).length||(u=(null==r||null==(e=r.data)?void 0:e.rows)||(null==r?void 0:r.data)||(null==r?void 0:r.rows)||[],s=new Set(a.map(function(e){return String(e)})),!(p=u.filter(function(e){return s.has(String(e.id))}).map(function(e){return e.translationId}).filter(Boolean)).length))return[2,c.message.error(i("Please select the records you want to delete"))];return[4,l.resource("localizationTranslations").destroy({filterByTk:p})];case 1:return m.sent(),null==n||n({selectedRowKeys:[]}),o(),[2]}})})()}}},S=function(){var e=(0,a.useAPIClient)();return{run:function(){return h(function(){return g(this,function(t){switch(t.label){case 0:return[4,e.resource("localization").publish()];case 1:return t.sent(),window.location.reload(),[2]}})})()}}},E=function(){var e=(0,p.Q)().t,t=(0,a.useResourceActionContext)().refresh,n=(0,a.useAPIClient)(),r=x((0,u.useState)(!1),2),i=r[0],m=r[1],d=x((0,u.useState)([]),2),f=d[0],y=d[1],b=x((0,u.useState)([]),2),v=b[0],A=b[1],C=x((0,u.useState)(!1),2),T=C[0],w=C[1],S=x((0,u.useState)(!0),2),E=S[0],O=S[1],P=(0,a.useRequest)(function(){return n.resource("localization").getSources().then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data})},{onSuccess:function(e){var t=e.map(function(e){return e.name});y(t),A(t)}}),k=P.data;return P.loading?null:s().createElement(a.StablePopover,{placement:"bottomRight",content:s().createElement(s().Fragment,null,s().createElement(c.Checkbox,{indeterminate:T,onChange:function(e){A(e.target.checked?f:[]),w(!1),O(e.target.checked)},checked:E},e("All")),s().createElement(c.Divider,{style:{margin:"5px 0"}}),s().createElement(c.Checkbox.Group,{onChange:function(e){A(e),w(!!e.length&&e.length<f.length),O(e.length===f.length)},value:v},s().createElement(c.Col,null,(k||[]).map(function(t){return s().createElement(c.Row,{key:t.name},s().createElement(c.Checkbox,{value:t.name},l.Schema.compile(t.title,{t:e})))}))))},s().createElement(c.Button,{icon:s().createElement(o.SyncOutlined,null),loading:i,onClick:function(){return h(function(){return g(this,function(o){switch(o.label){case 0:if(!v.length)return[2,c.message.error(e("Please select the resources you want to synchronize"))];return m(!0),[4,n.resource("localization").sync({values:{types:v}})];case 1:return o.sent(),m(!1),t(),[2]}})})()}},e("Sync")))},O=function(){var e,t=(0,p.Q)().t,n=(0,i.useMemoizedFn)(t),o=(0,a.useResourceActionContext)().data;return(0,u.useMemo)(function(){var e,t;return(null==o||null==(t=o.meta)||null==(e=t.modules)?void 0:e.map(function(e){return{value:e.value,label:l.Schema.compile(e.label,{t:n})}}))||[]},[null==o||null==(e=o.meta)?void 0:e.modules,n])},P=function(){var e=(0,p.Q)().t,t=(0,a.useResourceActionContext)().run,n=O(),o=(0,u.useMemo)(function(){return(0,r.createForm)({initialValues:{hasTranslation:!0}})},[]),i=function(e){t(b({},e||o.values))};return(0,u.useEffect)(function(){o.query("module").take().dataSource=n},[o,n]),s().createElement(a.FormProvider,{form:o},s().createElement("div",{style:{display:"flex"}},s().createElement(l.Field,{name:"module",dataSource:n,component:[a.Select,{allowClear:!0,placeholder:e("Module"),onChange:function(e){return i(v(b({},o.values),{module:e}))}}]}),s().createElement(l.Field,{name:"keyword",component:[c.Input.Search,{placeholder:e("Keyword"),allowClear:!0,style:{marginLeft:"8px",width:"fit-content"},onSearch:function(e){return i(v(b({},o.values),{keyword:e}))}}]}),s().createElement(l.Field,{name:"hasTranslation",dataSource:[{label:e("All"),value:!0},{label:e("No translation"),value:!1}],component:[a.Radio.Group,{defaultValue:!0,style:{marginLeft:"8px",width:"fit-content"},optionType:"button",onChange:function(){return i()}}]})))},k=function(){var e=(0,p.Q)().t,t=(0,a.useRecord)(),n=t.moduleTitle,o=t.module;return n?s().createElement(c.Tag,null,l.Schema.compile(n,{t:e})):s().createElement(c.Tag,null,o)},F=function(){var e,t=(0,p.Q)().t,n=(0,a.useAPIClient)().auth.getLocale(),o=(null==(e=a.locale[n])?void 0:e.label)||n;return s().createElement(c.Card,{bordered:!1},s().createElement(a.SchemaComponent,{schema:d,components:{TranslationField:function(e){return void 0!==e.value?s().createElement(a.Input.TextArea,e):s().createElement("div",null)},CurrentLang:function(){return s().createElement(c.Typography,null,s().createElement(A,{strong:!0},t("Current language")),s().createElement(c.Tag,{style:{marginLeft:"10px"}},o))},Sync:E,Filter:P,ModuleTitle:k},scope:{t:t,useDestroyTranslationAction:T,useBulkDestroyTranslationAction:w,useUpdateTranslationAction:C,usePublishAction:S,useModules:O}}))}}}]);
@@ -0,0 +1,25 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { FlowEngineContext } from '@nocobase/flow-engine';
10
+ export declare class MissingKeyHandler {
11
+ private context;
12
+ static DEBOUNCE_DELAY: number;
13
+ static fallbackNS: string;
14
+ private sentMissingKeys;
15
+ private pendingMissingKeys;
16
+ private submitPendingKeysDebounced;
17
+ private missingKeyHandler;
18
+ private currentLocale?;
19
+ constructor(context: FlowEngineContext);
20
+ register(): void;
21
+ unregister(): void;
22
+ private isFallbackClient;
23
+ private removeClientFallback;
24
+ private submitPendingKeys;
25
+ }
@@ -7,4 +7,4 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@formily/core"),require("ahooks"),require("@nocobase/client"),require("react"),require("@formily/react"),require("@ant-design/icons"),require("antd"),require("react-i18next")):"function"==typeof define&&define.amd?define("@nocobase/plugin-localization",["@formily/core","ahooks","@nocobase/client","react","@formily/react","@ant-design/icons","antd","react-i18next"],t):"object"==typeof exports?exports["@nocobase/plugin-localization"]=t(require("@formily/core"),require("ahooks"),require("@nocobase/client"),require("react"),require("@formily/react"),require("@ant-design/icons"),require("antd"),require("react-i18next")):e["@nocobase/plugin-localization"]=t(e["@formily/core"],e.ahooks,e["@nocobase/client"],e.react,e["@formily/react"],e["@ant-design/icons"],e.antd,e["react-i18next"])}(self,function(e,t,n,r,o,i,u,c){return function(){var a,l,f,s,p,d,b={551:function(e,t,n){"use strict";n.d(t,{A:function(){return o},F:function(){return i}});var r=n(238),o="localization",i=function(){return(0,r.useTranslation)([o,"client"],{nsMode:"fallback"})}},581:function(e){e.exports=function(e,t){return"undefined"!=typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},482:function(e){"use strict";e.exports=i},563:function(t){"use strict";t.exports=e},505:function(e){"use strict";e.exports=o},772:function(e){"use strict";e.exports=n},749:function(e){"use strict";e.exports=t},721:function(e){"use strict";e.exports=u},156:function(e){"use strict";e.exports=r},238:function(e){"use strict";e.exports=c}},y={};function h(e){var t=y[e];if(void 0!==t)return t.exports;var n=y[e]={exports:{}};return b[e](n,n.exports,h),n.exports}h.m=b,h.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return h.d(t,{a:t}),t},h.d=function(e,t){for(var n in t)h.o(t,n)&&!h.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},h.f={},h.e=function(e){return Promise.all(Object.keys(h.f).reduce(function(t,n){return h.f[n](e,t),t},[]))},h.u=function(e){return"0c4d30d25f0064b4.js"},h.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),h.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a={},l="@nocobase/plugin-localization:",h.l=function(e,t,n,r){if(a[e])return void a[e].push(t);if(void 0!==n)for(var o,i,u=document.getElementsByTagName("script"),c=0;c<u.length;c++){var f=u[c];if(f.getAttribute("src")==e||f.getAttribute("data-webpack")==l+n){o=f;break}}o||(i=!0,(o=document.createElement("script")).charset="utf-8",o.timeout=120,h.nc&&o.setAttribute("nonce",h.nc),o.setAttribute("data-webpack",l+n),o.src=e),a[e]=[t];var s=function(t,n){o.onerror=o.onload=null,clearTimeout(p);var r=a[e];if(delete a[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},p=setTimeout(s.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=s.bind(null,o.onerror),o.onload=s.bind(null,o.onload),i&&document.head.appendChild(o)},h.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(f=window.__nocobase_public_path__||"/").endsWith("/")||(f+="/"),h.p=f+"static/plugins/@nocobase/plugin-localization/dist/client/",s={909:0},h.f.j=function(e,t){var n=h.o(s,e)?s[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=s[e]=[t,r]});t.push(n[2]=r);var o=h.p+h.u(e),i=Error();h.l(o,function(t){if(h.o(s,e)&&(0!==(n=s[e])&&(s[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},p=function(e,t){var n,r,o=t[0],i=t[1],u=t[2],c=0;if(o.some(function(e){return 0!==s[e]})){for(n in i)h.o(i,n)&&(h.m[n]=i[n]);u&&u(h)}for(e&&e(t);c<o.length;c++)r=o[c],h.o(s,r)&&s[r]&&s[r][0](),s[r]=0},(d=self.webpackChunk_nocobase_plugin_localization=self.webpackChunk_nocobase_plugin_localization||[]).forEach(p.bind(null,0)),d.push=p.bind(null,d.push.bind(d));var v={};return!function(){"use strict";h.r(v),h.d(v,{PluginLocalizationClient:function(){return f}});var e=h(772),t=h(551),n=h(581);function r(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function o(e,t,n){return(o=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&u(o,n.prototype),o}).apply(null,arguments)}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(e){var t="function"==typeof Map?new Map:void 0;return(c=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return o(e,arguments,i(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)})(e)}function a(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(a=function(){return!!e})()}var l=(0,e.lazy)(function(){return n("imported_-237jod_component",h.e("121").then(h.bind(h,730)))},"Localization").Localization,f=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function o(){var e,t;if(!(this instanceof o))throw TypeError("Cannot call a class as a function");return e=o,t=arguments,e=i(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,a()?Reflect.construct(e,t||[],i(this).constructor):e.apply(this,t))}return o.prototype=Object.create(e&&e.prototype,{constructor:{value:o,writable:!0,configurable:!0}}),e&&u(o,e),n=[{key:"load",value:function(){var e,n=this;return(e=function(){return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var a=[i,c];if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}(this,function(e){return n.app.pluginSettingsManager.add(t.A,{title:'{{t("Localization", { ns: "'.concat(t.A,'" })}}'),icon:"GlobalOutlined",Component:l,aclSnippet:"pm.localization.localization"}),[2]})},function(){var t=this,n=arguments;return new Promise(function(o,i){var u=e.apply(t,n);function c(e){r(u,o,i,c,a,"next",e)}function a(e){r(u,o,i,c,a,"throw",e)}c(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(o.prototype,n),o}(c(e.Plugin));v.default=f}(),v}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("ahooks"),require("react-i18next"),require("@formily/core"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("lodash")):"function"==typeof define&&define.amd?define("@nocobase/plugin-localization",["ahooks","react-i18next","@formily/core","react","antd","@nocobase/client","@formily/react","@ant-design/icons","lodash"],t):"object"==typeof exports?exports["@nocobase/plugin-localization"]=t(require("ahooks"),require("react-i18next"),require("@formily/core"),require("react"),require("antd"),require("@nocobase/client"),require("@formily/react"),require("@ant-design/icons"),require("lodash")):e["@nocobase/plugin-localization"]=t(e.ahooks,e["react-i18next"],e["@formily/core"],e.react,e.antd,e["@nocobase/client"],e["@formily/react"],e["@ant-design/icons"],e.lodash)}(self,function(e,t,n,r,o,i,a,u,c){return function(){var s,l,f,p={404:function(e,t,n){"use strict";n.d(t,{C:function(){return o},Q:function(){return i}});var r=n(953),o="localization",i=function(){return(0,r.useTranslation)([o,"client"],{nsMode:"fallback"})}},631:function(e){e.exports=function(e,t){return"u">typeof __deoptimization_sideEffect__&&__deoptimization_sideEffect__(e,t),t}},375:function(e){"use strict";e.exports=u},452:function(e){"use strict";e.exports=n},230:function(e){"use strict";e.exports=a},342:function(e){"use strict";e.exports=i},625:function(t){"use strict";t.exports=e},59:function(e){"use strict";e.exports=o},773:function(e){"use strict";e.exports=c},155:function(e){"use strict";e.exports=r},953:function(e){"use strict";e.exports=t}},d={};function y(e){var t=d[e];if(void 0!==t)return t.exports;var n=d[e]={exports:{}};return p[e](n,n.exports,y),n.exports}y.m=p,y.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return y.d(t,{a:t}),t},y.d=function(e,t){for(var n in t)y.o(t,n)&&!y.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},y.f={},y.e=function(e){return Promise.all(Object.keys(y.f).reduce(function(t,n){return y.f[n](e,t),t},[]))},y.u=function(e){return"0f2a2f4597e12c21.js"},y.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),y.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},b={},y.l=function(e,t,n,r){if(b[e])return void b[e].push(t);if(void 0!==n)for(var o,i,a=document.getElementsByTagName("script"),u=0;u<a.length;u++){var c=a[u];if(c.getAttribute("src")==e||c.getAttribute("data-rspack")=="@nocobase/plugin-localization:"+n){o=c;break}}o||(i=!0,(o=document.createElement("script")).timeout=120,y.nc&&o.setAttribute("nonce",y.nc),o.setAttribute("data-rspack","@nocobase/plugin-localization:"+n),o.src=e),b[e]=[t];var s=function(t,n){o.onerror=o.onload=null,clearTimeout(l);var r=b[e];if(delete b[e],o.parentNode&&o.parentNode.removeChild(o),r&&r.forEach(function(e){return e(n)}),t)return t(n)},l=setTimeout(s.bind(null,void 0,{type:"timeout",target:o}),12e4);o.onerror=s.bind(null,o.onerror),o.onload=s.bind(null,o.onload),i&&document.head.appendChild(o)},y.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},y.g.importScripts&&(h=y.g.location+"");var b,h,v=y.g.document;if(!h&&v&&(v.currentScript&&"SCRIPT"===v.currentScript.tagName.toUpperCase()&&(h=v.currentScript.src),!h)){var g=v.getElementsByTagName("script");if(g.length)for(var m=g.length-1;m>-1&&(!h||!/^http(s?):/.test(h));)h=g[m--].src}if(!h)throw Error("Automatic publicPath is not supported in this browser");y.p=h.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),s={889:0},y.f.j=function(e,t){var n=y.o(s,e)?s[e]:void 0;if(0!==n)if(n)t.push(n[2]);else{var r=new Promise(function(t,r){n=s[e]=[t,r]});t.push(n[2]=r);var o=y.p+y.u(e),i=Error();y.l(o,function(t){if(y.o(s,e)&&(0!==(n=s[e])&&(s[e]=void 0),n)){var r=t&&("load"===t.type?"missing":t.type),o=t&&t.target&&t.target.src;i.message="Loading chunk "+e+" failed.\n("+r+": "+o+")",i.name="ChunkLoadError",i.type=r,i.request=o,n[1](i)}},"chunk-"+e,e)}},l=function(e,t){var n,r,o=t[0],i=t[1],a=t[2],u=0;if(o.some(function(e){return 0!==s[e]})){for(n in i)y.o(i,n)&&(y.m[n]=i[n]);a&&a(y)}for(e&&e(t);u<o.length;u++)r=o[u],y.o(s,r)&&s[r]&&s[r][0](),s[r]=0},(f=self.webpackChunk_nocobase_plugin_localization=self.webpackChunk_nocobase_plugin_localization||[]).forEach(l.bind(null,0)),f.push=l.bind(null,f.push.bind(f));var w={};return!function(){"use strict";var e=window.__webpack_public_path__||"/";"/"!==e.charAt(e.length-1)&&(e+="/"),y.p=e+"static/plugins/@nocobase/plugin-localization/dist/client/"}(),!function(){"use strict";y.r(w),y.d(w,{PluginLocalizationClient:function(){return h},default:function(){return v}});var e=y(342),t=y(404),n=y(773),r=y.n(n);function o(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=function(){var e;function t(e){var n=this;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");i(this,"context",void 0),i(this,"sentMissingKeys",void 0),i(this,"pendingMissingKeys",void 0),i(this,"submitPendingKeysDebounced",void 0),i(this,"missingKeyHandler",void 0),i(this,"currentLocale",void 0),this.context=e,this.sentMissingKeys=new Set,this.pendingMissingKeys=new Map,this.submitPendingKeysDebounced=r().debounce(function(){n.submitPendingKeys()},t.DEBOUNCE_DELAY)}return e=[{key:"register",value:function(){var e=this,t=this.context.i18n;t.options.saveMissing=!0,this.missingKeyHandler=function(t,n,r){if(e.context.auth.token&&e.context.flowSettingsEnabled&&"client"!==n&&"ui-schema-storage"!==n){var o,i="".concat(n,":").concat(r);if(!(!r||e.sentMissingKeys.has(i)))try{e.currentLocale=null==(o=e.context.i18n)?void 0:o.language,e.sentMissingKeys.add(i),e.pendingMissingKeys.set(i,{key:r,ns:n}),e.submitPendingKeysDebounced()}catch(e){console.error("[i18n] Error in missingKeyHandler:",e)}}},t.on("missingKey",this.missingKeyHandler)}},{key:"unregister",value:function(){var e=this.context.i18n;e.options.saveMissing=!1,this.missingKeyHandler&&(e.off("missingKey",this.missingKeyHandler),this.missingKeyHandler=void 0)}},{key:"isFallbackClient",value:function(e,n){if(e!==t.fallbackNS)return!1;var r=!0,o=!1,i=void 0;try{for(var a,u=this.pendingMissingKeys.values()[Symbol.iterator]();!(r=(a=u.next()).done);r=!0){var c=a.value;if(c.key===n&&c.ns!==t.fallbackNS)return!0}}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}var s=!0,l=!1,f=void 0;try{for(var p,d=this.sentMissingKeys[Symbol.iterator]();!(s=(p=d.next()).done);s=!0){var y=p.value,b=y.indexOf(":");if(b>-1){var h=y.slice(0,b);if(y.slice(b+1)===n&&h!==t.fallbackNS)return!0}}}catch(e){l=!0,f=e}finally{try{s||null==d.return||d.return()}finally{if(l)throw f}}return!1}},{key:"removeClientFallback",value:function(e){e&&this.pendingMissingKeys.delete("".concat(t.fallbackNS,":").concat(e))}},{key:"submitPendingKeys",value:function(){var e;return(e=function(){var e;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var s=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:if(0===this.pendingMissingKeys.size||!this.context.flowSettingsEnabled)return[2];t.label=1;case 1:return t.trys.push([1,3,,4]),e=Array.from(this.pendingMissingKeys.values()).map(function(e){return{text:e.key,ns:e.ns}}),[4,this.context.api.request({method:"POST",url:"/localizationTexts:missing",data:{keys:e,locale:this.currentLocale}})];case 2:return t.sent(),this.pendingMissingKeys.clear(),[3,4];case 3:return console.error("[i18n] Failed to submit missing keys:",t.sent()),[3,4];case 4:return[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,i){var a=e.apply(t,n);function u(e){o(a,r,i,u,c,"next",e)}function c(e){o(a,r,i,u,c,"throw",e)}u(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(t.prototype,e),t}();i(a,"DEBOUNCE_DELAY",2e3),i(a,"fallbackNS","client");var u=y(631);function c(e,t,n,r,o,i,a){try{var u=e[i](a),c=u.value}catch(e){n(e);return}u.done?t(c):Promise.resolve(c).then(r,o)}function s(e,t,n){return(s=d()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&f(o,n.prototype),o}).apply(null,arguments)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function f(e,t){return(f=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return s(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),f(n,e)})(e)}function d(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(d=function(){return!!e})()}var b=(0,e.lazy)(function(){return u("imported_-237jod_component",y.e("536").then(y.bind(y,555)))},"Localization").Localization,h=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=l(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,d()?Reflect.construct(e,t||[],l(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&f(r,e),n=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),u=Object.defineProperty;return u(a,"next",{value:c(0)}),u(a,"throw",{value:c(1)}),u(a,"return",{value:c(2)}),"function"==typeof Symbol&&u(a,Symbol.iterator,{value:function(){return this}}),a;function c(u){return function(c){var s=[u,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return i.label++,{value:s[1],done:!1};case 5:i.label++,r=s[1],s=[0];continue;case 7:s=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){i.label=s[1];break}if(6===s[0]&&i.label<o[1]){i.label=o[1],o=s;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(s);break}o[2]&&i.ops.pop(),i.trys.pop();continue}s=t.call(e,i)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}}(this,function(e){return new a(this.engine.context).register(),this.app.pluginSettingsManager.add(t.C,{title:'{{t("Localization", { ns: "'.concat(t.C,'" })}}'),icon:"GlobalOutlined",Component:b,aclSnippet:"pm.localization.localization"}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){c(i,r,o,a,u,"next",e)}function u(e){c(i,r,o,a,u,"throw",e)}a(void 0)})}).call(this)}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,n),r}(p(e.Plugin)),v=h}(),w}()});
@@ -11,14 +11,16 @@ module.exports = {
11
11
  "@ant-design/icons": "5.6.1",
12
12
  "@formily/core": "2.3.7",
13
13
  "@formily/react": "2.3.7",
14
- "@nocobase/client": "2.1.0-alpha.1",
14
+ "@nocobase/client": "2.1.0-alpha.10",
15
15
  "ahooks": "3.7.8",
16
16
  "antd": "5.24.2",
17
17
  "react": "18.2.0",
18
- "@nocobase/database": "2.1.0-alpha.1",
19
- "@nocobase/server": "2.1.0-alpha.1",
20
- "@nocobase/utils": "2.1.0-alpha.1",
21
- "@nocobase/cache": "2.1.0-alpha.1",
22
- "@nocobase/actions": "2.1.0-alpha.1",
18
+ "@nocobase/flow-engine": "2.1.0-alpha.10",
19
+ "lodash": "4.17.21",
20
+ "@nocobase/database": "2.1.0-alpha.10",
21
+ "@nocobase/server": "2.1.0-alpha.10",
22
+ "@nocobase/utils": "2.1.0-alpha.10",
23
+ "@nocobase/cache": "2.1.0-alpha.10",
24
+ "@nocobase/actions": "2.1.0-alpha.10",
23
25
  "react-i18next": "11.18.6"
24
26
  };
@@ -9,5 +9,6 @@
9
9
  import { Context, Next } from '@nocobase/actions';
10
10
  declare const _default: {
11
11
  list: (ctx: Context, next: Next) => Promise<void>;
12
+ missing: (ctx: Context, next: Next) => Promise<void>;
12
13
  };
13
14
  export default _default;
@@ -141,4 +141,34 @@ const list = async (ctx, next) => {
141
141
  };
142
142
  await next();
143
143
  };
144
- var localizationTexts_default = { list };
144
+ const missing = async (ctx, next) => {
145
+ var _a;
146
+ const { keys, locale } = ctx.request.body || {};
147
+ const currentRoles = ctx.state.currentRoles || [];
148
+ if (!currentRoles.includes("root")) {
149
+ const roles = await ctx.db.getRepository("roles").find({
150
+ filter: {
151
+ name: currentRoles
152
+ }
153
+ });
154
+ const hasUiSnippet = roles.some((role) => {
155
+ const snippets = role.get("snippets") || [];
156
+ return snippets.includes("ui.*");
157
+ });
158
+ if (!hasUiSnippet) {
159
+ ctx.throw(403, "No permission");
160
+ }
161
+ }
162
+ if ((keys == null ? void 0 : keys.length) > 0) {
163
+ const plugin = (_a = ctx.app.pm) == null ? void 0 : _a.get("localization");
164
+ const currentLocale = locale || ctx.get("X-Locale") || "en-US";
165
+ await (plugin == null ? void 0 : plugin.addNewTexts(
166
+ keys.map((key) => ({ text: key.text, module: `resources.${key.ns}` })),
167
+ {
168
+ locale: currentLocale
169
+ }
170
+ ));
171
+ }
172
+ await next();
173
+ };
174
+ var localizationTexts_default = { list, missing };
@@ -6,6 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ /// <reference types="node" />
9
10
  import { InstallOptions, Plugin } from '@nocobase/server';
10
11
  import Resources from './resources';
11
12
  import { SourceManager } from './source-manager';
@@ -15,7 +16,10 @@ export declare class PluginLocalizationServer extends Plugin {
15
16
  addNewTexts: (texts: {
16
17
  text: string;
17
18
  module: string;
18
- }[], options?: any) => Promise<void>;
19
+ }[], options?: {
20
+ transaction?: any;
21
+ locale?: string;
22
+ }) => Promise<void>;
19
23
  afterAdd(): void;
20
24
  beforeLoad(): void;
21
25
  load(): Promise<void>;
@@ -62,7 +62,7 @@ class PluginLocalizationServer extends import_server.Plugin {
62
62
  {
63
63
  transaction: options == null ? void 0 : options.transaction
64
64
  }
65
- ).then((newTexts) => {
65
+ ).then(async (newTexts) => {
66
66
  this.resources.updateCacheTexts(newTexts, options == null ? void 0 : options.transaction);
67
67
  this.sendSyncMessage(
68
68
  {
@@ -71,6 +71,18 @@ class PluginLocalizationServer extends import_server.Plugin {
71
71
  },
72
72
  { transaction: options == null ? void 0 : options.transaction }
73
73
  );
74
+ if ((options == null ? void 0 : options.locale) && (newTexts == null ? void 0 : newTexts.length)) {
75
+ await this.db.getModel("localizationTranslations").bulkCreate(
76
+ newTexts.map((text) => ({
77
+ locale: options.locale,
78
+ translation: text.get("text"),
79
+ textId: text.get("id")
80
+ })),
81
+ {
82
+ transaction: options == null ? void 0 : options.transaction
83
+ }
84
+ );
85
+ }
74
86
  }).catch((err) => {
75
87
  this.log.error(err);
76
88
  });
@@ -93,6 +105,10 @@ class PluginLocalizationServer extends import_server.Plugin {
93
105
  name: `pm.${this.name}.localization`,
94
106
  actions: ["localization:*", "localizationTexts:*", "localizationTranslations:*"]
95
107
  });
108
+ this.app.acl.registerSnippet({
109
+ name: "ui.localization",
110
+ actions: ["localizationTexts:missing"]
111
+ });
96
112
  this.app.localeManager.registerResourceStorer("plugin-localization", {
97
113
  getResources: (lang) => this.resources.getResources(lang),
98
114
  reset: () => this.resources.reset()
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-localization",
3
- "version": "2.1.0-alpha.1",
3
+ "version": "2.1.0-alpha.10",
4
4
  "main": "dist/server/index.js",
5
5
  "homepage": "https://docs.nocobase.com/handbook/localization-management",
6
6
  "homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/localization-management",
7
7
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/localization-management",
8
- "license": "AGPL-3.0",
8
+ "license": "Apache-2.0",
9
9
  "devDependencies": {
10
10
  "deepmerge": "^4.3.1"
11
11
  },
@@ -25,5 +25,5 @@
25
25
  "description": "Allows to manage localization resources of the application.",
26
26
  "description.ru-RU": "Позволяет управлять ресурсами локализации приложения.",
27
27
  "description.zh-CN": "支持管理应用程序的本地化资源。",
28
- "gitHead": "d27baf21569643d6fa83f882233f4e90eb5b89f1"
28
+ "gitHead": "ce790d46c0a5768ca9618c7d0d77ab8300de75c8"
29
29
  }
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_localization=self.webpackChunk_nocobase_plugin_localization||[]).push([["121"],{730:function(e,t,n){n.r(t),n.d(t,{Localization:function(){return P}});var o=n(482),r=n(563),l=n(505),a=n(772),i=n(749),c=n(721),u=n(156),s=n.n(u),p=n(551),m={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"})}}'}]}}]},d={type:"void",name:"localization","x-decorator":"ResourceActionProvider","x-decorator-props":{collection:m,resourceName:"localizationTexts",request:{resource:"localizationTexts",action:"list",params:{pageSize:50}}},"x-component":"CollectionProvider_deprecated","x-component-props":{collection:m},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":"ModuleTitle"}}},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:{title:'{{t("Module")}}',"x-component":"ModuleTitle","x-decorator":"FormItem"},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()}}"}}}}}}}}};function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function y(e,t,n,o,r,l,a){try{var i=e[l](a),c=i.value}catch(e){n(e);return}i.done?t(c):Promise.resolve(c).then(o,r)}function h(e){return function(){var t=this,n=arguments;return new Promise(function(o,r){var l=e.apply(t,n);function a(e){y(l,o,r,a,i,"next",e)}function i(e){y(l,o,r,a,i,"throw",e)}a(void 0)})}}function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}function b(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function v(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,o,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var l=[],a=!0,i=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(i)throw o}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return f(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function g(e,t){var n,o,r,l,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var c=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,o&&(r=2&c[0]?o.return:c[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,c[1])).done)return r;switch(o=0,r&&(c=[2&c[0],r.value]),c[0]){case 0:case 1:r=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,o=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(r=(r=a.trys).length>0&&r[r.length-1])&&(6===c[0]||2===c[0])){a=0;continue}if(3===c[0]&&(!r||c[1]>r[0]&&c[1]<r[3])){a.label=c[1];break}if(6===c[0]&&a.label<r[1]){a.label=r[1],r=c;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(c);break}r[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],o=0}finally{n=r=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}var A=c.Typography.Text,C=function(){var e=(0,l.useField)(),t=(0,l.useForm)(),n=(0,a.useActionContext)(),o=(0,a.useResourceActionContext)().refresh,r=(0,a.useResourceContext)().targetKey,i=(0,a.useRecord)()[r],c=(0,a.useAPIClient)(),u=c.auth.getLocale();return{run:function(){return h(function(){return g(this,function(r){switch(r.label){case 0:return[4,t.submit()];case 1:r.sent(),e.data=e.data||{},e.data.loading=!0,r.label=2;case 2:return r.trys.push([2,5,6,7]),[4,c.resource("localizationTranslations").updateOrCreate({filterKeys:["textId","locale"],values:{textId:i,locale:u,translation:t.values.translation}})];case 3:return r.sent(),n.setVisible(!1),[4,t.reset()];case 4:return r.sent(),o(),[3,7];case 5:return console.log(r.sent()),[3,7];case 6:return e.data.loading=!1,[7];case 7:return[2]}})})()}}},T=function(){var e=(0,a.useResourceActionContext)().refresh,t=(0,a.useAPIClient)(),n=(0,a.useRecord)().translationId;return{run:function(){return h(function(){return g(this,function(o){switch(o.label){case 0:if(!n)return[2];return[4,t.resource("localizationTranslations").destroy({filterByTk:n})];case 1:return o.sent(),e(),[2]}})})()}}},w=function(){var e=(0,a.useResourceActionContext)(),t=e.state,n=e.setState,o=e.refresh,r=(0,a.useAPIClient)(),l=(0,p.F)().t;return{run:function(){return h(function(){var e;return g(this,function(a){switch(a.label){case 0:if(!(null==t||null==(e=t.selectedRowKeys)?void 0:e.length))return[2,c.message.error(l("Please select the records you want to delete"))];return[4,r.resource("localizationTranslations").destroy({filterByTk:null==t?void 0:t.selectedRowKeys})];case 1:return a.sent(),null==n||n({selectedRowKeys:[]}),o(),[2]}})})()}}},S=function(){var e=(0,a.useAPIClient)();return{run:function(){return h(function(){return g(this,function(t){switch(t.label){case 0:return[4,e.resource("localization").publish()];case 1:return t.sent(),window.location.reload(),[2]}})})()}}},F=function(){var e=(0,p.F)().t,t=(0,a.useResourceActionContext)().refresh,n=(0,a.useAPIClient)(),r=v((0,u.useState)(!1),2),i=r[0],m=r[1],d=v((0,u.useState)([]),2),f=d[0],y=d[1],x=v((0,u.useState)([]),2),b=x[0],A=x[1],C=v((0,u.useState)(!1),2),T=C[0],w=C[1],S=v((0,u.useState)(!0),2),F=S[0],E=S[1],k=(0,a.useRequest)(function(){return n.resource("localization").getSources().then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data})},{onSuccess:function(e){var t=e.map(function(e){return e.name});y(t),A(t)}}),O=k.data;return k.loading?null:s().createElement(a.StablePopover,{placement:"bottomRight",content:s().createElement(s().Fragment,null,s().createElement(c.Checkbox,{indeterminate:T,onChange:function(e){A(e.target.checked?f:[]),w(!1),E(e.target.checked)},checked:F},e("All")),s().createElement(c.Divider,{style:{margin:"5px 0"}}),s().createElement(c.Checkbox.Group,{onChange:function(e){A(e),w(!!e.length&&e.length<f.length),E(e.length===f.length)},value:b},s().createElement(c.Col,null,(O||[]).map(function(t){return s().createElement(c.Row,{key:t.name},s().createElement(c.Checkbox,{value:t.name},l.Schema.compile(t.title,{t:e})))}))))},s().createElement(c.Button,{icon:s().createElement(o.SyncOutlined,null),loading:i,onClick:h(function(){return g(this,function(o){switch(o.label){case 0:if(!b.length)return[2,c.message.error(e("Please select the resources you want to synchronize"))];return m(!0),[4,n.resource("localization").sync({values:{types:b}})];case 1:return o.sent(),m(!1),t(),[2]}})})},e("Sync")))},E=function(){var e,t=(0,p.F)().t,n=(0,i.useMemoizedFn)(t),o=(0,a.useResourceActionContext)().data;return(0,u.useMemo)(function(){var e,t;return(null==o||null==(t=o.meta)||null==(e=t.modules)?void 0:e.map(function(e){return{value:e.value,label:l.Schema.compile(e.label,{t:n})}}))||[]},[null==o||null==(e=o.meta)?void 0:e.modules,n])},k=function(){var e=(0,p.F)().t,t=(0,a.useResourceActionContext)().run,n=E(),o=(0,u.useMemo)(function(){return(0,r.createForm)({initialValues:{hasTranslation:!0}})},[]),i=function(e){t(x({},e||o.values))};return(0,u.useEffect)(function(){o.query("module").take().dataSource=n},[o,n]),s().createElement(a.FormProvider,{form:o},s().createElement("div",{style:{display:"flex"}},s().createElement(l.Field,{name:"module",dataSource:n,component:[a.Select,{allowClear:!0,placeholder:e("Module"),onChange:function(e){return i(b(x({},o.values),{module:e}))}}]}),s().createElement(l.Field,{name:"keyword",component:[c.Input.Search,{placeholder:e("Keyword"),allowClear:!0,style:{marginLeft:"8px",width:"fit-content"},onSearch:function(e){return i(b(x({},o.values),{keyword:e}))}}]}),s().createElement(l.Field,{name:"hasTranslation",dataSource:[{label:e("All"),value:!0},{label:e("No translation"),value:!1}],component:[a.Radio.Group,{defaultValue:!0,style:{marginLeft:"8px",width:"fit-content"},optionType:"button",onChange:function(){return i()}}]})))},O=function(){var e=(0,p.F)().t,t=(0,a.useRecord)().moduleTitle;return s().createElement(c.Tag,null,l.Schema.compile(t,{t:e}))},P=function(){var e,t=(0,p.F)().t,n=(0,a.useAPIClient)().auth.getLocale(),o=(null==(e=a.locale[n])?void 0:e.label)||n;return s().createElement(c.Card,{bordered:!1},s().createElement(a.SchemaComponent,{schema:d,components:{TranslationField:function(e){return void 0!==e.value?s().createElement(a.Input.TextArea,e):s().createElement("div",null)},CurrentLang:function(){return s().createElement(c.Typography,null,s().createElement(A,{strong:!0},t("Current language")),s().createElement(c.Tag,{style:{marginLeft:"10px"}},o))},Sync:F,Filter:k,ModuleTitle:O},scope:{t:t,useDestroyTranslationAction:T,useBulkDestroyTranslationAction:w,useUpdateTranslationAction:C,usePublishAction:S,useModules:E}}))}}}]);