Przeglądaj źródła

增加国际化支持

wzh 2 lat temu
rodzic
commit
8c4b83582f

+ 8 - 0
locale/en.json

@@ -0,0 +1,8 @@
+{
+  "locale.auto": "System",
+  "locale.en": "English",
+  "locale.zh-hans": "简体中文",
+  "login": {
+    "input": ""
+  }
+}

+ 10 - 0
locale/index.js

@@ -0,0 +1,10 @@
+import en from './en.json'
+import zhHans from './zh-Hans.json'
+import zhHant from './zh-Hant.json'
+import ja from './ja.json'
+export default {
+	en,
+	'zh-Hans': zhHans,
+	'zh-Hant': zhHant,
+	ja
+}

+ 23 - 0
locale/ja.json

@@ -0,0 +1,23 @@
+{
+  "locale.auto": "システム",
+  "locale.en": "英語",
+  "locale.zh-hans": "简体中文",
+  "locale.zh-hant": "繁体中文",
+  "locale.ja": "日语",
+  "index.title": "Hello i18n",
+  "index.home": "ホーム",
+  "index.component": "コンポーネント",
+  "index.api": "API",
+  "index.schema": "Schema",
+  "index.demo": "uni-app globalization",
+  "index.demo-description": "ユニフレームワーク、manifest.json、pages.json、タブバー、ページ、コンポーネント、APIを含める、Schema",
+  "index.detail": "詳細",
+  "index.language": "言語",
+  "index.language-info": "設定",
+  "index.system-language": "システム言語",
+  "index.application-language": "アプリケーション言語",
+  "index.language-change-confirm": "この設定を適用すると、アプリが再起動します",
+  "api.message": "メッセージ",
+  "schema.add": "追加",
+  "schema.add-success": "成功を追加"
+}

+ 36 - 0
locale/uni-app.ja.json

@@ -0,0 +1,36 @@
+{
+  "common": {
+    "uni.app.quit": "もう一度押すと、アプリケーションが終了します",
+    "uni.async.error": "サーバーへの接続がタイムアウトしました。画面をクリックして再試行してください",
+    "uni.showActionSheet.cancel": "キャンセル",
+    "uni.showToast.unpaired": "使用するには、showToastとhideToastをペアにする必要があることに注意してください",
+    "uni.showLoading.unpaired": "使用するには、showLoadingとhideLoadingをペアにする必要があることに注意してください",
+    "uni.showModal.cancel": "キャンセル",
+    "uni.showModal.confirm": "OK",
+    "uni.chooseImage.cancel": "キャンセル",
+    "uni.chooseImage.sourceType.album": "アルバムから選択",
+    "uni.chooseImage.sourceType.camera": "カメラ",
+    "uni.chooseVideo.cancel": "キャンセル",
+    "uni.chooseVideo.sourceType.album": "アルバムから選択",
+    "uni.chooseVideo.sourceType.camera": "カメラ",
+    "uni.previewImage.cancel": "キャンセル",
+    "uni.previewImage.button.save": "画像を保存",
+    "uni.previewImage.save.success": "画像をアルバムに正常に保存します",
+    "uni.previewImage.save.fail": "画像をアルバムに保存できませんでした",
+    "uni.setClipboardData.success": "コンテンツがコピーされました",
+    "uni.scanCode.title": "スキャンコード",
+    "uni.scanCode.album": "アルバム",
+    "uni.scanCode.fail": "認識に失敗しました",
+    "uni.scanCode.flash.on": "タッチして点灯",
+    "uni.scanCode.flash.off": "タップして閉じる",
+    "uni.startSoterAuthentication.authContent": "指紋認識...",
+    "uni.picker.done": "完了",
+    "uni.picker.cancel": "キャンセル",
+    "uni.video.danmu": "「弾幕」",
+    "uni.video.volume": "ボリューム",
+    "uni.button.feedback.title": "質問のフィードバック",
+    "uni.button.feedback.send": "送信"
+  },
+  "ios": {},
+  "android": {}
+}

+ 52 - 0
locale/zh-Hans.json

