uni-app系列回顧總結----項目國際化2(翻譯問題與解決方案)總結


國際化翻譯遇到的問題與解決方案:

國際化項目部署情況:uni-app系列----項目國際化

 

 

1.文字的替換方法:

跟訪問data數據 一樣,{{}}實現數據綁定:

<text class="placeholder">搜索</text>
<text class="placeholder">{{i18n.search}}</text>

 

2.標簽內屬性值的替換方法:

用  "  : " 即 “ v-bind”進行綁定訪問:注意冒號

<input placeholder="電話" type="number" maxlength="11" @input="onMobileInput"></input>

<input :placeholder="i18n.mobilePhone" type="number" maxlength="11" @input="onMobileInput"></input>

  

3.標簽或文本內的三木運算判斷的替換方法:

<view class="date">{{userLevelInfo.levelType==1? wxs.spliceDate(userLevelInfo.endTime)+"1111":"22222"}}</view>

<view class="date">{{userLevelInfo.levelType==1? wxs.spliceDate(userLevelInfo.endTime)+i18n.expire:i18n.notPayingMember}}</view>

  

<view :class="'level-mark  ' + (currentLevelId==item.id? '':'white-bg' )">{{currentLevelId==item.id?"111":"222"}}</view>

<view :class="'level-mark ' + (currentLevelId==item.id? '':'white-bg' )">{{currentLevelId==item.id?i18n.current:i18n.notPurchased}}</view>

  

4.data里數值的替換方法:

不能直接 i18n. 進行訪問,只能用在函數中用 push 方法添加進去

一些對象的屬性也可以這樣添加實現!

// refundPriReasonArray: ['請選擇', '協商一致退款', '拍錯/多拍/不喜歡', '其他'],
refundPriReasonArray: [i18n.pleaseChoose, i18n.refundConsensus, i18n.wrongShot, i18n.other],//無法訪問

data里:
refundPriReasonArray:[],
函數
{
  this.refundPriReasonArray.push(i18n.pleaseChoose, i18n.refundConsensus, i18n.wrongShot, i18n.other);
  console.log(this.refundPriReasonArray)
}

  

5.彈窗文字的替換方法:

用 this 進行訪問,同訪問 data 數據

uni.showModal({
	title: "提示",
	content: "請輸入正確的信息!",
	success: res => {
		if (res.confirm) {
			this.popupShow = true
			} else {}
		}
	});


uni.showModal({ title: this.i18n.tips, content: this.i18n.upgradeMemberTips1, success: res => { if (res.confirm) { this.popupShow = true } else {} } });

 

6.下方導航標簽的替換方法

 

 

 只能一次設置一個,所以要設多個

 

 

記得城市換調用與渲染

 

 

 

7.頁面標題的替換方法

 

 

 用

uni.setNavigationBarTitle({

});

uni.setNavigationBarTitle({
	 title:this.i18n.yamiMultiStore
});

再每個頁面都要設置。。。。。一百多個頁面文件,就是手指有點抽筋。。。。

我是放在onShow里面的

 

 

8. js文件文字的替換方法

終於解決了。hhhhhhhhhh,弄了一個早上,搞定了是真的開心呀

下面的彈窗就是再js文件里設置的,搞定了!

 

 

 方法:

 

 

 

 

 

9.彈窗補充(wx.showModal與uni.showModal)

wx.showModal:http://www.mamicode.com/info-detail-2373042.html

uni.showModal: https://www.kancloud.cn/guobaoguo/uniapp/820872

 

 

 

 

 

 

解決:

 

 

 

 注意:this指向問題:

 

 

 

 

詳細請結合參考官網:https://uniapp.dcloud.io/api/ui/tabbar?id=settabbaritem
https://ask.dcloud.net.cn/article/35872


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM