diff --git a/PKHeX.Core/PKM/SK2.cs b/PKHeX.Core/PKM/SK2.cs index 70995cf37..e2621e789 100644 --- a/PKHeX.Core/PKM/SK2.cs +++ b/PKHeX.Core/PKM/SK2.cs @@ -137,7 +137,7 @@ public sealed class SK2 : GBPKM, ICaughtData2 protected override void GetNonNickname(int language, Span data) { var name = SpeciesName.GetSpeciesNameGeneration(Species, language, 2); - StringConverter2.SetString(data, name, data.Length, Language, StringConverterOption.Clear50); + StringConverter2.SetString(data, name, data.Length, language, StringConverterOption.Clear50); } public override void SetNotNicknamed(int language) => GetNonNickname(language, NicknameTrash); diff --git a/PKHeX.Core/PKM/Shared/GBPKM.cs b/PKHeX.Core/PKM/Shared/GBPKM.cs index 72e6cd187..5e6b6188b 100644 --- a/PKHeX.Core/PKM/Shared/GBPKM.cs +++ b/PKHeX.Core/PKM/Shared/GBPKM.cs @@ -187,12 +187,20 @@ public abstract class GBPKM : PKM public void SetNotNicknamed() => SetNotNicknamed(GuessedLanguage()); public abstract void SetNotNicknamed(int language); + public bool IsSpeciesNameMatch(int language) + { + var expect = SpeciesName.GetSpeciesNameGeneration(Species, language, 2); + Span current = stackalloc char[TrashCharCountNickname]; + int len = LoadString(NicknameTrash, current); + return current[..len].SequenceEqual(expect); + } + public int GuessedLanguage(int fallback = (int)LanguageID.English) { int lang = Language; if (lang > 0) return lang; - if (fallback is (int)LanguageID.French or (int)LanguageID.German) // only other permitted besides English + if (fallback is (int)LanguageID.French or (int)LanguageID.German or (int)LanguageID.Italian or (int)LanguageID.Spanish) // only other permitted besides English return fallback; return (int)LanguageID.English; } @@ -205,8 +213,7 @@ public abstract class GBPKM : PKM protected int TransferLanguage(int destLanguage) { // if the Species name of the destination language matches the current nickname, transfer with that language. - var expect = SpeciesName.GetSpeciesNameGeneration(Species, destLanguage, 2); - if (Nickname == expect) + if (IsSpeciesNameMatch(destLanguage)) return destLanguage; return GuessedLanguage(destLanguage); } diff --git a/PKHeX.WinForms/Controls/PKM Editor/EditPK1.cs b/PKHeX.WinForms/Controls/PKM Editor/EditPK1.cs index 54a249d48..e6cf97fc4 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/EditPK1.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/EditPK1.cs @@ -15,7 +15,8 @@ public partial class PKMEditor CR_PK1.LoadPK1(pk1); // Attempt to detect language - CB_Language.SelectedValue = pk1.GuessedLanguage(); + var language = RequestSaveFile.Language; + CB_Language.SelectedValue = pk1.IsSpeciesNameMatch(language) ? language : pk1.GuessedLanguage(language); LoadPartyStats(pk1); UpdateStats(); diff --git a/PKHeX.WinForms/Controls/PKM Editor/EditPK2.cs b/PKHeX.WinForms/Controls/PKM Editor/EditPK2.cs index 7b435a6f3..3946e223f 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/EditPK2.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/EditPK2.cs @@ -24,7 +24,8 @@ public partial class PKMEditor CB_MetTimeOfDay.SelectedIndex = c2.MetTimeOfDay; // Attempt to detect language - CB_Language.SelectedValue = pk2.GuessedLanguage(); + var language = RequestSaveFile.Language; + CB_Language.SelectedValue = pk2.IsSpeciesNameMatch(language) ? language : pk2.GuessedLanguage(language); LoadPartyStats(pk2); UpdateStats();