fix language default selection
If the browser or system language is not supported, display "Default (en, English)"
This commit is contained in:
@@ -138,6 +138,14 @@ namespace Duplicati.Library.Localization
|
||||
{
|
||||
get { return MoLocalizationService.SupportedCultures; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the culture has localization support
|
||||
/// </summary>
|
||||
public static Boolean isCultureSupported(CultureInfo culture)
|
||||
{
|
||||
return MoLocalizationService.isCultureSupported(culture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -163,12 +163,12 @@ namespace Duplicati.Library.Localization
|
||||
return catalog.GetString(message, args);
|
||||
}
|
||||
|
||||
private static List<String> m_supportedcultures = null;
|
||||
private static IEnumerable<CultureInfo> m_supportedcultures = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all the supported cultures
|
||||
/// </summary>
|
||||
public static IEnumerable<string> SupportedCultures
|
||||
private static IEnumerable<CultureInfo> 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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of all the supported cultures
|
||||
/// </summary>
|
||||
public static IEnumerable<string> SupportedCultures
|
||||
{
|
||||
get
|
||||
{
|
||||
return SupportedCultureInfos
|
||||
.Select(x => x.Name).Distinct()
|
||||
.OrderBy(x => x)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the culture has localization support
|
||||
/// </summary>
|
||||
public static Boolean isCultureSupported(CultureInfo culture)
|
||||
{
|
||||
foreach (var supportedCulture in SupportedCultureInfos)
|
||||
{
|
||||
if (supportedCulture.TwoLetterISOLanguageName == culture.TwoLetterISOLanguageName)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -39,7 +39,9 @@
|
||||
<label for="userinterfacelanguage" translate>Language in user interface</label>
|
||||
|
||||
<select id="userinterfacelanguage" ng-model="uiLanguage" ng-options="item.Code as item.DisplayName + ' (' + item.Code + ', ' + item.EnglishName + ')' for item in SystemInfo.SupportedLocales">
|
||||
<option value="" translate translate-params-displayname="SystemInfo.BrowserLocale.DisplayName" translate-params-code="SystemInfo.BrowserLocale.Code">Browser default ({{displayname}}, {{code}})</option>
|
||||
<option value="">{{ SystemInfo.BrowserLocaleSupported ?
|
||||
lang_browser_default + " (" + SystemInfo.BrowserLocale.DisplayName + ", " + SystemInfo.BrowserLocale.Code + ")" :
|
||||
lang_default + " (en, English)" }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user