Files
sbox-public/engine/Sandbox.System/Localization/PhraseCollection.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

29 lines
687 B
C#

namespace Sandbox.Localization;
/// <summary>
/// Holds a bunch of localized phrases
/// </summary>
public class PhraseCollection
{
internal Dictionary<string, Phrase> Phrases { get; } = new Dictionary<string, Phrase>( StringComparer.OrdinalIgnoreCase );
/// <summary>
/// Add a phrase to the language
/// </summary>
public void Set( string key, string value )
{
Phrases[key] = new Phrase( value );
}
/// <summary>
/// Get a simple phrase from the language
/// </summary>
public string GetPhrase( string phrase, Dictionary<string, object> data = null )
{
if ( !Phrases.TryGetValue( phrase, out var result ) )
return phrase;
return result.Render( data );
}
}