Skip to content

Instantly share code, notes, and snippets.

@Zegnat
Created November 18, 2011 12:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Zegnat/1376327 to your computer and use it in GitHub Desktop.
Save Zegnat/1376327 to your computer and use it in GitHub Desktop.
var tld = window.location.hostname.split('.').pop(),
tldExtend = {uk:'GB',za:'ZA',ie:'IE',au:'AU'};
while (treeWalker.nextNode()) {
cN = treeWalker.currentNode;
cNlang =
cN.getAttribute('lang')||cN.getAttribute('xml:lang')||
(('getAttribute' in cN.parentNode&&(l=cN.parentNode.getAttribute('lang')||cN.parentNode.getAttribute('xml:lang'))&&!cN.setAttribute('lang',l))?l:null)||
window.navigator.language;
if (cNlang=='en'&&tld in tldExtend) cNlang+='-'+tldExtend[tld];
// Gender swap with lists based on cNlang here!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment