diff --git a/javascript/localization.js b/javascript/localization.js index 58c7b0a5..7c6ad836 100644 --- a/javascript/localization.js +++ b/javascript/localization.js @@ -1,3 +1,5 @@ +var re_num = /^[.\d]+$/; + var original_lines = {}; var translated_lines = {}; @@ -11,6 +13,15 @@ function textNodesUnder(el) { return a; } +function canBeTranslated(node, text) { + if (!text) return false; + if (!node.parentElement) return false; + var parentType = node.parentElement.nodeName; + if (parentType == 'SCRIPT' || parentType == 'STYLE' || parentType == 'TEXTAREA') return false; + if (re_num.test(text)) return false; + return true; +} + function getTranslation(text) { if (!text) return undefined; @@ -28,6 +39,9 @@ function getTranslation(text) { function processTextNode(node) { var text = node.textContent.trim(); + + if (!canBeTranslated(node, text)) return; + var tl = getTranslation(text); if (tl !== undefined) { node.textContent = tl;