I'm making a translation function, and I want to easily add translations inside an object and then change each globally inside the $("body").html(), problem is, when I use new RegExp() inside my for loop it cuts the loop after first iteration.
if (window.location.href.indexOf("sv") > -1) {
    //CUSTOM TRANSLATIONS
    var translations = {
        'All': 'alla',
        'Filter Members': 'Filtrera medlemar',
    }
    for (var key in translations) {
        if (translations.hasOwnProperty(key)) {
            console.log(key + " -> " + translations[key]);
            $body = jQuery("body");
            replaceThis = new RegExp(key, "g");
            alert(replaceThis);
            $body.html($body.html().replace(replaceThis, translations[key]));
        }
    }
}
 
     
     
     
     
    