Merge remote-tracking branch 'kawaiiyuyu/lang' into general-devel
This commit is contained in:
commit
9f7a8aa05b
2 changed files with 23 additions and 2 deletions
|
|
@ -21,7 +21,10 @@ global using static TShockAPI.I18n;
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
using GetText;
|
using GetText;
|
||||||
|
using Terraria.Initializers;
|
||||||
|
using Terraria.Localization;
|
||||||
|
|
||||||
namespace TShockAPI
|
namespace TShockAPI
|
||||||
{
|
{
|
||||||
|
|
@ -29,8 +32,7 @@ namespace TShockAPI
|
||||||
static string TranslationsDirectory => Path.Combine(AppContext.BaseDirectory, "i18n");
|
static string TranslationsDirectory => Path.Combine(AppContext.BaseDirectory, "i18n");
|
||||||
static CultureInfo TranslationCultureInfo
|
static CultureInfo TranslationCultureInfo
|
||||||
{
|
{
|
||||||
get
|
get {
|
||||||
{
|
|
||||||
// cross-platform mapping of cultureinfos can be a bit screwy, so give our users
|
// cross-platform mapping of cultureinfos can be a bit screwy, so give our users
|
||||||
// the chance to explicitly spell out which translation they would like to use.
|
// the chance to explicitly spell out which translation they would like to use.
|
||||||
// this is an environment variable instead of a flag because this needs to be
|
// this is an environment variable instead of a flag because this needs to be
|
||||||
|
|
@ -39,6 +41,24 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
return new CultureInfo(overrideLang);
|
return new CultureInfo(overrideLang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static CultureInfo Redirect(CultureInfo cultureInfo)
|
||||||
|
=> cultureInfo.Name == "zh-Hans" ? new CultureInfo("zh-CN") : cultureInfo;
|
||||||
|
|
||||||
|
if (Terraria.Program.LaunchParameters.TryGetValue("-lang", out var langArg)
|
||||||
|
&& int.TryParse(langArg, out var langId)) {
|
||||||
|
if (GameCulture._legacyCultures.TryGetValue(langId, out var culture)) {
|
||||||
|
return Redirect(culture.CultureInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Terraria.Program.LaunchParameters.TryGetValue("-language", out var languageArg)) {
|
||||||
|
var culture = GameCulture._legacyCultures.Values.SingleOrDefault(c => c.Name == languageArg);
|
||||||
|
if (culture != null) {
|
||||||
|
return Redirect(culture.CultureInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return CultureInfo.CurrentUICulture;
|
return CultureInfo.CurrentUICulture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ Use past tense when adding new entries; sign your name off when you add or chang
|
||||||
* Dockerize TShock (@PotatoCider)
|
* Dockerize TShock (@PotatoCider)
|
||||||
|
|
||||||
* Add ability for items given to players to be inserted directly into their inventory instead of spawned as an item drop (@pontaoski)
|
* Add ability for items given to players to be inserted directly into their inventory instead of spawned as an item drop (@pontaoski)
|
||||||
|
* Added support of `-lang` and `-language` flags for our i18n system. (@KawaiiYuyu)
|
||||||
|
|
||||||
## TShock 4.5.18
|
## TShock 4.5.18
|
||||||
* Fixed `TSPlayer.GiveItem` not working if the player is in lava. (@PotatoCider)
|
* Fixed `TSPlayer.GiveItem` not working if the player is in lava. (@PotatoCider)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue