gui: Translate theme names in settings (#8006)

Add each subdirectory of the guiDir as a translation candidate string.
The key is prefixed with "theme-name-" and the default English
translation corresponds to the directory name turned to title case.
Disable the automatic name mangling in the GUI JS code in favor of
just looking up the translation.
This commit is contained in:
André Colomb
2021-10-20 19:44:38 +02:00
committed by GitHub
parent 517667c590
commit 3e3954eb38
4 changed files with 33 additions and 3 deletions
@@ -2822,9 +2822,14 @@ angular.module('syncthing.core')
};
$scope.themeName = function (theme) {
return theme.replace('-', ' ').replace(/(?:^|\s)\S/g, function (a) {
return a.toUpperCase();
});
var translation = $translate.instant("theme-name-" + theme);
if (translation.startsWith("theme-name-")) {
// Fall back to simple Title Casing on missing translation
translation = theme.toLowerCase().replace(/(?:^|\s)\S/g, function (a) {
return a.toUpperCase();
});
}
return translation;
};
$scope.modalLoaded = function () {