From e8b601c7630d81e4bb6bcbebdc2dc48fb835eb83 Mon Sep 17 00:00:00 2001 From: 0aubsq <0aubsq@gmail.com> Date: Sun, 24 Oct 2021 13:50:33 +0200 Subject: [PATCH] Change I18N structure from function overrides to dictionnaries to make it lighter --- TJAPlayer3/I18N/CLang_en.cs | 19 ++++++++++++++----- TJAPlayer3/I18N/CLang_fr.cs | 19 ++++++++++++++----- TJAPlayer3/I18N/CLang_jp.cs | 19 ++++++++++++++----- TJAPlayer3/I18N/ILang.cs | 3 +-- TJAPlayer3/Stages/04.Config/CActConfigList.cs | 14 ++++++-------- 5 files changed, 49 insertions(+), 25 deletions(-) diff --git a/TJAPlayer3/I18N/CLang_en.cs b/TJAPlayer3/I18N/CLang_en.cs index dc222fed..144376e3 100644 --- a/TJAPlayer3/I18N/CLang_en.cs +++ b/TJAPlayer3/I18N/CLang_en.cs @@ -7,14 +7,23 @@ namespace TJAPlayer3 { internal class CLang_en : ILang { - string ILang.ConfigChangeLanguage() + string ILang.GetString(int idx) { - return "Change the displayed language\ningame and within the menus."; + if (!dictionnary.ContainsKey(idx)) + return "[!] Index not found in dictionnary"; + + return dictionnary[idx]; } - string ILang.ConfigChangeLanguageHead() + + private static readonly Dictionary dictionnary = new Dictionary { - return "System language"; - } + [0] = "Change the displayed language\ningame and within the menus.", + [1] = "System language", + [2] = "<< Return to Menu", + [3] = "Return to left menu.", + [4] = "Reload song data", + [5] = "Retrieve and update the song list.", + }; } } \ No newline at end of file diff --git a/TJAPlayer3/I18N/CLang_fr.cs b/TJAPlayer3/I18N/CLang_fr.cs index 3b81ff49..994488b1 100644 --- a/TJAPlayer3/I18N/CLang_fr.cs +++ b/TJAPlayer3/I18N/CLang_fr.cs @@ -7,14 +7,23 @@ namespace TJAPlayer3 { internal class CLang_fr : ILang { - string ILang.ConfigChangeLanguage() + string ILang.GetString(int idx) { - return "Changer la langue affichée\ndans les menus et en jeu."; + if (!dictionnary.ContainsKey(idx)) + return "[!] Index non trouvé dans le dictionnaire"; + + return dictionnary[idx]; } - string ILang.ConfigChangeLanguageHead() + + private static readonly Dictionary dictionnary = new Dictionary { - return "Langue du système"; - } + [0] = "Changer la langue affichée\ndans les menus et en jeu.", + [1] = "Langue du système", + [2] = "<< Retour au menu", + [3] = "Retour au menu principal.", + [4] = "Recharger les sons", + [5] = "Met à jour et récupère les\nmodifications effectuées sur\nla liste de sons.", + }; } } \ No newline at end of file diff --git a/TJAPlayer3/I18N/CLang_jp.cs b/TJAPlayer3/I18N/CLang_jp.cs index d5323833..7ea0535c 100644 --- a/TJAPlayer3/I18N/CLang_jp.cs +++ b/TJAPlayer3/I18N/CLang_jp.cs @@ -7,14 +7,23 @@ namespace TJAPlayer3 { internal class CLang_jp : ILang { - string ILang.ConfigChangeLanguage() + string ILang.GetString(int idx) { - return "vC⃁j[\n\錾ύXB"; + if (!dictionnary.ContainsKey(idx)) + return "[!] ŋ߂w‚܂ł"; + + return dictionnary[idx]; } - string ILang.ConfigChangeLanguageHead() + + private static readonly Dictionary dictionnary = new Dictionary { - return "VXe"; - } + [0] = "vC⃁j[\n\錾ύXB", + [1] = "VXe", + [2] = "<< ߂", + [3] = "̃j[ɖ߂܂B", + [4] = "ȃf[^ēǍ", + [5] = "ȃf[^̈ꗗ擾܂B", + }; } } \ No newline at end of file diff --git a/TJAPlayer3/I18N/ILang.cs b/TJAPlayer3/I18N/ILang.cs index 45948892..84a350c4 100644 --- a/TJAPlayer3/I18N/ILang.cs +++ b/TJAPlayer3/I18N/ILang.cs @@ -7,8 +7,7 @@ namespace TJAPlayer3 { internal interface ILang { - string ConfigChangeLanguage(); - string ConfigChangeLanguageHead(); + string GetString(int idx); } static internal class CLangManager diff --git a/TJAPlayer3/Stages/04.Config/CActConfigList.cs b/TJAPlayer3/Stages/04.Config/CActConfigList.cs index aa4fd889..7ab1dee8 100644 --- a/TJAPlayer3/Stages/04.Config/CActConfigList.cs +++ b/TJAPlayer3/Stages/04.Config/CActConfigList.cs @@ -69,19 +69,17 @@ namespace TJAPlayer3 // #27029 2012.1.5 from: 説明文は最大9行→13行に変更。 - this.iSystemReturnToMenu = new CItemBase( "<< ReturnTo Menu", CItemBase.Eパネル種別.その他, - "左側のメニューに戻ります。", - "Return to left menu." ); + this.iSystemReturnToMenu = new CItemBase(CLangManager.LangInstance.GetString(2), CItemBase.Eパネル種別.その他, + CLangManager.LangInstance.GetString(3)); this.list項目リスト.Add( this.iSystemReturnToMenu ); - this.iSystemReloadDTX = new CItemBase( "曲データ再読込み", CItemBase.Eパネル種別.通常, - "曲データの一覧情報を取得し直します。", - "Reload song data." ); + this.iSystemReloadDTX = new CItemBase(CLangManager.LangInstance.GetString(4), CItemBase.Eパネル種別.通常, + CLangManager.LangInstance.GetString(5)); this.list項目リスト.Add( this.iSystemReloadDTX ); - this.iSystemLanguage = new CItemList(CLangManager.LangInstance.ConfigChangeLanguageHead(), CItemList.Eパネル種別.通常, CLangManager.langToInt(TJAPlayer3.ConfigIni.sLang), - CLangManager.LangInstance.ConfigChangeLanguage(), + this.iSystemLanguage = new CItemList(CLangManager.LangInstance.GetString(1), CItemList.Eパネル種別.通常, CLangManager.langToInt(TJAPlayer3.ConfigIni.sLang), + CLangManager.LangInstance.GetString(0), CLangManager.Languages); this.list項目リスト.Add(this.iSystemLanguage);