Browse Source

chore: add international components ecard

richard1015 3 years ago
parent
commit
2e2a7f675f

+ 0 - 1
src/packages/__VUE/ecard/demo.vue

@@ -3,7 +3,6 @@
     <h2>基础用法</h2>
     <nut-cell>
       <nut-ecard
-        chooseText="请选择电子卡面值"
         @inputChange="inputChange"
         @change="change"
         @changeStep="changeStep"

+ 14 - 8
src/packages/__VUE/ecard/index.taro.vue

@@ -1,6 +1,6 @@
 <template>
   <view class="nut-ecard">
-    <view class="nut-ecard__title">{{ chooseText }}</view>
+    <view class="nut-ecard__title">{{ chooseText || translate('chooseText') }}</view>
     <view class="nut-ecard__list">
       <view
         v-for="(item, index) in dataList"
@@ -11,9 +11,14 @@
         {{ item.price }}
       </view>
       <view :class="['nut-ecard__list__input', currentIndex == 'input' ? 'active' : '']" @click="inputClick">
-        <view>{{ otherValueText }}</view>
+        <view>{{ otherValueText || translate('otherValueText') }}</view>
         <view class="nut-ecard__list__input--con">
-          <input type="text" :value="inputValue" @input="change" :placeholder="placeholder" />
+          <input
+            type="text"
+            v-model="inputValue"
+            @input="change"
+            :placeholder="placeholder || translate('placeholder')"
+          />
           {{ suffix }}
         </view>
       </view>
@@ -27,16 +32,16 @@
 <script lang="ts">
 import { Ref, ref, watch } from 'vue';
 import { createComponent } from '../../utils/create';
-const { componentName, create } = createComponent('ecard');
+const { componentName, create, translate } = createComponent('ecard');
 export default create({
   props: {
     chooseText: {
       type: String,
-      default: '请选择电子卡面值'
+      default: ''
     },
     otherValueText: {
       type: String,
-      default: '其他面值'
+      default: ''
     },
     dataList: {
       type: [Object, Array],
@@ -66,7 +71,7 @@ export default create({
     },
     placeholder: {
       type: String,
-      default: '请输入1-5000整数'
+      default: ''
     },
     suffix: {
       type: String,
@@ -122,7 +127,8 @@ export default create({
       stepValue,
       currentIndex,
       inputValue,
-      money
+      money,
+      translate
     };
   }
 });

+ 14 - 8
src/packages/__VUE/ecard/index.vue

@@ -1,6 +1,6 @@
 <template>
   <view class="nut-ecard">
-    <view class="nut-ecard__title">{{ chooseText }}</view>
+    <view class="nut-ecard__title">{{ chooseText || translate('chooseText') }}</view>
     <view class="nut-ecard__list">
       <view
         v-for="(item, index) in dataList"
@@ -11,9 +11,14 @@
         {{ item.price }}
       </view>
       <view :class="['nut-ecard__list__input', currentIndex == 'input' ? 'active' : '']" @click="inputClick">
-        <view>{{ otherValueText }}</view>
+        <view>{{ otherValueText || translate('otherValueText') }}</view>
         <view class="nut-ecard__list__input--con">
-          <input type="text" v-model="inputValue" @input="change" :placeholder="placeholder" />
+          <input
+            type="text"
+            v-model="inputValue"
+            @input="change"
+            :placeholder="placeholder || translate('placeholder')"
+          />
           {{ suffix }}
         </view>
       </view>
@@ -27,7 +32,7 @@
 <script lang="ts">
 import { Ref, ref, watch } from 'vue';
 import { createComponent } from '../../utils/create';
-const { componentName, create } = createComponent('ecard');
+const { componentName, create, translate } = createComponent('ecard');
 
 interface props {
   chooseText: string; // 选择文案
@@ -46,11 +51,11 @@ export default create({
   props: {
     chooseText: {
       type: String,
-      default: '请选择电子卡面值'
+      default: ''
     },
     otherValueText: {
       type: String,
-      default: '其他面值'
+      default: ''
     },
     dataList: {
       type: [Object, Array],
@@ -80,7 +85,7 @@ export default create({
     },
     placeholder: {
       type: String,
-      default: '请输入1-5000整数'
+      default: ''
     },
     suffix: {
       type: String,
@@ -135,7 +140,8 @@ export default create({
       stepValue,
       currentIndex,
       inputValue,
-      money
+      money,
+      translate
     };
   }
 });

+ 1 - 0
src/packages/__VUE/progress/test/__snapshots__/index.spec.ts.snap

@@ -5,6 +5,7 @@ exports[`should render progress when use props 1`] = `
   <div class=\\"nut-progress-outer nut-progress-outer-part nut-progress-base\\">
     <div class=\\"nut-progress-inner\\" style=\\"width: 100%;\\">
       <!--v-if-->
+      <!--v-if-->
     </div>
   </div>
   <div class=\\"nut-progress-text\\" style=\\"line-height: px;\\"><span>100%</span></div>

+ 1 - 1
src/packages/locale/index.ts

@@ -2,7 +2,7 @@ import { ref, reactive } from 'vue';
 import lang from './lang/zh-CN';
 import defaultLang from './lang/zh-CN';
 import enUSLang from './lang/en-US';
-const currentLang = ref('en-US');
+const currentLang = ref('zh-CN');
 
 type lang = Record<string, any>;
 const langs = reactive<lang>({

+ 5 - 0
src/packages/locale/lang/baseLang.ts

@@ -54,4 +54,9 @@ export interface BaseLang {
     reSign: string;
     unSupportTpl: string;
   };
+  ecard: {
+    chooseText: string;
+    otherValueText: string;
+    placeholder: string;
+  };
 }

+ 6 - 1
src/packages/locale/lang/en-US.ts

@@ -52,8 +52,13 @@ const lang: BaseLang = {
     chooseAnotherAddress: 'Choose Another Address'
   },
   signature: {
-    reSign: 're-sign',
+    reSign: 'Re Sign',
     unSupportTpl: `Sorry, the current browser doesn't support canvas, so we can't use this control!`
+  },
+  ecard: {
+    chooseText: 'Select',
+    otherValueText: 'Other Value',
+    placeholder: 'Placeholder'
   }
 };
 export default lang;

+ 5 - 0
src/packages/locale/lang/zh-CN.ts

@@ -54,6 +54,11 @@ const lang: BaseLang = {
   signature: {
     reSign: '重签',
     unSupportTpl: '对不起,当前浏览器不支持Canvas,无法使用本控件!'
+  },
+  ecard: {
+    chooseText: '请选择电子卡面值',
+    otherValueText: '其他面值',
+    placeholder: '请输入1-5000整数'
   }
 };
 export default lang;

+ 0 - 1
src/sites/mobile-taro/vue/src/business/pages/ecard/index.vue

@@ -3,7 +3,6 @@
     <h2>基础用法</h2>
     <nut-cell>
       <nut-ecard
-        chooseText="请选择电子卡面值"
         @inputChange="inputChange"
         @change="change"
         @changeStep="changeStep"