1
我正在使用此javascript來本地化我的Cordova/Phonegap應用程序。它依賴於我不想使用的JQuery。這最後一點特別是沒有工作刪除本地化代碼中的JQuery依賴項
_results.push($(".l10n-" + key).html(value));
如何更改代碼,以消除該依賴關係? 謝謝
\t var Localization;
\t Localization = (function() {
\t function Localization() {}
\t Localization.initialize = function(dictionnary, fallback_language) {
\t \t Localization.dictionnary = dictionnary;
\t \t Localization.fallback_language = fallback_language;
\t \t return navigator.globalization.getPreferredLanguage(Localization.get_preferred_language_callback, Localization.get_preferred_language_error_callback);
\t };
\t Localization.get_preferred_language_callback = function(language) {
\t \t Localization.language = language.value;
\t \t alert("Phone language is " + Localization.language);
\t \t if (Localization.language in Localization.dictionnary) {
\t \t alert("It is supported.");
\t \t } else {
\t \t Localization.language = Localization.fallback_language;
\t \t alert("It is unsupported, so we chose " + Localization.language + " instead.");
\t \t }
\t \t return Localization.apply_to_current_html();
\t };
\t Localization.get_preferred_language_error_callback = function() {
\t \t Localization.language = Localization.fallback_language;
\t \t alert("There was a error determining the language, so we chose " + Localization.language + ".");
\t \t return Localization.apply_to_current_html();
\t };
\t Localization.apply_to_current_html = function() {
\t \t var key, value, _ref, _results;
\t \t alert("Localizing HTML file.");
\t \t _ref = Localization.dictionnary[Localization.language];
\t \t _results = [];
\t \t for (key in _ref) {
\t \t value = _ref[key];
\t \t alert(value);
\t \t _results.push($(".l10n-" + key).html(value));
\t \t alert("result is " + _results);
\t \t }
\t \t return _results;
\t };
\t Localization["for"] = function(key) {
\t \t return Localization.dictionnary[Localization.language][key];
\t };
\t return Localization;
\t })();