mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-23 12:33:06 +00:00
Extract language initialization to core
Call this method whenever you boot a separate app that needs legality strings to be ready.
This commit is contained in:
parent
3813d5dba9
commit
88dcb59798
2 changed files with 33 additions and 21 deletions
32
PKHeX.Core/Editing/LocalizeUtil.cs
Normal file
32
PKHeX.Core/Editing/LocalizeUtil.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace PKHeX.Core
|
||||
{
|
||||
public static class LocalizeUtil
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes PKHeX's runtime strings to the specified language.
|
||||
/// </summary>
|
||||
/// <param name="lang">2-char language ID</param>
|
||||
/// <param name="sav">Save data (optional)</param>
|
||||
/// <param name="hax">Permit illegal things (items, only)</param>
|
||||
public static void InitializeStrings(string lang, SaveFile? sav = null, bool hax = false)
|
||||
{
|
||||
var str = GameInfo.Strings = GameInfo.GetStrings(lang);
|
||||
if (sav != null)
|
||||
GameInfo.FilteredSources = new FilteredGameDataSource(sav, GameInfo.Sources, hax);
|
||||
|
||||
// Update Legality Analysis strings
|
||||
LegalityAnalysis.MoveStrings = str.movelist;
|
||||
LegalityAnalysis.SpeciesStrings = str.specieslist;
|
||||
|
||||
// Update Legality Strings
|
||||
Task.Run(() =>
|
||||
{
|
||||
RibbonStrings.ResetDictionary(str.ribbons);
|
||||
Util.SetLocalization(typeof(LegalityCheckStrings), lang);
|
||||
Util.SetLocalization(typeof(MessageStrings), lang);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -917,7 +917,7 @@ namespace PKHeX.WinForms
|
|||
|
||||
Menu_Options.DropDown.Close();
|
||||
|
||||
InitializeStrings();
|
||||
LocalizeUtil.InitializeStrings(CurrentLanguage, C_SAV.SAV, HaX);
|
||||
WinFormsUtil.TranslateInterface(this, CurrentLanguage); // Translate the UI to language.
|
||||
if (C_SAV.SAV != null)
|
||||
{
|
||||
|
@ -928,26 +928,6 @@ namespace PKHeX.WinForms
|
|||
Text = GetProgramTitle(sav);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeStrings()
|
||||
{
|
||||
string l = CurrentLanguage;
|
||||
GameInfo.Strings = GameInfo.GetStrings(l);
|
||||
if (C_SAV.SAV != null)
|
||||
GameInfo.FilteredSources = new FilteredGameDataSource(C_SAV.SAV, GameInfo.Sources, HaX);
|
||||
|
||||
// Update Legality Strings
|
||||
Task.Run(() => {
|
||||
var lang = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.Substring(0, 2);
|
||||
Util.SetLocalization(typeof(LegalityCheckStrings), lang);
|
||||
Util.SetLocalization(typeof(MessageStrings), lang);
|
||||
RibbonStrings.ResetDictionary(GameInfo.Strings.ribbons);
|
||||
});
|
||||
|
||||
// Update Legality Analysis strings
|
||||
LegalityAnalysis.MoveStrings = GameInfo.Strings.movelist;
|
||||
LegalityAnalysis.SpeciesStrings = GameInfo.Strings.specieslist;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region //// PKX WINDOW FUNCTIONS ////
|
||||
|
|
Loading…
Reference in a new issue