Traveller/scripts/utils/TranslationServerUtils.cs
Cold-Mint 5ec6b3065b
Distinguish log levels to solve the problem of overlapping room splicing borders.
区分日志等级,解决房间拼接边框重叠的问题。
2024-05-24 22:58:52 +08:00

30 lines
913 B
C#

using Godot;
namespace ColdMint.scripts.utils;
public static class TranslationServerUtils
{
/// <summary>
/// <para>Gets a translation of a field and displays it formatted</para>
/// <para>获取某个字段的翻译,并且将其格式化显示</para>
/// </summary>
/// <param name="key"></param>
/// <param name="args"></param>
/// <returns></returns>
public static string? TranslateWithFormat(string key, params object[] args)
{
var value = TranslationServer.Translate(key);
return value == null ? null : string.Format(value, args);
}
/// <summary>
/// <para>Gets a translation of a field</para>
/// <para>获取某个字段的翻译</para>
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static string? Translate(string? key)
{
return TranslationServer.Translate(key);
}
}