mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-04 04:18:27 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
29 lines
687 B
C#
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 );
|
|
}
|
|
}
|