A simple function which returns current locale.
Call it using getUserLanguage(options), where options - is an optional object.
It has two options:
- supportedLocales is an array of supported locales. If it is passed and the browser locale is not one of them, then the function will return false.
- fallbackLocale is a name of a locale which should be returned if browser locale is not one of supportedLocales.
All modern browsers and even some IEs.
Test it with this command: