mirror of
https://github.com/tonytins/cstdotnet.git
synced 2026-02-10 12:14:47 -05:00
This release drops .NET Standard in favor of .NET 6.
There are a lot of significant under the hood changes with the release. See the change log for details.
This commit is contained in:
parent
ceebb00314
commit
229ab4f0ad
12 changed files with 179 additions and 186 deletions
|
|
@ -1,57 +1,54 @@
|
|||
// This project is licensed under the MIT license.
|
||||
// See the LICENSE file in the project root for more information.
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Sixam.CST
|
||||
namespace Sixam.CST;
|
||||
|
||||
public class UIText
|
||||
{
|
||||
public class UIText
|
||||
string Language { get; set; } = "english";
|
||||
public string[] BasePath { get; set; } = { AppContext.BaseDirectory, "uitext" };
|
||||
|
||||
public UIText() { }
|
||||
|
||||
public UIText(string language)
|
||||
{
|
||||
string Language { get; set; } = "english";
|
||||
public string[] BasePath { get; set; } = { AppContext.BaseDirectory, "uitext" };
|
||||
Language = language;
|
||||
}
|
||||
|
||||
public UIText() { }
|
||||
public UIText(string language, params string[] baseBath)
|
||||
{
|
||||
Language = language;
|
||||
BasePath = baseBath;
|
||||
}
|
||||
|
||||
public UIText(string language)
|
||||
public string GetText(int id, int key) => GetText(id, key.ToString());
|
||||
|
||||
public string GetText(int id, string key)
|
||||
{
|
||||
var basePath = Path.Combine(BasePath);
|
||||
var langPath = Path.Combine(basePath, $"{Language}.dir");
|
||||
var files = Directory.GetFiles(langPath);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
Language = language;
|
||||
if (!file.Contains(".cst"))
|
||||
continue;
|
||||
|
||||
var ids = Path.GetFileName(file);
|
||||
var second = ids.IndexOf("_", 1, StringComparison.InvariantCultureIgnoreCase);
|
||||
|
||||
if (second == -1)
|
||||
continue;
|
||||
|
||||
ids = ids.Substring(1, second - 1);
|
||||
|
||||
if (ids != id.ToString())
|
||||
continue;
|
||||
|
||||
var content = File.ReadAllText(file);
|
||||
return CaretSeparatedText.Parse(content, key);
|
||||
}
|
||||
|
||||
public UIText(string language, params string[] baseBath)
|
||||
{
|
||||
Language = language;
|
||||
BasePath = baseBath;
|
||||
}
|
||||
|
||||
public string GetText(int id, int key) => GetText(id, key.ToString());
|
||||
|
||||
public string GetText(int id, string key)
|
||||
{
|
||||
var basePath = Path.Combine(BasePath);
|
||||
var langPath = Path.Combine(basePath, $"{Language}.dir");
|
||||
var files = Directory.GetFiles(langPath);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (!file.Contains(".cst"))
|
||||
continue;
|
||||
|
||||
var ids = Path.GetFileName(file);
|
||||
var second = ids.IndexOf("_", 1, StringComparison.InvariantCultureIgnoreCase);
|
||||
|
||||
if (second == -1)
|
||||
continue;
|
||||
|
||||
ids = ids.Substring(1, second - 1);
|
||||
|
||||
if (ids != id.ToString())
|
||||
continue;
|
||||
|
||||
var content = File.ReadAllText(file);
|
||||
return CaretSeparatedText.Parse(content, key);
|
||||
}
|
||||
|
||||
return "***MISSING***";
|
||||
}
|
||||
return "***MISSING***";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue