2021-10-24 09:20:14 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace TJAPlayer3
|
|
|
|
|
{
|
|
|
|
|
internal interface ILang
|
|
|
|
|
{
|
2021-10-24 13:50:33 +02:00
|
|
|
|
string GetString(int idx);
|
2021-10-24 09:20:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static internal class CLangManager
|
|
|
|
|
{
|
|
|
|
|
// Cheap factory-like design pattern
|
2022-06-25 20:40:55 +02:00
|
|
|
|
|
|
|
|
|
public static (string, int) DefaultLanguage = ("jp", 0);
|
2021-10-24 09:20:14 +02:00
|
|
|
|
public static void langAttach(string lang)
|
|
|
|
|
{
|
|
|
|
|
switch (lang) {
|
2022-02-15 12:04:56 +01:00
|
|
|
|
case "zh":
|
|
|
|
|
CLangManager.LangInstance = new CLang_zh();
|
|
|
|
|
break;
|
2021-11-09 13:45:21 +01:00
|
|
|
|
case "es":
|
|
|
|
|
CLangManager.LangInstance = new CLang_es();
|
|
|
|
|
break;
|
2021-10-24 09:20:14 +02:00
|
|
|
|
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)
|
|
|
|
|
{
|
2022-02-15 12:04:56 +01:00
|
|
|
|
case "zh":
|
|
|
|
|
return 4;
|
2021-11-09 13:45:21 +01:00
|
|
|
|
case "es":
|
|
|
|
|
return 3;
|
2021-10-24 09:20:14 +02:00
|
|
|
|
case "fr":
|
|
|
|
|
return 2;
|
|
|
|
|
case "en":
|
|
|
|
|
return 1;
|
|
|
|
|
case "jp":
|
|
|
|
|
default:
|
2022-06-25 20:40:55 +02:00
|
|
|
|
return DefaultLanguage.Item2;
|
2021-10-24 09:20:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-25 20:40:55 +02:00
|
|
|
|
public static string fetchLang()
|
|
|
|
|
{
|
|
|
|
|
if (LangInstance is CLang_jp)
|
|
|
|
|
return "jp";
|
|
|
|
|
else if (LangInstance is CLang_en)
|
|
|
|
|
return "en";
|
|
|
|
|
else if (LangInstance is CLang_fr)
|
|
|
|
|
return "fr";
|
|
|
|
|
else if (LangInstance is CLang_es)
|
|
|
|
|
return "es";
|
|
|
|
|
else if (LangInstance is CLang_zh)
|
|
|
|
|
return "zh";
|
|
|
|
|
return DefaultLanguage.Item1;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-24 09:20:14 +02:00
|
|
|
|
public static string intToLang(int idx)
|
|
|
|
|
{
|
|
|
|
|
switch (idx)
|
|
|
|
|
{
|
2022-02-15 12:04:56 +01:00
|
|
|
|
case 4:
|
|
|
|
|
return "zh";
|
2021-11-09 13:45:21 +01:00
|
|
|
|
case 3:
|
|
|
|
|
return "es";
|
2021-10-24 09:20:14 +02:00
|
|
|
|
case 2:
|
|
|
|
|
return "fr";
|
|
|
|
|
case 1:
|
|
|
|
|
return "en";
|
|
|
|
|
case 0:
|
|
|
|
|
default:
|
2022-06-25 20:40:55 +02:00
|
|
|
|
return DefaultLanguage.Item1;
|
2021-10-24 09:20:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-15 12:04:56 +01:00
|
|
|
|
public static readonly string[] Languages = new string[] { "日本語", "English", "Français", "Español", "中文" };
|
2021-10-25 12:13:24 +02:00
|
|
|
|
public static ILang LangInstance { get; private set; } = new CLang_jp();
|
2021-10-24 09:20:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|