mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-02-10 03:40:01 +00:00
use EnumerateFiles instead of GetFiles, and just use strings instead of DirectoryInfo/FileInfo
This commit is contained in:
parent
182b4385e3
commit
7af2d6b7d2
@ -9,7 +9,7 @@ namespace QSB.Localization;
|
|||||||
|
|
||||||
public static class QSBLocalization
|
public static class QSBLocalization
|
||||||
{
|
{
|
||||||
private readonly static List<Translation> _translations = new();
|
private static readonly List<Translation> _translations = new();
|
||||||
public static Translation Current;
|
public static Translation Current;
|
||||||
|
|
||||||
public static Action LanguageChanged;
|
public static Action LanguageChanged;
|
||||||
@ -17,18 +17,16 @@ public static class QSBLocalization
|
|||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
// get all translation files
|
// get all translation files
|
||||||
var directory = new DirectoryInfo(Path.Combine(QSBCore.Helper.Manifest.ModFolderPath, "Translations\\"));
|
foreach (var path in Directory.EnumerateFiles(Path.Combine(QSBCore.Helper.Manifest.ModFolderPath, "Translations"), "*.json"))
|
||||||
var files = directory.GetFiles("*.json");
|
|
||||||
foreach (var file in files)
|
|
||||||
{
|
{
|
||||||
var translation = QSBCore.Helper.Storage.Load<Translation>($"Translations\\{file.Name}", false);
|
var translation = QSBCore.Helper.Storage.Load<Translation>(path, false);
|
||||||
_translations.Add(translation);
|
_translations.Add(translation);
|
||||||
DebugLog.DebugWrite($"- Added translation for language {translation.Language}");
|
DebugLog.DebugWrite($"- Added translation for language {translation.Language}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_translations.Count == 0)
|
if (_translations.Count == 0)
|
||||||
{
|
{
|
||||||
DebugLog.ToConsole($"FATAL - No translation files found!", OWML.Common.MessageType.Fatal);
|
DebugLog.ToConsole("FATAL - No translation files found!", OWML.Common.MessageType.Fatal);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user