@@ -0,0 +1,52 @@
+{
+	"locale.auto": "系统",
+	"locale.en": "English",
+	"locale.zh-hans": "简体中文",
+	"locale.zh-hant": "繁体中文",
+	"locale.ja": "日语",
+	"login": {
+		"mailInput": "请输入邮箱",
+		"pwdInput": "请输入密码",
+		"noAccount": "暂无账号",
+		"resiger":"立即注册",
+		"tologin": "立即登录",
+		"buletooth":"蓝牙连接",
+		"logintip": "请输入账号",
+		"pwdtip": "请输入密码",
+		"logining": "登陆中,请等待"
+	},
+	"register": {
+		"logintip": "请输入账号",
+		"pwdtip": "请输入密码",
+		"logining": "注册中,请等待"
+	},
+	"buletooth": {
+		"nodevice": "未发现设备,请确认蓝牙已经打开",
+		"init": "蓝牙初始化中",
+		"nopwd": "密码不能为空",
+		"pwdtip": "6位数字密码",
+		"pwdinput": "请输入操作密码",
+		"errpwd": "密码不能为空",
+		"connecting": "设备连接中",
+		"tip": "提示"
+	},
+	"charge": {
+		"break": "断开连接",
+		"modifypwd": "修改密码",
+		"charging": "充电中",
+		"planed": " 已预约",
+		"connected": "已连接",
+		"devtemper": "设备温度",
+		"voltage": "设备电压",
+		"current": "设备电流",
+		"chargetime": "已冲时间",
+		"power": "充电功率",
+
+
+		"startcharge": "开始充电",
+		"getinfo": "获取状态",
+		"oldpwd": "原密码",
+		"newpwd": "6位数字新密码",
+		"elec": "已冲电量"
+	}
+}

+ 24 - 0
locale/zh-Hant.json

@@ -0,0 +1,24 @@
+{
+  "locale.auto": "系統",
+  "locale.en": "English",
+  "locale.zh-hans": "简体中文",
+  "locale.zh-hant": "繁體中文",
+  "locale.ja": "日语",
+  "index.title": "Hello i18n",
+  "index.home": "主頁",
+  "index.component": "組件",
+  "index.api": "API",
+  "index.schema": "Schema",
+  "index.demo": "uni-app 國際化演示",
+  "index.demo-description": "包含 uni-framework、manifest.json、pages.json、tabbar、頁面、組件、API、Schema",
+  "index.detail": "詳情",
+  "index.language": "語言",
+  "index.language-info": "語言信息",
+  "index.system-language": "系統語言",
+  "index.application-language": "應用語言",
+  "index.language-change-confirm": "應用此設置將重啟App",
+  "api.message": "提示",
+  "schema.name": "姓名",
+  "schema.add": "新增",
+  "schema.add-success": "新增成功"
+}

+ 9 - 1
main.js

@@ -2,19 +2,27 @@ import Vue from 'vue'
 import App from './App'
 import store from './store' // store
 import plugins from './plugins' // plugins
+import messages from './locale/index'
 import './permission' // permission
 // import axios from "axios";
 import uView from '@/uni_modules/uview-ui'
 Vue.use(uView)
 // Vue.prototype.axios = axios;
 Vue.use(plugins)
-
+let i18nConfig = {
+  locale: uni.getLocale(),
+  messages
+}
+import VueI18n from 'vue-i18n'
+Vue.use(VueI18n)
+const i18n = new VueI18n(i18nConfig)
 Vue.config.productionTip = false
 Vue.prototype.$store = store
 
 App.mpType = 'app'
 
 const app = new Vue({
+	i18n,
   ...App
 })
 

+ 10 - 10
pages/bluetooth/index/index.vue

@@ -14,17 +14,17 @@
 			<text class="list-item-rssi">{{item.rssi}}</text>
 			<view class="list-item-line"></view>
 		</view>
-    <u-modal :show="showPwd" @confirm="inputPwd" @cancel="cancel" :showCancelButton="true"  title="请输入操作密码" >
+    <u-modal :show="showPwd" @confirm="inputPwd" @cancel="cancel" :showCancelButton="true"  :title="$t('buletooth.pwdinput')" >
       <view class="slot-content">
         <u--input
             type="number"
-            placeholder="6位数字密码"
+            :placeholder="$t('buletooth.pwdtip')"
             border="surround"
             v-model="pwd"
         ></u--input>
       </view>
     </u-modal>
