A simple JavaScript function that doubles every character on a web page – useful when testing layouts for i18n issues
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
// Paste this function to your browser’s JavaScript console, | |
// and then run it, passing in a CSS selector, eg: | |
// > pseudolocalize('body') | |
var pseudolocalize = function pseudolocalize(arg){ | |
if(typeof arg === 'string'){ | |
var elements = document.querySelectorAll(arg); | |
for(var i=0, len=elements.length; i<len; i++){ | |
pseudolocalize(elements[i]); | |
} | |
} else if(arg.nodeType === 1){ | |
for(var i=0, len=arg.childNodes.length; i<len; i++){ | |
pseudolocalize(arg.childNodes[i]); | |
} | |
} else if(arg.nodeType === 3){ | |
arg.nodeValue = arg.nodeValue.replace(/(.)/g, '$1$1'); | |
} | |
} |
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 pseudolocalize=function e(l){if("string"==typeof l)for(var o=document.querySelectorAll(l),d=0,n=o.length;n>d;d++)e(o[d]);else if(1===l.nodeType)for(var d=0,n=l.childNodes.length;n>d;d++)e(l.childNodes[d]);else 3===l.nodeType&&(l.nodeValue=l.nodeValue.replace(/(.)/g,"$1$1"))}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment