Decompiled source of Aerolt Chinese Localization v1.0.0

AeroltZhCN.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using Aerolt.API;
using AeroltZhCN.Patches;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RoR2;
using UnityEngine;
using UnityEngine.UI;
using UniverseLib.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("AeroltZhCN")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AeroltZhCN")]
[assembly: AssemblyTitle("AeroltZhCN")]
[assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was created with the assistance of Generative AI (DeepSeek Harness / deepseek-flash).")]
[assembly: AssemblyMetadata("AI_Model_Vendor", "DeepSeek")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AeroltZhCN
{
	internal static class FontSupport
	{
		private static Font _cjkFont;

		private static bool _tried;

		private static bool _loggedError;

		public static void Ensure(Text text, string value)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.UseOsFontFallback.Value || (Object)(object)text == (Object)null || string.IsNullOrEmpty(value) || !HasCjk(value))
			{
				return;
			}
			try
			{
				Font font = text.font;
				if (!((Object)(object)font != (Object)null) || !font.HasCharacter('中'))
				{
					Font cjkFont = GetCjkFont();
					if (!((Object)(object)cjkFont == (Object)null) && !((Object)(object)cjkFont == (Object)(object)font))
					{
						text.font = cjkFont;
						cjkFont.RequestCharactersInTexture(value, text.fontSize, text.fontStyle);
					}
				}
			}
			catch (Exception ex)
			{
				if (!_loggedError)
				{
					_loggedError = true;
					ManualLogSource log = Plugin.Log;
					if (log != null)
					{
						log.LogWarning((object)("[AeroltZhCN] font fallback failed: " + ex.Message));
					}
				}
			}
		}

		private static Font GetCjkFont()
		{
			if (_tried)
			{
				return _cjkFont;
			}
			_tried = true;
			string[] array = new string[9] { "Microsoft YaHei", "微软雅黑", "SimHei", "黑体", "SimSun", "宋体", "Noto Sans CJK SC", "Source Han Sans SC", "Arial Unicode MS" };
			try
			{
				_cjkFont = Font.CreateDynamicFontFromOSFont(array, 16);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[AeroltZhCN] CreateDynamicFontFromOSFont failed: " + ex.Message));
				}
			}
			if ((Object)(object)_cjkFont == (Object)null)
			{
				string[] array2 = array;
				foreach (string text in array2)
				{
					try
					{
						_cjkFont = Font.CreateDynamicFontFromOSFont(text, 16);
						if ((Object)(object)_cjkFont != (Object)null)
						{
							break;
						}
					}
					catch
					{
					}
				}
			}
			if ((Object)(object)_cjkFont == (Object)null)
			{
				ManualLogSource log2 = Plugin.Log;
				if (log2 != null)
				{
					log2.LogWarning((object)"[AeroltZhCN] no CJK OS font found; Chinese may render as boxes.");
				}
			}
			return _cjkFont;
		}

		private static bool HasCjk(string value)
		{
			foreach (char c in value)
			{
				if (c >= '一' && c <= '鿿')
				{
					return true;
				}
			}
			return false;
		}
	}
	[BepInPlugin("com.local.aerolt.zhcn", "Aerolt 中文本地化", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "com.local.aerolt.zhcn";

		internal static Plugin Instance;

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> UseOsFontFallback;

		internal static ConfigEntry<bool> LogUntranslated;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "启用 Aerolt 界面汉化。关闭后完全恢复英文显示。");
			UseOsFontFallback = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseOsFontFallback", true, "当 UI 字体不含中文字形时,自动改用系统中文字体(微软雅黑/黑体等),避免显示方框。");
			LogUntranslated = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "LogUntranslated", false, "把 Aerolt 界面中未翻译的英文文本写入 BepInEx 日志,便于补充词条。");
			Translation.Load(Paths.ConfigPath);
			_harmony = new Harmony("com.local.aerolt.zhcn");
			AeroltZhCN.Patches.Patches.Apply(_harmony);
			Log.LogInfo((object)("[AeroltZhCN] loaded: " + Translation.Count + " entries, " + Translation.RuleCount + " rules."));
		}

		private void OnDestroy()
		{
			try
			{
				Harmony harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
			}
			catch
			{
			}
		}
	}
	internal static class Translation
	{
		private struct RegexRule
		{
			public Regex Regex;

			public string Replacement;
		}

		private static readonly Dictionary<string, string> Map = new Dictionary<string, string>(StringComparer.Ordinal);

		private static readonly List<RegexRule> Rules = new List<RegexRule>();

		private static readonly List<Func<string, string>> Handlers = new List<Func<string, string>>();

		private static readonly HashSet<string> Missing = new HashSet<string>(StringComparer.Ordinal);

		private const string ResourceName = "AeroltZhCN.translations.tsv";

		private static string _embeddedText = string.Empty;

		private static readonly Regex NumberedSection = new Regex("^(\\d{2,3}) - (.+)$", RegexOptions.Compiled);

		private static readonly Regex EditItemsCount = new Regex("^Edit Items \\((\\d+)\\)$", RegexOptions.Compiled);

		private static readonly Regex ProfileNumber = new Regex("^Profile (\\d+)$", RegexOptions.Compiled);

		private static readonly Regex LoadoutNumber = new Regex("^Loadout (\\d+)$", RegexOptions.Compiled);

		private static readonly Regex DifficultyValue = new Regex("^Difficulty (.+)$", RegexOptions.Compiled);

		private static readonly Regex LoadoutItemCount = new Regex("^(.+?)  \\((\\d+) items\\)$", RegexOptions.Compiled);

		private static readonly Regex InteractablesUnavailable = new Regex("^Interactables unavailable \\(not in a stage\\?\\): (.*)$", RegexOptions.Compiled);

		private static readonly Regex KillChat = new Regex("^<color=yellow>Killed (.*)</color>$", RegexOptions.Compiled);

		private static readonly Regex SavedLoadout = new Regex("^<color=cyan>Saved loadout '(.*)' \\((\\d+) items\\)\\.</color>$", RegexOptions.Compiled);

		private static readonly Regex LoadedLoadout = new Regex("^<color=cyan>Loaded loadout '(.*)'\\.</color>$", RegexOptions.Compiled);

		private static readonly Regex HostOnlyChat = new Regex("^<color=yellow>\\[Aerolt\\]</color> Host-only mode: (.*)$", RegexOptions.Compiled);

		private static readonly Regex EquippedValue = new Regex("^Equipped: (.+)$", RegexOptions.Compiled);

		private static readonly Regex EspHp = new Regex("(\\d+)/(\\d+) HP", RegexOptions.Compiled);

		private static readonly Regex EspSecondsSuffix = new Regex("(\\d+(?:\\.\\d+)?)s$", RegexOptions.Compiled);

		public static int Count { get; private set; }

		public static int RuleCount { get; private set; }

		public static void Load(string configDir)
		{
			Map.Clear();
			Rules.Clear();
			Handlers.Clear();
			Missing.Clear();
			_embeddedText = ReadEmbedded();
			ParseInto(_embeddedText);
			try
			{
				string text = Path.Combine(configDir, "AeroltZhCN");
				string path = Path.Combine(text, "translations.tsv");
				Directory.CreateDirectory(text);
				if (File.Exists(path))
				{
					ParseInto(File.ReadAllText(path, Encoding.UTF8));
				}
				else
				{
					File.WriteAllText(path, "# AeroltZhCN 用户覆盖表\n# 内置词条已编译进插件;这里只需写想覆盖或补充的条目。\n# 格式:原文<TAB>译文;键以 re: 开头表示正则;\\n 表示换行。\n# 示例(去掉行首 # 即可生效):\n# God Mode\t上帝模式\n", new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[AeroltZhCN] Could not load/save external translations: " + ex.Message));
				}
			}
			BuildHandlers();
			Count = Map.Count;
			RuleCount = Rules.Count + Handlers.Count;
		}

		internal static void LoadForTest(string text)
		{
			Map.Clear();
			Rules.Clear();
			Handlers.Clear();
			Missing.Clear();
			_embeddedText = text ?? string.Empty;
			ParseInto(_embeddedText);
			BuildHandlers();
			Count = Map.Count;
			RuleCount = Rules.Count + Handlers.Count;
		}

		private static string ReadEmbedded()
		{
			try
			{
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("AeroltZhCN.translations.tsv");
				if (stream == null)
				{
					ManualLogSource log = Plugin.Log;
					if (log != null)
					{
						log.LogWarning((object)"[AeroltZhCN] Embedded translations.tsv not found.");
					}
					return string.Empty;
				}
				using StreamReader streamReader = new StreamReader(stream, Encoding.UTF8);
				return streamReader.ReadToEnd();
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				if (log2 != null)
				{
					log2.LogWarning((object)("[AeroltZhCN] Could not read embedded translations: " + ex.Message));
				}
				return string.Empty;
			}
		}

		private static void ParseInto(string text)
		{
			if (string.IsNullOrEmpty(text))
			{
				return;
			}
			string[] array = text.Split(new string[3] { "\r\n", "\n", "\r" }, StringSplitOptions.None);
			foreach (string text2 in array)
			{
				if (text2.Length == 0 || text2[0] == '#')
				{
					continue;
				}
				int num = text2.IndexOf('\t');
				if (num <= 0)
				{
					continue;
				}
				string text3 = Unescape(text2.Substring(0, num));
				string text4 = Unescape(text2.Substring(num + 1));
				if (text3.Length == 0)
				{
					continue;
				}
				if (text3.StartsWith("re:", StringComparison.Ordinal))
				{
					string text5 = text3.Substring(3);
					if (text5.Length == 0)
					{
						continue;
					}
					try
					{
						Rules.Add(new RegexRule
						{
							Regex = new Regex(text5, RegexOptions.Compiled),
							Replacement = text4
						});
					}
					catch (Exception ex)
					{
						ManualLogSource log = Plugin.Log;
						if (log != null)
						{
							log.LogWarning((object)("[AeroltZhCN] Bad regex '" + text5 + "': " + ex.Message));
						}
					}
				}
				else
				{
					Map[text3] = text4;
				}
			}
		}

		private static void BuildHandlers()
		{
			Handlers.Add(delegate(string s)
			{
				Match match = NumberedSection.Match(s);
				return (!match.Success) ? null : (match.Groups[1].Value + " - " + Translate(match.Groups[2].Value));
			});
			Handlers.Add(delegate(string s)
			{
				Match match = EditItemsCount.Match(s);
				return (!match.Success) ? null : ("编辑物品(" + match.Groups[1].Value + ")");
			});
			Handlers.Add(delegate(string s)
			{
				Match match = ProfileNumber.Match(s);
				return (!match.Success) ? null : ("配置 " + match.Groups[1].Value);
			});
			Handlers.Add(delegate(string s)
			{
				Match match = LoadoutNumber.Match(s);
				return (!match.Success) ? null : ("配装 " + match.Groups[1].Value);
			});
			Handlers.Add(delegate(string s)
			{
				Match match = DifficultyValue.Match(s);
				return (!match.Success) ? null : ("难度 " + Translate(match.Groups[1].Value));
			});
			Handlers.Add(delegate(string s)
			{
				Match match = LoadoutItemCount.Match(s);
				return (!match.Success) ? null : (Translate(match.Groups[1].Value) + "(" + match.Groups[2].Value + " 件物品)");
			});
			Handlers.Add(delegate(string s)
			{
				Match match = InteractablesUnavailable.Match(s);
				return (!match.Success) ? null : ("可交互物不可用(不在关卡中?):" + match.Groups[1].Value);
			});
			Handlers.Add(delegate(string s)
			{
				Match match = KillChat.Match(s);
				return (!match.Success) ? null : ("<color=yellow>已击杀 " + match.Groups[1].Value + "</color>");
			});
			Handlers.Add(delegate(string s)
			{
				Match match = SavedLoadout.Match(s);
				return (!match.Success) ? null : ("<color=cyan>已保存配装“" + match.Groups[1].Value + "”(" + match.Groups[2].Value + " 件物品)。</color>");
			});
			Handlers.Add(delegate(string s)
			{
				Match match = LoadedLoadout.Match(s);
				return (!match.Success) ? null : ("<color=cyan>已载入配装“" + match.Groups[1].Value + "”。</color>");
			});
			Handlers.Add(delegate(string s)
			{
				Match match = HostOnlyChat.Match(s);
				return (!match.Success) ? null : ("<color=yellow>[Aerolt]</color> 仅主机模式:" + Translate(match.Groups[1].Value));
			});
			Handlers.Add(delegate(string s)
			{
				Match match = EquippedValue.Match(s);
				return (!match.Success) ? null : ("已装备:" + match.Groups[1].Value);
			});
		}

		public static string Translate(string value)
		{
			if (string.IsNullOrEmpty(value))
			{
				return value;
			}
			if (!HasAsciiLetter(value))
			{
				return value;
			}
			if (Map.TryGetValue(value, out var value2))
			{
				return value2;
			}
			for (int i = 0; i < Handlers.Count; i++)
			{
				string text;
				try
				{
					text = Handlers[i](value);
				}
				catch
				{
					text = null;
				}
				if (text != null)
				{
					return text;
				}
			}
			for (int j = 0; j < Rules.Count; j++)
			{
				RegexRule regexRule = Rules[j];
				if (regexRule.Regex.IsMatch(value))
				{
					return regexRule.Regex.Replace(value, regexRule.Replacement);
				}
			}
			return value;
		}

		public static string TranslateEsp(string value)
		{
			if (string.IsNullOrEmpty(value))
			{
				return value;
			}
			if (!HasAsciiLetter(value))
			{
				return value;
			}
			string[] array = value.Split('\n');
			bool flag = false;
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i];
				string text2 = text;
				string text3 = text2.Trim();
				if (text3.Length == 0)
				{
					continue;
				}
				if (Map.TryGetValue(text3, out var value2))
				{
					text2 = text2.Replace(text3, value2);
				}
				else
				{
					int num = text3.IndexOf(" : ", StringComparison.Ordinal);
					if (num > 0)
					{
						string text4 = text3.Substring(0, num);
						if (Map.TryGetValue(text4, out var value3))
						{
							text2 = text2.Replace(text4, value3);
						}
						else
						{
							string text5 = Translate(text4);
							if (!string.Equals(text5, text4, StringComparison.Ordinal))
							{
								text2 = text2.Replace(text4, text5);
							}
						}
					}
					else
					{
						string text6 = Translate(text3);
						if (!string.Equals(text6, text3, StringComparison.Ordinal))
						{
							text2 = text2.Replace(text3, text6);
						}
					}
				}
				if (EspHp.IsMatch(text2))
				{
					text2 = EspHp.Replace(text2, "$1/$2 生命");
				}
				text2 = EspSecondsSuffix.Replace(text2, "$1秒");
				if (!string.Equals(text2, text, StringComparison.Ordinal))
				{
					array[i] = text2;
					flag = true;
				}
			}
			if (!flag)
			{
				return value;
			}
			return string.Join("\n", array);
		}

		public static void LogUnmatched(string value)
		{
			if (!string.IsNullOrEmpty(value) && value.Length >= 2 && value.Length <= 300 && HasAsciiLetter(value) && !ContainsCjk(value) && Missing.Count < 500 && Missing.Add(value))
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[AeroltZhCN] untranslated: " + value.Replace("\n", "\\n")));
				}
			}
		}

		private static bool HasAsciiLetter(string value)
		{
			foreach (char c in value)
			{
				if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'))
				{
					return true;
				}
			}
			return false;
		}

		private static bool ContainsCjk(string value)
		{
			foreach (char c in value)
			{
				if (c >= '一' && c <= '鿿')
				{
					return true;
				}
			}
			return false;
		}

		private static string Unescape(string value)
		{
			if (value.IndexOf('\\') < 0)
			{
				return value;
			}
			StringBuilder stringBuilder = new StringBuilder(value.Length);
			for (int i = 0; i < value.Length; i++)
			{
				char c = value[i];
				if (c != '\\' || i + 1 >= value.Length)
				{
					stringBuilder.Append(c);
					continue;
				}
				char c2 = value[++i];
				switch (c2)
				{
				case 'n':
					stringBuilder.Append('\n');
					break;
				case 't':
					stringBuilder.Append('\t');
					break;
				case 'r':
					stringBuilder.Append('\r');
					break;
				case '\\':
					stringBuilder.Append('\\');
					break;
				default:
					stringBuilder.Append('\\').Append(c2);
					break;
				}
			}
			return stringBuilder.ToString();
		}
	}
}
namespace AeroltZhCN.Patches
{
	internal static class Patches
	{
		private static bool _textErrorLogged;

