Browse Source

add i18n for file input button label

wangweimin 3 năm trước cách đây
mục cha
commit
0da4078eff
2 tập tin đã thay đổi với 4 bổ sung2 xóa
  1. 2 0
      webiojs/src/i18n.ts
  2. 2 2
      webiojs/src/models/input/file.ts

+ 2 - 0
webiojs/src/i18n.ts

@@ -15,6 +15,7 @@ const translations: { [lang: string]: { [msgid: string]: string } } = {
         "reset": "Reset",
         "cancel": "Cancel",
         "duplicated_pin_name": "This pin widget has expired (due to the output of a new pin widget with the same name ).",
+        "browse_file": "Browse",
     },
     "zh": {
         "disconnected_with_server": "与服务器连接已断开,请刷新页面重新操作",
@@ -26,6 +27,7 @@ const translations: { [lang: string]: { [msgid: string]: string } } = {
         "reset": "重置",
         "cancel": "取消",
         "duplicated_pin_name": "该 Pin widget 已失效(由于输出了新的同名 pin widget)",
+        "browse_file": "浏览文件",
     },
 };
 

+ 2 - 2
webiojs/src/models/input/file.ts

@@ -7,7 +7,7 @@ const file_input_tpl = `
     {{#label}}<label for="{{id_name}}">{{label}}</label>{{/label}}
     <div class="custom-file">
         <input type="file" name="{{name}}" class="custom-file-input" id="{{id_name}}" aria-describedby="{{id_name}}_help">
-        <label class="custom-file-label" for="{{id_name}}"><span>{{placeholder}}</span></label>
+        <label class="custom-file-label" for="{{id_name}}" data-browse="{{browse_file}}"><span>{{placeholder}}</span></label>
         <div class="invalid-feedback">{{invalid_feedback}}</div>  <!-- input 添加 is-invalid 类 -->
         <div class="valid-feedback">{{valid_feedback}}</div> <!-- input 添加 is-valid 类 -->
         <small id="{{id_name}}_help"  class="form-text text-muted">{{help_text}}</small>
@@ -29,7 +29,7 @@ export class File extends InputItem {
         const id_name = spec.name + '-' + Math.floor(Math.random() * Math.floor(9999));
         spec['id_name'] = id_name;
 
-        const html = Mustache.render(file_input_tpl, spec);
+        const html = Mustache.render(file_input_tpl, {...spec, browse_file: t('browse_file')});
         this.element = $(html);
         let input_elem = this.element.find('input[type="file"]');