-		<view v-if="deviceListDataShow.length==0" class="notice"> - 未发现设备,请确认蓝牙是否打开 -</view>
+		<view v-if="deviceListDataShow.length==0" class="notice"> - {{ $t('buletooth.nodevice') }} -</view>
 		<view class="gap"></view>
 	</scroll-view>
 
@@ -56,7 +56,7 @@ const ecBLE = require('@/utils/ecBLE/ecBLE.js')
 			}
 		},
 		onLoad() {
-      ecUI.showLoading('蓝牙初始化中')
+      ecUI.showLoading(this.$t('buletooth.init'))
 			ctx = this
       clearInterval(this.timer);
       this.timer = setInterval(() => {
@@ -83,12 +83,12 @@ const ecBLE = require('@/utils/ecBLE/ecBLE.js')
       },
       inputPwd(){
         if(!this.pwd ){
-          this.$modal.showToast("密码不能为空");
+          this.$modal.showToast(this.$t('buletooth.nopwd'));
         }else{
           if(this.rightPwd && this.rightPwd === this.pwd){
            this.loginSuccess();
           }else{
-            this.$modal.showToast("密码有误,请重新输入");
+            this.$modal.showToast(this.$t('buletooth.errpwd'));
           }
 
         }
@@ -109,7 +109,7 @@ const ecBLE = require('@/utils/ecBLE/ecBLE.js')
       },
 			listViewTap(id){
         let self = this;
-				ecUI.showLoading('设备连接中')
+				ecUI.showLoading(this.$t('buletooth.connecting'))
 				ecBLE.onBLEConnectionStateChange(res => {
           console.log(res);
 					if (res.ok) {
@@ -125,8 +125,8 @@ const ecBLE = require('@/utils/ecBLE/ecBLE.js')
             ecUI.hideLoading()
             uni.removeStorageSync('blueid');
 						ecUI.showModal(
-							'提示',
-							'连接失败,errCode=' + res.errCode + ',errMsg=' + res.errMsg
+                this.$t('buletooth.tip'),
+							'error,errCode=' + res.errCode + ',errMsg=' + res.errMsg
 						)
 					}
 				});
@@ -170,7 +170,7 @@ const ecBLE = require('@/utils/ecBLE/ecBLE.js')
             }
 					} else {
 						ecUI.showModal(
-							'提示',
+                this.$t('buletooth.tip'),
 							`Bluetooth adapter error | ${res.errCode} | ${res.errMsg}`,
 							() => {
 

+ 14 - 12
pages/login.vue

@@ -22,7 +22,7 @@
 		<uni-icons class="icon" type="email" size="20" color="#0E9F9B"></uni-icons>
        </uni-col>
 	   <uni-col :span="22">
-	    <input v-model="loginForm.username" class="input" type="text" placeholder="请输入账号" maxlength="30" />
+	    <input v-model="loginForm.username" class="input" type="text" :placeholder="$t('login.mailInput')" maxlength="30" />
 	   </uni-col>
 	   </uni-row>
       </view>
@@ -33,13 +33,13 @@
 		<uni-icons class="icon" type="locked" size="20" color="#0E9F9B"></uni-icons>
 		</uni-col>
 		<uni-col :span="22">
-        <uni-easyinput style="margin-left:-10px ;" :inputBorder="false" v-model="loginForm.password"  type="password" class="input"  placeholder="请输入密码" maxlength="30" />
+        <uni-easyinput style="margin-left:-10px ;" :inputBorder="false" v-model="loginForm.password"  type="password" class="input"  :placeholder="$t('login.pwdInput')" maxlength="30" />
 		</uni-col>
 		</uni-row>
       </view>
 	  <view class="xieyi text-center" style="margin-top: -10px;">
-		  <text class="text-grey">暂无账号,</text>
-		  <text @click="toggleLoginMode" class="text-green">立即注册</text>
+		  <text class="text-grey">{{ $t('login.noAccount') }},</text>
+		  <text @click="toggleLoginMode" class="text-green">{{ $t('login.resiger') }}</text>
 		  <!-- <text @click="handleUserAgrement" class="text-green">立即注册</text> -->
 		  <!-- <text @click="handlePrivacy" class="text-blue">《隐私协议》</text> -->
 		</view>
@@ -50,7 +50,7 @@
         <view class="login-code"> <image :src="codeUrl" @click="getCode" class="login-code-img"></image></view  >
       </view> -->
       <view class="action-btn" style="z-index: 99;position: relative;">
-        <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">立即登录</button>
+        <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">{{ $t('login.tologin') }}</button>
       </view>
     </view>
     <view class="login-form-content" style="z-index: 9999;position: relative;" v-show="!isLogin" @submit.prevent="handleRegister">
@@ -91,7 +91,7 @@
 	    <image @click="buleTeeth" style="width: 31px;" :src="imgUrl+'/login/blueTeeth.png'" mode="widthFix"/>
 	</view>
 	<view class="blue-text">
-	    <text @click="buleTeeth">蓝牙连接</text>
+	    <text @click="buleTeeth">{{ $t('login.buletooth') }}</text>
 	</view>
 	</view>
   </view>
@@ -129,6 +129,8 @@
 	  }
 	},
     created() {
+      console.log(uni.getLocale())
+      console.log(this.$t('locale.auto'))
 		uni.getLocation({
 			type: 'wgs84',
 			success: function (res) {
@@ -173,15 +175,15 @@
       // 登录方法
       async handleLogin() {
         if (this.loginForm.username === "") {
-          this.$modal.msgError("请输入您的账号")
+          this.$modal.msgError(this.$t('login.logintip'))
         } else if (this.loginForm.password === "") {
-          this.$modal.msgError("请输入您的密码")
+          this.$modal.msgError(this.$t('login.pwdtip'))
         }
 		// else if (this.loginForm.code === "" && this.captchaEnabled) {
   //         this.$modal.msgError("请输入验证码")}
 		  else {
 
-          this.$modal.loading("登录中,请耐心等待...")
+          this.$modal.loading(this.$t('login.logining'))
 
           this.pwdLogin()
         }
@@ -261,15 +263,15 @@
 	      async handleRegister() {
 			  // debugger
 	        if (this.register.username === "") {
-	          this.$modal.msgError("请输入您的注册账号")
+	          this.$modal.msgError(this.$t('register.logintip'))
 	        } else if (this.register.password === "") {
-	          this.$modal.msgError("请输入您的注册密码")
+	          this.$modal.msgError(this.$t('register.pwdtip'))
 	        }
 	  		// else if (this.loginForm.code === "" && this.captchaEnabled) {
 	        // this.$modal.msgError("请输入验证码")}
 	  		  else {
 				 // debugger
-	          this.$modal.loading("注册中,请耐心等待...")
+	          this.$modal.loading(this.$t('register.logining'))
 	          this.pwdRegister()
 	        }
 	     },

+ 18 - 154
pages/weitiandi/bluetooth/status.vue

@@ -1,11 +1,11 @@
 <template>
   <view class="container">
     <view style="height: 20px;line-height:15px;padding: 2px;text-align: center;position: fixed;right: -5px;top:30px;z-index: 9999;background: rgb(243,157,116);color: white;border-radius: 5px;font-size: 10px;width: 120rpx;" @click="goBack">
-      断开连接
+      {{$t('charge.break')}}
     </view>
 
     <view style="height: 20px;line-height:15px;padding: 2px;text-align: center;position: fixed;right: -5px;top:120px;z-index: 9999;background: #1A87FF;color: white;border-radius: 5px;font-size: 10px;width: 120rpx;" @click="modifyPwd">
-     修改密码
+      {{$t('charge.modifypwd')}}
     </view>
     <view style=";position: relative;height: 250px;margin-top:2vh;">
       <view class="dtop">
@@ -35,19 +35,19 @@
             <view class="p0" st="">{$device['sn']}</view>
             <view class="p1">
               <view v-if="portDetail.portStatus == 2">
-                充电中
+                {{$t('charge.charging')}}
               </view>
 
               <view v-if="portDetail.portStatus == 6">
-                已预约
+                {{$t('charge.planed')}}
               </view>
 
               <view v-if="portDetail.portStatus == 2">
-                已连接
+                {{$t('charge.connected')}}
               </view>
 
               <view v-else>
-                未充电
+                {{$t('charge.nocharge')}}
               </view>
 
             </view>
@@ -61,36 +61,36 @@
       <view class="ditem">
         <image class="itemimg" src="/static/images/new/tmp.png"/>
         <view class="item-value">{{portDetail.dev_temper}}℃</view>
-        <span class="item-text">设备温度</span>
+        <span class="item-text">{{$t('charge.devtemper')}}</span>
       </view>
       <view class="ditem">
         <image class="itemimg" src="/static/images/new/dianya.png"/>
         <view class="item-value">{{ portDetail.voltage }}V</view>
-        <span class="item-text">设备电压</span>
+        <span class="item-text">{{$t('charge.voltage')}}</span>
       </view>
       <view class="ditem">
         <image class="itemimg" src="/static/images/new/dianliu.png"/>
         <view class="item-value" v-if="portDetail.voltage == 0">0A</view>
         <view class="item-value" v-else>{{portDetail.POWER/portDetail.voltage}}A</view>
-        <span class="item-text">设备电流</span>
+        <span class="item-text">{{$t('charge.current')}}</span>
       </view>
 
       <view class="ditem">
         <image class="itemimg" src="/static/images/new/shjian.png"/>
         <view class="item-value">{{ portDetail.time }}分钟</view>
-        <span class="item-text">已冲时间</span>
+        <span class="item-text">{{$t('charge.chargetime')}}</span>
       </view>
 
       <view class="ditem">
         <image class="itemimg" src="/static/images/new/gonglv.png"/>
         <view class="item-value">{{ portDetail.power }}W</view>
-        <span class="item-text">充电功率</span>
+        <span class="item-text">{{$t('charge.power')}}</span>
       </view>
 
       <view class="ditem">
         <image class="itemimg" src="/static/images/new/dianliang.png"/>
         <view class="item-value">{{ portDetail.elec }} 度</view>
-        <span class="item-text">已冲电量</span>
+        <span class="item-text">{{$t('charge.elec')}}</span>
       </view>
 
     </view>
@@ -98,13 +98,13 @@
     <view class="dbtns">
       <view class="start" @click="toPage">
         <image style="width:25px;height: 25px;margin-right: 5px;" src="/static/images/new/start.png"/>
-        <span>启动充电</span>
+        <span>{{$t('charge.startcharge')}}</span>
       </view>
 
 
       <view class="get" @click="getInfo">
         <image style="width:25px;height: 25px;margin-right: 5px;" src="/static/images/new/get.png"/>
-        <span>获取状态</span>
+        <span>{{$t('charge.getinfo')}}</span>
       </view>
 
     </view>
@@ -112,155 +112,19 @@
     <view class="dtip">
       <view style="margin:10px 0px;color: #1A87FF;"><img style="width: 13px;height: 13px" src="/static/images/new/tip.png">温馨提示</view>
       <view>1,桩控制最大输出电流,当功率没有达到请检查车的状态或者车的设置;</view>
-      <view>2,主页-&gt;设备管理-&gt;设备详情页-&gt;主板参数 可设置设备最大输出电流</view>
+      <view>2,启动充电-&gt;设备管理- 可设置设备最大输出电流</view>
       <view>3,为保障您远程启动正常充电,请确保枪头完全连接充电口,同时确认您的爱车处于立即充电状态下;</view>
       <view>4,注意规范安全充电,停好车,锁好车。</view>
     </view>
-    <view class="port"  @click="showPort = true">
-      <view class="port-image">
-        <image class="btn-image" :src="imgUrl+'/index/device.png'" >
-        </image>
-      </view>
-      <view class="port-text">
-       当前端口:
-      </view>
-
-      <view class="port-num">
-        <view>
-          {{portList[0][choosePort-1]["text"]}}
-        </view>
-
-      </view>
-      <view class="port-icon">
-        <image class="btn-image" :src="imgUrl+'/index/right.png'" >
-        </image>
-      </view>
-    </view>
-    <view class="plan" @click="planCharge">
-      <view class="port-image">
-        <image class="btn-image" :src="imgUrl+'/index/clock.png'" >
-        </image>
-      </view>
-      <view class="port-text" v-if="portDetail.portStatus == 6"  style="top:16px">
-        已预约
-      </view>
-      <view class="port-text" style="top:24px" v-else>
-        点击预约充电
-      </view>
-      <view class="port-num" style="top:48px;font-size: 12px" v-if="portDetail.portStatus == 6">
-        点击取消预约
-      </view>
-      <view class="port-icon"  v-if="portDetail.portStatus !=6">
-        <image class="btn-image" :src="imgUrl+'/index/right.png'" >
-        </image>
-      </view>
-      <view class="port-icon" v-if="portDetail.portStatus == 6" style="width: 18px;height: 18px;right:1px;">
-        <image class="btn-image"  :src="imgUrl+'/index/del.png'" >
-        </image>
-      </view>
-
-    </view>
-    <view class="info-body">
-     <view>
-       <view class="info-content">
-
-         <view class="info-content-value">{{ portDetail.voltage }}V</view>
-         <view class="info-content-text">
-           充电电压
-         </view>
-       </view>
-
-       <view class="info-content">
-
-         <view class="info-content-value" v-if="portDetail.voltage == 0">0A</view>
-         <view class="info-content-value" v-else>{{portDetail.POWER/portDetail.voltage}}A</view>
-
-         <view class="info-content-text">
-           充电电流
-         </view>
-       </view>
-
-       <view class="info-content">
-
-         <view class="info-content-value">{{portDetail.dev_temper}}℃</view>
-         <view class="info-content-text">
-           设备温度
-         </view>
-       </view>
-
-
-       <view class="info-content">
-
-         <view class="info-content-value">{{portDetail.wire_temper}}℃</view>
-         <view class="info-content-text">
-           线路温度
-         </view>
-       </view>
-     </view>
-
-      <view class="body-bottom">
-        <view class="info-content">
-
-          <view class="info-content-value">{{ portDetail.time }}分钟</view>
-          <view class="info-content-text">
-            已冲时间
-          </view>
-        </view>
-        <view class="info-content">
-
-          <view class="info-content-value">{{ portDetail.power }}W</view>
-          <view class="info-content-text">
-            充电功率
-          </view>
-        </view>
-        <view class="info-content">
-
-          <view class="info-content-value">{{ portDetail.elec }} 度</view>
-          <view class="info-content-text">
-            已冲电量
-          </view>
-        </view>
-      </view>
-
-    </view>
     <u-picker @cancel="showPort=false" @confirm="confirmPort" :show="showPort" :columns="portList" keyName="text"></u-picker>
 
-
-    <view class="bottom-control">
-      <view class="control-btn" @click="trigger()" v-if="portDetail.portStatus == 2">
-        <image class="btn-image" :src="imgUrl+'/control/stop.png'" >
-        </image>
-        <view>停止充电</view>
-      </view>
-
-      <view class="control-btn" @click="trigger()" v-if="portDetail.portStatus != 2">
-        <image class="btn-image" :src="imgUrl+'/control/charge.png'" >
-        </image>
-        <view>立即充电</view>
-      </view>
-      <view class="control-btn" @click="getInfo">
-        <image class="btn-image" :src="imgUrl+'/control/getstatus.png'" >
-        </image>
-        <view>获取状态</view>
-      </view>
-      <view class="control-btn" @click="toSet">
-        <image class="btn-image" :src="imgUrl+'/control/control.png'" >
-        </image>
-        <view>设备控制</view>
-      </view>
-<!--      <view class="control-btn">-->
-<!--        <image class="btn-image" :src="imgUrl+'/control/record.png'" >-->
-<!--        </image>-->
-<!--        <view>使用记录</view>-->
-<!--      </view>-->
-    </view>
     <u-picker @cancel="cancelPicker" @confirm="confirm" :show="showPlan" :columns="planCols" @change="changeHandler"></u-picker>
-    <u-modal :show="showPwd" @confirm="inputPwd" @cancel="cancel" :showCancelButton="true"  title="修改密码" >
+    <u-modal :show="showPwd" @confirm="inputPwd" @cancel="cancel" :showCancelButton="true"  :title="$t('charge.modifypwd')" >
       <view class="slot-content">
         <view>
           <u--input
               type="number"
-              placeholder="原密码"
+              :placeholder="$t('charge.oldpwd')"
               border="surround"
               v-model="oldPwd"
           ></u--input>
@@ -269,7 +133,7 @@
         <view style="margin-top:5px">
           <u--input
               type="number"
-              placeholder="6位数字新密码"
+              :placeholder="$t('charge.newpwd')"
               border="surround"
               v-model="pwd"
           ></u--input>