		private static bool _espErrorLogged;

		public static void Apply(Harmony harmony)
		{
			PatchMethod(harmony, typeof(Text), "set_text", new Type[1] { typeof(string) }, "TextPrefix", "UnityEngine.UI.Text.set_text");
			Type type = AccessTools.TypeByName("Aerolt.Managers.EspHelper");
			if (type == null)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)"[AeroltZhCN] Aerolt.Managers.EspHelper not found; ESP labels stay English.");
				}
			}
			else
			{
				PatchMethod(harmony, type, "DrawEspLabel", new Type[5]
				{
					typeof(Vector3),
					typeof(Color),
					typeof(Color),
					typeof(string),
					typeof(string)
				}, "EspTextPrefix", "Aerolt.Managers.EspHelper.DrawEspLabel");
				PatchMethod(harmony, type, "DrawRarityEspLabel", new Type[7]
				{
					typeof(Vector3),
					typeof(Color),
					typeof(Color),
					typeof(string),
					typeof(Color),
					typeof(string),
					typeof(string)
				}, "EspRarityPrefix", "Aerolt.Managers.EspHelper.DrawRarityEspLabel");
				PatchMethod(harmony, type, "DrawMultiShopRarityESPLabel", new Type[7]
				{
					typeof(Vector3),
					typeof(Color),
					typeof(Color),
					typeof(string),
					typeof(List<Color>),
					typeof(List<string>),
					typeof(string)
				}, "EspMultiShopPrefix", "Aerolt.Managers.EspHelper.DrawMultiShopRarityESPLabel");
			}
			PatchMethod(harmony, typeof(Chat), "AddMessage", new Type[1] { typeof(string) }, "ChatPrefix", "RoR2.Chat.AddMessage");
		}

		private static void PatchMethod(Harmony harmony, Type type, string methodName, Type[] args, string prefixName, string displayName)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = AccessTools.Method(type, methodName, args, (Type[])null);
				if (methodInfo == null)
				{
					ManualLogSource log = Plugin.Log;
					if (log != null)
					{
						log.LogWarning((object)("[AeroltZhCN] target not found: " + displayName));
					}
					return;
				}
				MethodInfo methodInfo2 = AccessTools.Method(typeof(Patches), prefixName, (Type[])null, (Type[])null);
				if (methodInfo2 == null)
				{
					ManualLogSource log2 = Plugin.Log;
					if (log2 != null)
					{
						log2.LogWarning((object)("[AeroltZhCN] prefix not found: " + prefixName));
					}
					return;
				}
				harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				ManualLogSource log3 = Plugin.Log;
				if (log3 != null)
				{
					log3.LogInfo((object)("[AeroltZhCN] patched " + displayName));
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log4 = Plugin.Log;
				if (log4 != null)
				{
					log4.LogWarning((object)("[AeroltZhCN] failed to patch " + displayName + ": " + ex));
				}
			}
		}

		private static void TextPrefix(Text __instance, ref string value)
		{
			try
			{
				if (!Plugin.Enabled.Value || string.IsNullOrEmpty(value) || !IsAeroltUi(__instance))
				{
					return;
				}
				InputField componentInParent = ((Component)__instance).GetComponentInParent<InputField>();
				if ((Object)(object)componentInParent != (Object)null && componentInParent.textComponent == __instance)
				{
					FontSupport.Ensure(__instance, value);
					return;
				}
				string text = Translation.Translate(value);
				if (!string.Equals(text, value, StringComparison.Ordinal))
				{
					value = text;
				}
				else if (Plugin.LogUntranslated.Value)
				{
					Translation.LogUnmatched(value);
				}
				FontSupport.Ensure(__instance, value);
			}
			catch (Exception ex)
			{
				if (!_textErrorLogged)
				{
					_textErrorLogged = true;
					ManualLogSource log = Plugin.Log;
					if (log != null)
					{
						log.LogWarning((object)("[AeroltZhCN] Text prefix failed: " + ex));
					}
				}
			}
		}

		private static bool IsAeroltUi(Text text)
		{
			try
			{
				UIBase sharedUIBase = AeroltAPI.SharedUIBase;
				if (sharedUIBase != null)
				{
					GameObject rootObject = sharedUIBase.RootObject;
					if ((Object)(object)rootObject != (Object)null)
					{
						return ((Component)text).transform.IsChildOf(rootObject.transform);
					}
				}
			}
			catch
			{
			}
			try
			{
				Canvas componentInParent = ((Component)text).GetComponentInParent<Canvas>();
				return (Object)(object)componentInParent != (Object)null && ((Object)((Component)componentInParent).gameObject).name.IndexOf("Aerolt", StringComparison.OrdinalIgnoreCase) >= 0;
			}
			catch
			{
				return false;
			}
		}

		private static void EspTextPrefix(ref string text, ref string outlinetext)
		{
			ApplyEsp(ref text, ref outlinetext);
		}

		private static void EspRarityPrefix(ref string text, ref string outlinetext)
		{
			ApplyEsp(ref text, ref outlinetext);
		}

		private static void EspMultiShopPrefix(ref string text, ref string outlinetext)
		{
			ApplyEsp(ref text, ref outlinetext);
		}

		private static void ApplyEsp(ref string text, ref string outlinetext)
		{
			try
			{
				if (Plugin.Enabled.Value)
				{
					text = Translation.TranslateEsp(text);
					outlinetext = Translation.TranslateEsp(outlinetext);
				}
			}
			catch (Exception ex)
			{
				if (!_espErrorLogged)
				{
					_espErrorLogged = true;
					ManualLogSource log = Plugin.Log;
					if (log != null)
					{
						log.LogWarning((object)("[AeroltZhCN] ESP prefix failed: " + ex));
					}
				}
			}
		}

		private static void ChatPrefix(ref string message)
		{
			try
			{
				if (Plugin.Enabled.Value && !string.IsNullOrEmpty(message))
				{
					message = Translation.Translate(message);
				}
			}
			catch
			{
			}
		}
	}
}