mirror of
https://github.com/tonytins/cstdotnet.git
synced 2025-07-08 07:20:26 -04:00
Project overhaul
This commit is contained in:
parent
3de1fc5eca
commit
84c27a1b14
11 changed files with 78 additions and 169 deletions
|
@ -3,7 +3,10 @@
|
|||
|
||||
namespace CSTNet;
|
||||
|
||||
public class CaretSeparatedText
|
||||
[Obsolete("Use CST class instead.")]
|
||||
public class CaretSeparatedText : CST { }
|
||||
|
||||
public class CST
|
||||
{
|
||||
const char CARET = '^';
|
||||
const string LF = "\u000A";
|
||||
|
@ -78,3 +81,5 @@ public class CaretSeparatedText
|
|||
return "***MISSING***";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,19 +1,19 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Version>1.2.100</Version>
|
||||
<TargetFrameworks>netstandard2.1;net6.0</TargetFrameworks>
|
||||
<Version>1.0.400-beta1</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Authors>Tony Bark, Sixam Software</Authors>
|
||||
<Authors>Tony Bark</Authors>
|
||||
<PackageDescription>
|
||||
Caret-Separated Text (or CST) is a key-value pair format represented by digits or words as keys and the value as text enclosed between carets. ([key] ^[value]^)
|
||||
|
||||
Sixam.CST provides you the framework for parsing the CST format.
|
||||
CSTNet provides you the framework for parsing the CST format.
|
||||
</PackageDescription>
|
||||
<RepositoryUrl>https://github.com/sixamsoft/cst-dotnet</RepositoryUrl>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
<RootNamespace>Sixam.CST</RootNamespace>
|
||||
<RepositoryUrl>https://github.com/tonytins/cstdotnet</RepositoryUrl>
|
||||
<PackageLicenseExpression>BSD 3-Clause</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -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***";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue