在BB10 Webworks应用程序中找不到Phonegap 2.3.0全球化类

时间:2013-05-28 15:05:52

标签: cordova globalization blackberry-10 sencha-touch-2.2

我正在使用WebWorks和Sencha Touch 2.2在BlackBerry 10上开发Phonegap 2.3应用程序。当我尝试根据文档调用getPreferredLanguage()方法时:

navigator.globalization.getPreferredLanguage(
  function (language) {alert('language: ' + language.value + '\n');},
  function () {alert('Error getting language\n');}
);

我收到以下错误:

Error: Status=2 Message=Class Globalization cannot be found

文档声明在OS5及更高版本的BlackBerry上支持全球化类,那么为什么我会发现类未找到错误?

2 个答案:

答案 0 :(得分:1)

尝试检查“设备就绪”事件是否已被触发:

$(document).ready(function() {  
  document.addEventListener("deviceready", onDeviceReady, false); 
});

function onDeviceReady() {
  alert('device ready');
  navigator.globalization.getPreferredLanguage(
    function (language) {alert('language: ' + language.value + '\n');},
    function () {alert('Error getting language\n');}
  );
}

答案 1 :(得分:0)

在config.xml文件中更改

<feature name="Geolocation">
  <param name="android-package" value="org.apache.cordova.Globalization" />  
</feature>

<feature name="Geolocation">
  <param name="android-package" value="org.apache.cordova.globalization.Globalization" />  
</feature>