diff --git a/Duplicati/Library/Localization/LocalizationService.cs b/Duplicati/Library/Localization/LocalizationService.cs index fda4a3c1e..ad65f3051 100644 --- a/Duplicati/Library/Localization/LocalizationService.cs +++ b/Duplicati/Library/Localization/LocalizationService.cs @@ -138,6 +138,14 @@ namespace Duplicati.Library.Localization { get { return MoLocalizationService.SupportedCultures; } } + + /// + /// Returns true if the culture has localization support + /// + public static Boolean isCultureSupported(CultureInfo culture) + { + return MoLocalizationService.isCultureSupported(culture); + } } } diff --git a/Duplicati/Library/Localization/MoLocalizationService.cs b/Duplicati/Library/Localization/MoLocalizationService.cs index 8f9f52040..ff3f4b8e1 100644 --- a/Duplicati/Library/Localization/MoLocalizationService.cs +++ b/Duplicati/Library/Localization/MoLocalizationService.cs @@ -163,12 +163,12 @@ namespace Duplicati.Library.Localization return catalog.GetString(message, args); } - private static List m_supportedcultures = null; + private static IEnumerable m_supportedcultures = null; /// /// Gets a list of all the supported cultures /// - public static IEnumerable SupportedCultures + private static IEnumerable SupportedCultureInfos { get { @@ -189,17 +189,38 @@ namespace Duplicati.Library.Localization where ci != null select ci; - m_supportedcultures = - allcultures - .Select(x => x.TwoLetterISOLanguageName).Distinct().OrderBy(x => x) - .Union( - allcultures.Select(x => x.Name).Distinct().OrderBy(x => x) - ).ToList(); - - m_supportedcultures.Add("en"); + m_supportedcultures = allcultures.Concat(new[] { new CultureInfo("en") }) + .Distinct(); } return m_supportedcultures; } } + + /// + /// Gets a list of all the supported cultures + /// + public static IEnumerable SupportedCultures + { + get + { + return SupportedCultureInfos + .Select(x => x.Name).Distinct() + .OrderBy(x => x) + .ToList(); + } + } + + /// + /// Returns true if the culture has localization support + /// + public static Boolean isCultureSupported(CultureInfo culture) + { + foreach (var supportedCulture in SupportedCultureInfos) + { + if (supportedCulture.TwoLetterISOLanguageName == culture.TwoLetterISOLanguageName) + return true; + } + return false; + } } } diff --git a/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs b/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs index 4045a5476..b1ca474d6 100644 --- a/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs +++ b/Duplicati/Server/WebServer/RESTMethods/SystemInfo.cs @@ -113,7 +113,8 @@ namespace Duplicati.Server.WebServer.RESTMethods EnglishName = new System.Globalization.CultureInfo(x).EnglishName, DisplayName = new System.Globalization.CultureInfo(x).NativeName } - ) + ), + BrowserLocaleSupported = Library.Localization.LocalizationService.isCultureSupported(browserlanguage) }; } } diff --git a/Duplicati/Server/webroot/ngax/scripts/controllers/SystemSettingsController.js b/Duplicati/Server/webroot/ngax/scripts/controllers/SystemSettingsController.js index 989f4fa5c..21c3f70ce 100644 --- a/Duplicati/Server/webroot/ngax/scripts/controllers/SystemSettingsController.js +++ b/Duplicati/Server/webroot/ngax/scripts/controllers/SystemSettingsController.js @@ -4,13 +4,15 @@ backupApp.controller('SystemSettingsController', function($rootScope, $scope, $l function reloadOptionsList() { $scope.advancedOptionList = AppUtils.buildOptionList($scope.SystemInfo, false, false, false); - }; + } reloadOptionsList(); $scope.$on('systeminfochanged', reloadOptionsList); $scope.uiLanguage = $cookies.get('ui-locale'); + $scope.lang_browser_default = gettextCatalog.getString('Browser default'); + $scope.lang_default = gettextCatalog.getString('Default'); function setUILanguage() { if (($scope.uiLanguage || '').trim().length == 0) { @@ -21,10 +23,7 @@ backupApp.controller('SystemSettingsController', function($rootScope, $scope, $l gettextCatalog.setCurrentLanguage($scope.uiLanguage); } $rootScope.$broadcast('ui_language_changed'); - }; - - // Uncomment for immediate change - //$scope.$watch('uiLanguage', setUILanguage); + } AppService.get('/serversettings').then(function(data) { @@ -55,7 +54,7 @@ backupApp.controller('SystemSettingsController', function($rootScope, $scope, $l 'startup-delay': $scope.startupDelayDurationValue + '' + $scope.startupDelayDurationMultiplier, 'update-channel': $scope.updateChannel, 'usage-reporter-level': $scope.usageReporterLevel - } + }; if ($scope.requireRemotePassword) { diff --git a/Duplicati/Server/webroot/ngax/templates/settings.html b/Duplicati/Server/webroot/ngax/templates/settings.html index 269138471..93339ca05 100644 --- a/Duplicati/Server/webroot/ngax/templates/settings.html +++ b/Duplicati/Server/webroot/ngax/templates/settings.html @@ -39,7 +39,9 @@