Project overhaul

This commit is contained in:
Tony Bark 2022-07-21 10:23:31 -04:00
parent 3de1fc5eca
commit 84c27a1b14
11 changed files with 78 additions and 169 deletions

View file

@ -6,23 +6,46 @@ namespace CSTNet;
public class UIText
{
string Language { get; set; } = "english";
public string[] BasePath { get; set; } = { AppContext.BaseDirectory, "uitext" };
public UIText() { }
/// <summary>
/// Loads the language file.
/// </summary>
/// <param name="language">Language to load</param>
public UIText(string language)
{
Language = language;
}
/// <summary>
/// Loads the language file.
/// </summary>
/// <param name="language">Language to load</param>
/// <param name="basePath">Base directory for the language files.</param>
public UIText(string language, params string[] baseBath)
{
Language = language;
BasePath = baseBath;
}
/// <summary>
/// Get the text for the given id and key.
/// </summary>
/// <param name="id">The id of the text.</param>
/// <param name="key">The key of the text.</param>
/// <returns>The text for the given id and key.</returns>
public string GetText(int id, int key) => GetText(id, key.ToString());
/// <summary>
/// Get the text for the given id and key.
/// </summary>
/// <param name="id">The id of the text.</param>
/// <param name="key">The key of the text.</param>
/// <returns>The text for the given id and key.</returns>
public string GetText(int id, string key)
{
var basePath = Path.Combine(BasePath);
@ -46,9 +69,10 @@ public class UIText
continue;
var content = File.ReadAllText(file);
return CaretSeparatedText.Parse(content, key);
return CST.Parse(content, key);
}
return "***MISSING***";
}
}