Last active
May 29, 2016 04:49
-
-
Save nishinoshake/23fa0a54ad523927c104 to your computer and use it in GitHub Desktop.
JSでブラウザの言語を取得する
This file contains hidden or 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
/** | |
* getLangage | |
* | |
* ブラウザに設定されている言語コードを返す | |
* 例. ja(日本), en(英語), zh(中国), zh-tw(台湾), ko(韓国) | |
* @returns {string} 言語コードを小文字で | |
*/ | |
_self.getLanguage = function( ){ | |
return (window.navigator.userLanguage || | |
window.navigator.language || | |
window.navigator.browserLanguage | |
).toLowerCase(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment