mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-22 22:58:25 +00:00
Enable URL lang parameter for switching languages (fixes #1080)
This commit is contained in:
parent
c6041d2590
commit
f62812a8dc
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,3 +12,4 @@ bin
|
||||
perfstats*.csv
|
||||
coverage.xml
|
||||
!gui/scripts/syncthing
|
||||
.DS_Store
|
||||
|
@ -918,11 +918,12 @@ angular.module('syncthing.core')
|
||||
var devices = $scope.folders[folderID].Devices
|
||||
for (var i = 0; i < devices.length; i++) {
|
||||
if (devices[i].DeviceID == deviceCfg.DeviceID) {
|
||||
folders.push(folderID)
|
||||
break
|
||||
folders.push(folderID);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
folders.sort();
|
||||
return folders;
|
||||
};
|
||||
|
@ -12,7 +12,7 @@ angular.module('syncthing.core')
|
||||
_availableLocales = locales;
|
||||
};
|
||||
|
||||
this.$get = ['$http', '$translate', function ($http, $translate) {
|
||||
this.$get = ['$http', '$translate', '$location', function ($http, $translate, $location) {
|
||||
|
||||
/**
|
||||
* Requests the server in order to get the browser's requested locale strings.
|
||||
@ -26,8 +26,12 @@ angular.module('syncthing.core')
|
||||
}
|
||||
|
||||
function autoConfigLocale() {
|
||||
var params = $location.search();
|
||||
|
||||
return readBrowserLocales().success(function (langs) {
|
||||
if(params.lang) {
|
||||
$translate.use(params.lang);
|
||||
} else {
|
||||
readBrowserLocales().success(function (langs) {
|
||||
// Find the first language in the list provided by the user's browser
|
||||
// that is a prefix of a language we have available. That is, "en"
|
||||
// sent by the browser will match "en" or "en-US", while "zh-TW" will
|
||||
@ -35,7 +39,8 @@ angular.module('syncthing.core')
|
||||
|
||||
var i,
|
||||
lang,
|
||||
matching;
|
||||
matching,
|
||||
locale = _defaultLocale;
|
||||
|
||||
for (i = 0; i < langs.length; i++) {
|
||||
lang = langs[i];
|
||||
@ -57,14 +62,14 @@ angular.module('syncthing.core')
|
||||
});
|
||||
|
||||
if (matching.length >= 1) {
|
||||
$translate.use(matching[0]);
|
||||
return;
|
||||
locale = matching[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Fallback if nothing matched
|
||||
$translate.use(_defaultLocale);
|
||||
$translate.use(locale);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function useLocale(language) {
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user