Skip to content

Instantly share code, notes, and snippets.

@bjmiller121
Last active August 29, 2015 14:02
Show Gist options
  • Save bjmiller121/eb3a8d0e3460327677ef to your computer and use it in GitHub Desktop.
Save bjmiller121/eb3a8d0e3460327677ef to your computer and use it in GitHub Desktop.
Get language code of a page in JS
var path = window.location.pathname.split('/')[1],
lang = /\w\w\-\w\w/.test(path) ? path.split('-')[0] : 'en';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment