From dc74074bddcfdbf9eb025792d9ad9cc18e120fd0 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 29 Jun 2026 12:03:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20bricks=20i18n=20=E2=80=94=20=E7=A1=AC?= =?UTF-8?q?=E7=BC=96=E7=A0=81=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=94=B9=E7=94=A8?= =?UTF-8?q?=20i18n.=5F()=20+=20=E7=BF=BB=E8=AF=91=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 编译的 dist/ 目录新增 i18n/{zh,en,jp,ko}/ 自动注入到 sage wwwroot/bricks/i18n/ 翻译的字符串: - conform.js: Conform/Discard → i18n._() - dynamicaccordion.js: add a new record → i18n._() - form.js: Submit/Reset/Cancel/Requirement → i18n._() - jsoncall.js: access error → i18n._() - llm.js: 知识库/召回数量/模版 → i18n._() build.sh 新增 i18n 目录复制到 dist --- bricks/build.sh | 5 +++++ bricks/conform.js | 4 ++-- bricks/dynamicaccordion.js | 2 +- bricks/form.js | 12 ++++++------ bricks/jsoncall.js | 4 ++-- bricks/llm.js | 6 +++--- i18n/en/msg.txt | 12 ++++++++++++ i18n/jp/msg.txt | 12 ++++++++++++ i18n/ko/msg.txt | 12 ++++++++++++ i18n/zh/msg.txt | 12 ++++++++++++ 10 files changed, 67 insertions(+), 14 deletions(-) create mode 100644 i18n/en/msg.txt create mode 100644 i18n/jp/msg.txt create mode 100644 i18n/ko/msg.txt create mode 100644 i18n/zh/msg.txt diff --git a/bricks/build.sh b/bricks/build.sh index 89ad0b5..594fe74 100755 --- a/bricks/build.sh +++ b/bricks/build.sh @@ -42,4 +42,9 @@ cp -a ../examples/* ../dist/examples cp -a ../3parties/* ../dist/3parties cp -a ../docs/* ../dist/docs cp *.tmpl ../dist +if [ ! -d ../dist/i18n ];then + rm -rf ../dist/i18n + mkdir ../dist/i18n +fi +cp -a ../i18n/* ../dist/i18n echo "Finished ..." diff --git a/bricks/conform.js b/bricks/conform.js index 03940dd..dc461dc 100644 --- a/bricks/conform.js +++ b/bricks/conform.js @@ -29,12 +29,12 @@ bricks.Conform = class extends bricks.PopupWindow { bricks.extend({ "name":"conform", "icon":bricks_resource('imgs/conform.svg'), - "label":'Conform' + "label":bricks.app.i18n._('Conform') }, this.opts.conform||{}), bricks.extend({ "name":"discard", "icon":bricks_resource('imgs/cancel.svg'), - "label":"Discard" + "label":bricks.app.i18n._("Discard") }, this.opts.discard||{}) ] } diff --git a/bricks/dynamicaccordion.js b/bricks/dynamicaccordion.js index 0163fe2..569cf76 100644 --- a/bricks/dynamicaccordion.js +++ b/bricks/dynamicaccordion.js @@ -275,7 +275,7 @@ bricks.DynamicAccordion = class extends bricks.VScrollPanel { "tools":[ { "name":"add", - "tip":"add a new record", + "tip":bricks.app.i18n._("add a new record"), "icon":this.editable.add_icon || bricks_resource('imgs/add.svg') } ] diff --git a/bricks/form.js b/bricks/form.js index 428b214..5959a33 100644 --- a/bricks/form.js +++ b/bricks/form.js @@ -251,19 +251,19 @@ bricks.FormBase = class extends bricks.Layout { icon:bricks_resource('imgs/submit.svg'), name:'submit', css:'submit_btn', - label:'Submit' + label:bricks.app.i18n._('Submit') }, { icon:bricks_resource('imgs/reset.svg'), name:'reset', css:'reset_btn', - label:'Reset' + label:bricks.app.i18n._('Reset') }, { icon:bricks_resource('imgs/cancel.svg'), name:'cancel', css:'clear_btn', - label:'Cancel' + label:bricks.app.i18n._('Cancel') } ] var tb_desc={}; @@ -338,7 +338,7 @@ bricks.FormBase = class extends bricks.Layout { var d = w.getValue(); if (w.required && ( d[name] == '' || d[name] === null)){ bricks.debug('data=', data, 'd=', d); - new bricks.Error({title:'Requirement', message:'required field must input"' + w.label + '"'}) + new bricks.Error({title:bricks.app.i18n._('Requirement'), message:bricks.app.i18n._('required field must input') + '"' + w.label + '"'}) w.focus(); return; } @@ -392,7 +392,7 @@ bricks.FormBase = class extends bricks.Layout { if (w.parent.is_disabled()) continue; var d = w.getValue(); if (w.required && ( d[name] == '' || d[name] === null)){ - new bricks.Error({title:'Requirement', message:'required field must input"' + w.label + '"'}) + new bricks.Error({title:bricks.app.i18n._('Requirement'), message:bricks.app.i18n._('required field must input') + '"' + w.label + '"'}) w.focus(); return; } @@ -544,7 +544,7 @@ bricks.InlineForm = class extends bricks.HBox { build_submit(){ this.add_widget(new bricks.Filler()); var btnopts = { - label: this.opts.submit_label || 'Submit', + label: this.opts.submit_label || bricks.app.i18n._('Submit'), css: this.opts.submit_css || 'primary' }; if (this.opts.submit_icon) btnopts.icon = this.opts.submit_icon; diff --git a/bricks/jsoncall.js b/bricks/jsoncall.js index d20a415..02d1bcc 100644 --- a/bricks/jsoncall.js +++ b/bricks/jsoncall.js @@ -137,7 +137,7 @@ bricks.HttpText = class { } if (fetchResult.status == 403){ var w = new bricks.Error({ - "title":"access error", + "title":bricks.app.i18n._("access error"), "auto_open":true, "message":"you are forbidden to access it", "archor":"cc", @@ -149,7 +149,7 @@ bricks.HttpText = class { } if (! fetchResult.ok){ var w = new bricks.Error({ - "title":"access error", + "title":bricks.app.i18n._("access error"), "auto_open":true, "message":"server return error with error code" + fetchResult.status, "archor":"cc", diff --git a/bricks/llm.js b/bricks/llm.js index 49ed9b2..a99bfca 100644 --- a/bricks/llm.js +++ b/bricks/llm.js @@ -531,7 +531,7 @@ bricks.LlmIO = class extends bricks.VBox { "uitype":"checkbox", "multicheck": true, "required": true, - "label":"知识库", + "label":bricks.app.i18n._("知识库"), "valueField":"id", "textField":"name", "dataurl":this.get_kdb_url @@ -540,14 +540,14 @@ bricks.LlmIO = class extends bricks.VBox { "name":"recall_cnt", "uitype":"int", "value": data.recall_cnt, - "label":"召回数量" + "label":bricks.app.i18n._("召回数量") }, { "name":"prompt_tmpl", "value":data.prompt_tmpl, "uitype":"text", "required": true, - "label":"模版" + "label":bricks.app.i18n._("模版") } ] } diff --git a/i18n/en/msg.txt b/i18n/en/msg.txt new file mode 100644 index 0000000..302054f --- /dev/null +++ b/i18n/en/msg.txt @@ -0,0 +1,12 @@ +Conform: Confirm +Discard: Discard +add a new record: Add a new record +Submit: Submit +Reset: Reset +Cancel: Cancel +Requirement: Requirement +required field must input: Required field must input +access error: Access error +知识库: Knowledge Base +召回数量: Recall Count +模版: Template diff --git a/i18n/jp/msg.txt b/i18n/jp/msg.txt new file mode 100644 index 0000000..a8e5152 --- /dev/null +++ b/i18n/jp/msg.txt @@ -0,0 +1,12 @@ +Conform: 確認 +Discard: 破棄 +add a new record: 新規レコード追加 +Submit: 提出 +Reset: リセット +Cancel: キャンセル +Requirement: 必須 +required field must input: 必須フィールドを入力してください +access error: アクセスエラー +知识库: 知識ベース +召回数量: 検索数 +模版: テンプレート diff --git a/i18n/ko/msg.txt b/i18n/ko/msg.txt new file mode 100644 index 0000000..092246c --- /dev/null +++ b/i18n/ko/msg.txt @@ -0,0 +1,12 @@ +Conform: 확인 +Discard: 취소 +add a new record: 새 레코드 추가 +Submit: 제출 +Reset: 재설정 +Cancel: 취소 +Requirement: 필수 +required field must input: 필수 필드를 입력하세요 +access error: 액세스 오류 +知识库: 지식 베이스 +召回数量: 검색 수 +模版: 템플릿 diff --git a/i18n/zh/msg.txt b/i18n/zh/msg.txt new file mode 100644 index 0000000..c879e7f --- /dev/null +++ b/i18n/zh/msg.txt @@ -0,0 +1,12 @@ +Conform: 确认 +Discard: 放弃 +add a new record: 添加新记录 +Submit: 提交 +Reset: 重置 +Cancel: 取消 +Requirement: 必填 +required field must input: 必填字段必须输入 +access error: 访问错误 +知识库: 知识库 +召回数量: 召回数量 +模版: 模版