forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
79 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
using Robust.Shared.Prototypes; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace Content.Server.SS220.Language; | ||
|
||
public sealed class LanguageManager | ||
{ | ||
[Dependency] private readonly ILogManager _logManager = default!; | ||
[Dependency] private readonly IPrototypeManager _prototype = default!; | ||
|
||
public List<LanguagePrototype> Languages { get; private set; } = new(); | ||
|
||
private ISawmill _sawmill = default!; | ||
|
||
public void Initialize() | ||
{ | ||
Languages = new List<LanguagePrototype>(); | ||
foreach (var language in _prototype.EnumeratePrototypes<LanguagePrototype>()) | ||
{ | ||
Languages.Add(language); | ||
} | ||
|
||
_sawmill = _logManager.GetSawmill("language.manager"); | ||
} | ||
|
||
public bool TryGetLanguageById(string id, [NotNullWhen(true)] out LanguagePrototype? language) | ||
{ | ||
language = Languages.Find(l => l.ID == id); | ||
|
||
if (language == null) | ||
_sawmill.Error($"Doesn't found a language with id: {id}"); | ||
|
||
return language != null; | ||
} | ||
|
||
public bool TryGetLanguageByKey(string key, [NotNullWhen(true)] out LanguagePrototype? language) | ||
{ | ||
language = Languages.Find(l => l.Key == key); | ||
|
||
if (language == null) | ||
_sawmill.Error($"Doesn't found a language with key: {key}"); | ||
|
||
return language != null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters