1
0
mirror of synced 2024-11-28 09:20:53 +01:00

Base I18N implementation : Implement a structure that will make able to select a language within the settings menu (or config.ini) and the said menu option (Currently contains few texts in Japanese, English and French)

This commit is contained in:
0aubsq 2021-10-24 09:20:14 +02:00
parent 43eedd98f2
commit 637cafd892
8 changed files with 208 additions and 29 deletions

View File

@ -770,7 +770,6 @@ namespace TJAPlayer3
public bool bEndingAnime = false; // 2017.01.27 DD 「また遊んでね」画面の有効/無効オプション追加
public STDGBVALUE<E判定文字表示位置> ;
// public int nハイハット切り捨て下限Velocity;
// public int n切り捨て下限Velocity; // #23857 2010.12.12 yyagi VelocityMin
@ -875,6 +874,10 @@ namespace TJAPlayer3
public bool ShinuchiMode; // 真打モード
public bool FastRender; // 事前画像描画モード
public int MusicPreTimeMs; // 音源再生前の待機時間ms
// I18N choosen language
public string sLang = "jp";
/// <summary>
/// DiscordのRitch Presenceに再生中の.tjaファイルの情報を送信するかどうか。
/// </summary>
@ -1287,6 +1290,7 @@ namespace TJAPlayer3
this.BoxFontName = "MS UI Gothic";
this.ApplyLoudnessMetadata = true;
this.bEnableCountdownTimer = true;
this.sLang = "jp";
// 2018-08-28 twopointzero:
// There exists a particular large, well-known, well-curated, and
@ -1531,6 +1535,17 @@ namespace TJAPlayer3
sw.WriteLine("{0}={1}", nameof(FastRender), FastRender ? 1 : 0);
sw.WriteLine();
#endregion
#region [Language]
sw.WriteLine("; プレイ中やメニューの表示される言語を変更。");
sw.WriteLine("; Change the displayed language ingame and within the menus.");
sw.WriteLine("Lang={0}", this.sLang);
sw.WriteLine();
#endregion
#region [ Window関連 ]
sw.WriteLine( "; 画面モード(0:ウィンドウ, 1:全画面)" );
sw.WriteLine( "; Screen mode. (0:Window, 1:Fullscreen)" );
@ -2163,6 +2178,12 @@ namespace TJAPlayer3
this.str曲データ検索パス = str4;
}
#endregion
else if( str3.Equals("Lang"))
{
CLangManager.langAttach(str4);
}
#region [ skin関係 ]
else if ( str3.Equals( "SkinPath" ) )
{

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TJAPlayer3
{
internal class CLang_en : ILang
{
string ILang.ConfigChangeLanguage()
{
return "Change the displayed language\ningame and within the menus.";
}
string ILang.ConfigChangeLanguageHead()
{
return "System language";
}
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TJAPlayer3
{
internal class CLang_fr : ILang
{
string ILang.ConfigChangeLanguage()
{
return "Changer la langue affichée\ndans les menus et en jeu.";
}
string ILang.ConfigChangeLanguageHead()
{
return "Langue du système";
}
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TJAPlayer3
{
internal class CLang_jp : ILang
{
string ILang.ConfigChangeLanguage()
{
return "プレイ中やメニューの\n表示される言語を変更。";
}
string ILang.ConfigChangeLanguageHead()
{
return "システム言語";
}
}
}

64
TJAPlayer3/I18N/ILang.cs Normal file
View File

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TJAPlayer3
{
internal interface ILang
{
string ConfigChangeLanguage();
string ConfigChangeLanguageHead();
}
static internal class CLangManager
{
// Cheap factory-like design pattern
public static void langAttach(string lang)
{
switch (lang) {
case "fr":
CLangManager.LangInstance = new CLang_fr();
break;
case "en":
CLangManager.LangInstance = new CLang_en();
break;
case "jp":
default:
CLangManager.LangInstance = new CLang_jp();
break;
}
}
public static int langToInt(string lang)
{
switch (lang)
{
case "fr":
return 2;
case "en":
return 1;
case "jp":
default:
return 0;
}
}
public static string intToLang(int idx)
{
switch (idx)
{
case 2:
return "fr";
case 1:
return "en";
case 0:
default:
return "jp";
}
}
public static string[] Languages = new string[] { "日本語", "English", "Français" };
public static ILang LangInstance = new CLang_jp();
}
}

View File

@ -62,7 +62,7 @@ namespace TJAPlayer3
// メソッド
#region [ t項目リストの設定_System() ]
public void t項目リストの設定_System()
public void t項目リストの設定_System(bool refresh = true)
{
this.tConfigIniへ記録する();
this.list項目リスト.Clear();
@ -79,6 +79,12 @@ namespace TJAPlayer3
"Reload song data." );
this.list項目リスト.Add( this.iSystemReloadDTX );
this.iSystemLanguage = new CItemList(CLangManager.LangInstance.ConfigChangeLanguageHead(), CItemList.Eパネル種別., CLangManager.langToInt(TJAPlayer3.ConfigIni.sLang),
CLangManager.LangInstance.ConfigChangeLanguage(),
CLangManager.Languages);
this.list項目リスト.Add(this.iSystemLanguage);
//this.iCommonDark = new CItemList( "Dark", CItemBase.Eパネル種別.通常, (int) CDTXMania.ConfigIni.eDark,
// "HALF: 背景、レーン、ゲージが表示\nされなくなります。\nFULL: さらに小節線、拍線、判定ラ\nイン、パッドも表示されなくなります。",
// "OFF: all display parts are shown.\nHALF: wallpaper, lanes and gauge are\n disappeared.\nFULL: additionaly to HALF, bar/beat\n lines, hit bar, pads are disappeared.",
@ -490,9 +496,13 @@ namespace TJAPlayer3
this.list項目リスト.Add( this.iSystemGoToKeyAssign );
OnListMenuの初期化();
if (refresh)
{
this.n現在の選択項目 = 0;
this.eメニュー種別 = Eメニュー種別.System;
}
}
#endregion
#region [ t項目リストの設定_Drums() ]
public void t項目リストの設定_Drums()
@ -805,6 +815,13 @@ namespace TJAPlayer3
//{
// // 変更許可
this.list項目リスト[ this.n現在の選択項目 ].tEnter押下();
if (this.list項目リスト[this.n現在の選択項目] == this.iSystemLanguage)
{
TJAPlayer3.ConfigIni.sLang = CLangManager.intToLang(this.iSystemLanguage.n現在選択されている項目番号);
CLangManager.langAttach(TJAPlayer3.ConfigIni.sLang);
t項目リストの設定_System(refresh : false);
}
//}
@ -1555,6 +1572,9 @@ namespace TJAPlayer3
private CItemToggle iSystemBufferedInput;
private CItemInteger iSystemRisky; // #23559 2011.7.27 yyagi
private CItemList iSystemSoundType; // #24820 2013.1.3 yyagi
private CItemList iSystemLanguage;
private CItemInteger iSystemWASAPIBufferSizeMs; // #24820 2013.1.15 yyagi
// private CItemInteger iSystemASIOBufferSizeMs; // #24820 2013.1.3 yyagi
private CItemList iSystemASIODevice; // #24820 2013.1.17 yyagi
@ -1713,10 +1733,16 @@ namespace TJAPlayer3
TJAPlayer3.ConfigIni.bUseOSTimer = this.iSystemSoundTimerType.bON; // #33689 2014.6.17 yyagi
TJAPlayer3.ConfigIni.bTimeStretch = this.iSystemTimeStretch.bON; // #23664 2013.2.24 yyagi
//Trace.TraceInformation( "saved" );
//Trace.TraceInformation( "Skin現在Current : " + CDTXMania.Skin.GetCurrentSkinSubfolderFullName(true) );
//Trace.TraceInformation( "Skin現在System : " + CSkin.strSystemSkinSubfolderFullName );
//Trace.TraceInformation( "Skin現在BoxDef : " + CSkin.strBoxDefSkinSubfolderFullName );
TJAPlayer3.ConfigIni.sLang = CLangManager.intToLang(this.iSystemLanguage.n現在選択されている項目番号);
CLangManager.langAttach(TJAPlayer3.ConfigIni.sLang);
//Trace.TraceInformation( "saved" );
//Trace.TraceInformation( "Skin現在Current : " + CDTXMania.Skin.GetCurrentSkinSubfolderFullName(true) );
//Trace.TraceInformation( "Skin現在System : " + CSkin.strSystemSkinSubfolderFullName );
//Trace.TraceInformation( "Skin現在BoxDef : " + CSkin.strBoxDefSkinSubfolderFullName );
//CDTXMania.ConfigIni.nMasterVolume = this.iSystemMasterVolume.n現在の値; // #33700 2014.4.26 yyagi
//CDTXMania.ConfigIni.e判定表示優先度 = (E判定表示優先度) this.iSystemJudgeDispPriority.n現在選択されている項目番号;
TJAPlayer3.ConfigIni.ShowChara = this.ShowChara.bON;

View File

@ -358,6 +358,9 @@ namespace TJAPlayer3
case EItemPanelモード.:
bool bIsKeyAssignSelectedBeforeHitEnter = this.actList.bIsKeyAssignSelected; // #24525 2011.3.15 yyagi
this.actList.tEnter押下();
this.t説明文パネルに現在選択されている項目の説明を描画する();
if ( this.actList.b現在選択されている項目はReturnToMenuである )
{
this.t説明文パネルに現在選択されているメニューの説明を描画する();

View File

@ -106,6 +106,9 @@
<Compile Include="Common\Discord.cs" />
<Compile Include="Common\Easing.cs" />
<Compile Include="Common\NamePlateConfig.cs" />
<Compile Include="I18N\CLang_fr.cs" />
<Compile Include="I18N\CLang_en.cs" />
<Compile Include="I18N\CLang_jp.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Discord.resx">
<Generator>ResXFileCodeGenerator</Generator>
@ -127,6 +130,7 @@
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<Compile Include="I18N\ILang.cs" />
<None Include="TJAPlayer3.manifest" />
<None Include="DTXManiaGR.exe.x86.manifest" />
<None Include="Properties\Settings.settings">
@ -338,6 +342,7 @@
<Version>4.2.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.