I simply want to translate some words globally. My translations are inside an object with the key as the original word and the value as the translation. However I can't get my function to work, what am I missing?
jQuery(document).ready(function() {
if (window.location.href.indexOf("sv") > -1) {
var translations = {
'All': 'alla',
'Filter Members': 'Filtrera medlemar',
}
for (var key in translations) {
if (translations.hasOwnProperty(key)) {
console.log(key + " -> " + translations[key]);
$allItems = jQuery("body *").children();
$allItems.each(function() {
$this = jQuery(this);
$this.html().replace(key, translations[key]);
});
}
}