Last active
October 5, 2018 14:33
-
-
Save bastsoft/71b7cf053e783251b10e5141daea8e9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
btr.loadGist({ url: 'https://gist.github.com/', id: '71b7cf053e783251b10e5141daea8e9e'}, function(){ | |
btr.contextMenu('body', { | |
showTranslateCode : btr.functionGist('translate.js') | |
}); | |
alert('done'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i18nWord = {}; | |
function enumNodes(node) { | |
while (node) { | |
console.log(i18nWord, node.innerText); | |
if (i18nWord[node.innerText]) { | |
node.innerHTML = i18nWord[node.innerText]; | |
}; | |
enumNodes(node.firstChild); | |
node = node.nextSibling; | |
}; | |
}; | |
$.getJSON('/js/translation/en.js').then(function (i18nJson) { | |
Object.keys(i18nJson.messages).forEach((key) => { | |
i18nWord[i18nJson.messages[key]] = key; | |
}); | |
console.log(i18nWord); | |
enumNodes(document.body, i18nWord); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
javascript:(function(){%20%20%20%20var%20el%20=%20document.createElement('script');%20%20%20%20el.onload%20=%20el.onreadystatechange%20=%20function%20()%20{%20%20%20%20%20%20%20%20if%20(el.readyState%20&&%20el.readyState%20!==%20"complete"%20&&%20el.readyState%20!==%20"loaded")%20{%20%20%20%20%20%20%20%20%20%20%20%20return%20false;%20%20%20%20%20%20%20%20}%20%20%20%20%20%20%20%20btr.loadGist({%20id:%20'71b7cf053e783251b10e5141daea8e9e',%20file:%20'main.js'%20});%20%20%20%20};%20%20%20%20document.getElementsByTagName('head')[0].appendChild(el).src%20=%20'https://cdn.rawgit.com/bastsoft/btr/v0.1.0/btr.js';})();