Add messagestring dumper

untested, will monkey with later
This commit is contained in:
Kurt 2018-04-06 22:51:10 -07:00
parent 41653490c1
commit 2acef4eaf7
2 changed files with 12 additions and 5 deletions

View file

@ -930,6 +930,7 @@ namespace PKHeX.WinForms
Task.Run(() => { Task.Run(() => {
var lang = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.Substring(0, 2); var lang = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.Substring(0, 2);
Util.SetLocalization(typeof(LegalityCheckStrings), lang); Util.SetLocalization(typeof(LegalityCheckStrings), lang);
Util.SetLocalization(typeof(MessageStrings), lang);
RibbonStrings.ResetDictionary(GameInfo.Strings.ribbons); RibbonStrings.ResetDictionary(GameInfo.Strings.ribbons);
}); });

View file

@ -48,22 +48,28 @@ namespace PKHeX.WinForms
nameof(SettingsEditor), nameof(SettingsEditor),
}; };
public static void DumpLegalityStrings()
public static void DumpStringsMessage() => DumpStrings(typeof(MessageStrings));
public static void DumpStringsLegality() => DumpStrings(typeof(LegalityCheckStrings));
private static void DumpStrings(Type t, bool sort = false)
{ {
var langs = new[] {DefaultLanguage}.Concat(Languages); var langs = new[] {DefaultLanguage}.Concat(Languages);
foreach (var lang in langs) foreach (var lang in langs)
{ {
Util.SetLocalization(typeof(LegalityCheckStrings), lang); Util.SetLocalization(t, lang);
var entries = Util.GetLocalization(typeof(LegalityCheckStrings)); var entries = Util.GetLocalization(t);
var export = entries.Select(z => new {Variable = z.Split('=')[0], Line = z}) var export = entries.Select(z => new {Variable = z.Split('=')[0], Line = z})
.GroupBy(z => z.Variable.Length) // fancy sort! .GroupBy(z => z.Variable.Length) // fancy sort!
.OrderBy(z => z.Key) // sort by length (V1 = 2, V100 = 4) .OrderBy(z => z.Key) // sort by length (V1 = 2, V100 = 4)
.SelectMany(z => z.OrderBy(n => n.Variable)) // select sets from ordered Names .SelectMany(z => z.OrderBy(n => n.Variable)) // select sets from ordered Names
.Select(z => z.Line); // sorted lines .Select(z => z.Line); // sorted lines
var fn = $"{nameof(LegalityCheckStrings)}_{lang}.txt"; if (!sort) // discard linq
export = entries;
var fn = $"{t.Name}_{lang}.txt";
File.WriteAllLines(fn, export); File.WriteAllLines(fn, export);
Util.SetLocalization(typeof(LegalityCheckStrings), DefaultLanguage); Util.SetLocalization(t, DefaultLanguage);
} }
} }
} }