Skip to content

Commit

Permalink
SG : Translation(en , zh-CN , zh-TW)
Browse files Browse the repository at this point in the history
  • Loading branch information
LegendsOfSky committed Jul 14, 2021
1 parent d5e9355 commit 65faec9
Show file tree
Hide file tree
Showing 5 changed files with 389 additions and 46 deletions.
27 changes: 27 additions & 0 deletions PCCSettingsCalculator/LanguageType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;

namespace PCCSettingsGenerator
{
public enum LanguageType
{
en,
zh_TW,
zh_CN
}

public static class LanguageTypeUtils
{
public static string ToString(LanguageType language)
{
return language.ToString().Replace("_" , "-");
}

public static bool TryPrase(string name , out LanguageType language)
{
return Enum.TryParse<LanguageType>(name.Replace("-" , "_") , out language);
}
}
}
38 changes: 17 additions & 21 deletions PCCSettingsCalculator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,9 @@ static void Main(string[] args)
}
catch(MissingManifestResourceException)
{
Console.WriteLine("Available language option");
Console.WriteLine("1) en");
Console.WriteLine("2) zh-TW");
Console.WriteLine("Please choose a language.");
temp = Console.ReadLine();
while(!int.TryParse(temp , out int i) && i < 3 && i > 0)
{
Console.WriteLine("Unexpected response. Please choose a language.");
temp = Console.ReadLine();
}
if(temp == "1")
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("en");
else if(temp == "2")
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("zh-TW");
Console.WriteLine(manager.GetObject("Language"));
LanguageRequest();
}
Console.WriteLine(manager.GetObject("Translate"));
Console.WriteLine(manager.GetObject("PressKey"));
Console.ReadKey();
Clear();
Expand Down Expand Up @@ -156,7 +143,7 @@ static void Main(string[] args)
Console.WriteLine(manager.GetObject("Statement5"));
SeparatingLine();
Console.WriteLine(manager.GetObject("TNTSymbol"));
string temp2 = Console.ReadLine();
string temp2 = Console.ReadLine().ToUpper();
while(temp2 != "A" && temp2 != "B" && temp2 != "C" && temp2 != "D")
{
SeparatingLine();
Expand Down Expand Up @@ -287,7 +274,7 @@ private static void SaveSettingsToJson(string path , Settings settings)
}


public static Space3D ReadSpace3DFromConsole(string valueName)
private static Space3D ReadSpace3DFromConsole(string valueName)
{
Space3D result;
Console.WriteLine(valueName + " X :");
Expand Down Expand Up @@ -317,7 +304,7 @@ public static Space3D ReadSpace3DFromConsole(string valueName)
return result;
}

public static Surface2D ReadSurface2DFromConsole(string valueName)
private static Surface2D ReadSurface2DFromConsole(string valueName)
{
Surface2D result = new Surface2D();
Console.WriteLine(valueName + " X :");
Expand All @@ -339,7 +326,7 @@ public static Surface2D ReadSurface2DFromConsole(string valueName)
return result;
}

public static void Clear()
private static void Clear()
{
Console.Clear();
Console.WriteLine(manager.GetObject("Welcome"));
Expand All @@ -354,9 +341,18 @@ public static void Clear()
Console.WriteLine();
}

public static void SeparatingLine()
private static void SeparatingLine() => Console.WriteLine(manager.GetObject("Separate"));

private static void LanguageRequest()
{
Console.WriteLine(manager.GetObject("Separate"));
int i = 0;
Console.WriteLine("Available language option");
foreach(var item in Enum.GetValues(typeof(LanguageType)))
Console.WriteLine((++i).ToString() + ") " + LanguageTypeUtils.ToString((LanguageType)item));
Console.WriteLine("Please choose a language.");
int.TryParse(Console.ReadLine() , out i);
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(LanguageTypeUtils.ToString((LanguageType)(i - 1)));
Console.WriteLine(manager.GetObject("Language"));
}
}
}
3 changes: 3 additions & 0 deletions PCCSettingsCalculator/Resources/Language.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@
<data name="TNTSymbolParameter" xml:space="preserve">
<value>Corresponding English symbol for red TNT</value>
</data>
<data name="Translate" xml:space="preserve">
<value>Translate : LegendsOfSky</value>
</data>
<data name="UnexpectedResponseJson" xml:space="preserve">
<value>Unexpected response. Do you want to save as settings.json? (Y/N)</value>
</data>
Expand Down
Loading

0 comments on commit 65faec9

Please sign in to comment.