translate 的用法 1.在html页面:文本的翻译hello world
'hello world '|translate
2. placeholder= {{var|translate}} aria-label={{var|translate}} tooltip = {{var|translate}} ng-bind= {{var|translate}} ng-bind= {{key|translate}}var}}'}' --json key:".....{{index}}" 3.$translate.use(); define(function (require) { return function SavedObjectFactory(es, kbnIndex, Promise, Private, Notifier, safeConfirm, indexPatterns,$translate) { var angular = require('angular'); //[email protected] var message ; var lang = $translate.use(); if(lang === 'zh-cn'){ message = '你确定你想要覆盖 ' }else if(lang === 'zh-tw'){ message = '你確定你想要覆蓋 ' }else{ message = 'Are you sure you want to overwrite ' } $ 4.$translate.instant(key) var a = $translate.instant("Are you sure you want to delete the selected"); var b = $translate.instant("Are you sure you want to delete the selected"); var aaa = `trgutyr ${a}${currentTab.title}${b}`; 'rtguiyi' var bbb = aaa; ---.js var option = { "Seconds": $translate.instant("Seconds ago"), "Minutes":$translate.instant("Minutes ago"), "Hours": $translate.instant("Hours ago"), "Days": $translate.instant("Days ago"), "Weeks": $translate.instant("Weeks ago"), "Months": $translate.instant("Months ago"), "Years": $translate.instant("Years ago") }; $scope.relativeOptions = [ {text: option.Seconds, value: 's'}, {text: option.Hours, value: 'm'}, {text: option.Days, value: 'h'}, {text: option.Days, value: 'd'}, {text: option.Weeks, value: 'w'}, {text: option.Months, value: 'M'}, {text: option.Years, value: 'y'}, ]; ---.html
<select ng-model="relative.unit" ng-options="opt.value as opt.text for opt in relativeOptions" translate-values ng-change="formatRelative()" class="form-control col-xs-2">5直接使用window.localStorage.lang; //[email protected] var message ; var lang = window.localStorage.lang; if(lang === 'en-us'){ message = 'MMMM Do YYYY, HH:mm:ss.SSS' }else if(lang === 'zh-tw'){ message = 'YYYY年MM月DD日, HH:mm:ss.SSS' }else{ message = 'YYYY年MM月DD日, HH:mm:ss.SSS' } 6 ng-show = "lang === 'en-us'"finder title="Saved Searches" type="searches" make-url="step2WithSearchUrl"> finder title="已存搜索" type="searches" make-url="step2WithSearchUrl"> 7finder title="已存搜索" type="searches" make-url="step2WithSearchUrl"> if="aggParam.name"> Patternif="label">