mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-27 16:38:50 +02:00
use navigator to get the user locale
This commit is contained in:
parent
0673c03dea
commit
8cbf1c1ce5
1 changed files with 2 additions and 14 deletions
|
@ -259,20 +259,8 @@ var initDemo = function(sandbox) {
|
|||
};
|
||||
|
||||
function tryLocaleDetect() {
|
||||
// lets fire off a request to get our headers which then
|
||||
// can help us identify what locale the browser is in.
|
||||
// wrap everything in a try since this is a third party service
|
||||
try {
|
||||
$.ajax({
|
||||
url: 'http://ajaxhttpheaders.appspot.com',
|
||||
dataType: 'jsonp',
|
||||
success: function(headers) {
|
||||
changeLocaleFromHeaders(headers['Accept-Language']);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('locale detect fail', e);
|
||||
}
|
||||
// use navigator to get the locale setting
|
||||
changeLocaleFromHeaders(navigator.language || navigator.browserLanguage);
|
||||
}
|
||||
|
||||
function changeLocaleFromHeaders(langString) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue