Respect CurrentCulture also in CG

This commit is contained in:
JustArchi 2017-01-08 15:29:04 +01:00
parent 1affdb4e74
commit bbefb7d507
3 changed files with 24 additions and 1 deletions

View file

@ -168,6 +168,15 @@ namespace ConfigGenerator.Localization {
}
}
/// <summary>
/// Looks up a localized string similar to Your provided CurrentCulture is invalid, ConfigGenerator will keep running with default one!.
/// </summary>
internal static string ErrorInvalidCurrentCulture {
get {
return ResourceManager.GetString("ErrorInvalidCurrentCulture", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to This name is already used!.
/// </summary>

View file

@ -154,6 +154,9 @@
<value>Configured {0} property is invalid: {1}</value>
<comment>{0} will be replaced by name of the configuration property, {1} will be replaced by invalid value</comment>
</data>
<data name="ErrorInvalidCurrentCulture" xml:space="preserve">
<value>Your provided CurrentCulture is invalid, ConfigGenerator will keep running with default one!</value>
</data>
<data name="ErrorNameAlreadyUsed" xml:space="preserve">
<value>This name is already used!</value>
<comment>This happens e.g. when user wants to create a bot with name that exists already</comment>

View file

@ -25,6 +25,7 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
@ -64,8 +65,18 @@ namespace ConfigGenerator {
return;
}
ASFTab = new ConfigPage(GlobalConfig.Load(Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalConfigFileName)));
GlobalConfig globalConfig = GlobalConfig.Load(Path.Combine(SharedInfo.ConfigDirectory, SharedInfo.GlobalConfigFileName));
if (!string.IsNullOrEmpty(globalConfig.CurrentCulture)) {
try {
// GetCultureInfo() would be better but we can't use it for specifying neutral cultures such as "en"
CultureInfo culture = CultureInfo.CreateSpecificCulture(globalConfig.CurrentCulture);
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.DefaultThreadCurrentUICulture = culture;
} catch (CultureNotFoundException) {
Logging.LogGenericErrorWithoutStacktrace(CGStrings.ErrorInvalidCurrentCulture);
}
}
ASFTab = new ConfigPage(globalConfig);
MainTab.TabPages.Add(ASFTab);
foreach (string configFile in Directory.EnumerateFiles(SharedInfo.ConfigDirectory, "*.json")) {