插件网址:
http://ngcordova.com/docs/plugins/globalization/
- 安装插件
cordova plugin add cordova-plugin-globalization
- 获得语言
module.controller('MyCtrl', function($cordovaGlobalization) {
$cordovaGlobalization.getPreferredLanguage().then(
function(result) {
// result
},
function(error) {
// error
});
$cordovaGlobalization.getLocaleName().then(
function(result) {
// result
},
function(error) {
// error
});
$cordovaGlobalization.getFirstDayOfWeek().then(
function(result) {
// result
},
function(error) {
// error
});
// Soon implemented:
// dateToString
// stringToDate
// getDatePattern
// getDateNames
// isDayLightSavingsTime
// numberToString
// stringToNumber
// getNumberPattern
// getCurrencyPattern
});
// 获取当前语言
navigator.globalization.getPreferredLanguage(function (language) {
var lang = (language.value).split("-")[0];
console.log('now lang',lang);
}, null);
更多使用方法:
https://angular-translate.github.io/docs/#/guide/07_multi-language https://www.thepolyglotdeveloper.com/2014/08/internationalization-localization-ionicframework-angular-translate/