mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 00:40:07 +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() {
|
function tryLocaleDetect() {
|
||||||
// lets fire off a request to get our headers which then
|
// use navigator to get the locale setting
|
||||||
// can help us identify what locale the browser is in.
|
changeLocaleFromHeaders(navigator.language || navigator.browserLanguage);
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeLocaleFromHeaders(langString) {
|
function changeLocaleFromHeaders(langString) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue