Q:

Removing JQuery dependency in localization code

I'm using this javascript to localize my Cordova/Phonegap app.  It has a dependency on JQuery which I don't want to use. This last bit here in particular is not working 
      _results.push($(".l10n-" + key).html(value));

How can I change the code in order to remove that dependency?
Thank you

 var Localization;

 Localization = (function() {

   function Localization() {}

   Localization.initialize = function(dictionnary, fallback_language) {
  Localization.dictionnary = dictionnary;
  Localization.fallback_language = fallback_language;
  return navigator.globalization.getPreferredLanguage(Localization.get_preferred_language_callback, Localization.get_preferred_language_error_callback);
   };

   Localization.get_preferred_language_callback = function(language) {
  Localization.language = language.value;
  alert("Phone language is " + Localization.language);
  if (Localization.language in Localization.dictionnary) {
    alert("It is supported.");
  } else {
    Localization.language = Localization.fallback_language;
    alert("It is unsupported, so we chose " + Localization.language + " instead.");
  }
  return Localization.apply_to_current_html();
   };

   Localization.get_preferred_language_error_callback = function() {
  Localization.language = Localization.fallback_language;
  alert("There was a error determining the language, so we chose " + Localization.language + ".");
  return Localization.apply_to_current_html();
   };

   Localization.apply_to_current_html = function() {
  var key, value, _ref, _results;
  alert("Localizing HTML file.");
  _ref = Localization.dictionnary[Localization.language];
  _results = [];
  for (key in _ref) {
    value = _ref[key];
    alert(value);
    _results.push($(".l10n-" + key).html(value));
    alert("result is " + _results);
  }
  return _results;
   };

   Localization["for"] = function(key) {
  return Localization.dictionnary[Localization.language][key];
   };

   return Localization;

 })();

A:

You can use native JS methods to change the HTML of those elements:
Localization.apply_to_current_html = function() {
    var key, value, _ref, _results;
    _ref = Localization.dictionnary[Localization.language];
    _results = [];
    for (key in _ref) {
        value = _ref[key];
        var elements = document.querySelectorAll(".l10n-" + key);
        for (var i = 0; i < elements.length; i++) {
            elements[i].innerHTML = value;
            _results.push(elements[i]);
        }
    }
    return _results;
};

Note that the functionality will be the same, however the apply_to_current_html() function will now return an array of DOMElement objects, not an array of jQuery objects as before.
You've not stated an example of how this return value is used so I can't tell you what knock-on effects this may have.

