Interface ILocalizationService
Defines the contract for a localization service that provides translated strings and manages fonts for different languages.
Namespace: PopcorningGuineaPig.Engine.services
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public interface ILocalizationService
Properties
| Edit this page View SourceAvailableLanguages
Gets the list of available language codes.
Declaration
IEnumerable<string> AvailableLanguages { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<string> |
CurrentFontPath
Gets the font path for the current language.
Declaration
string CurrentFontPath { get; }
Property Value
| Type | Description |
|---|---|
| string |
CurrentLanguage
Gets the currently selected language code (e.g., "en", "zh").
Declaration
string CurrentLanguage { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
| Edit this page View SourceGetFontPathForLanguage(string)
Gets the font path for a specific language.
Declaration
string? GetFontPathForLanguage(string languageCode)
Parameters
| Type | Name | Description |
|---|---|---|
| string | languageCode | The language code. |
Returns
| Type | Description |
|---|---|
| string | The font path for the language, or null if not configured. |
GetString(string)
Gets the translated string for the specified key in the current language.
Declaration
string GetString(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | key | The localization key. |
Returns
| Type | Description |
|---|---|
| string | The translated string, or the key if no translation is found. |
LoadLocalization(string)
Loads localization data from a CSV file.
Declaration
void LoadLocalization(string filePath)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath | The path to the CSV file. |
SetFontPaths(Dictionary<string, string>)
Sets the font paths for different languages.
Declaration
void SetFontPaths(Dictionary<string, string> languageToFontMap)
Parameters
| Type | Name | Description |
|---|---|---|
| Dictionary<string, string> | languageToFontMap | Dictionary mapping language codes to font file paths. |
SetLanguage(string)
Sets the current language.
Declaration
void SetLanguage(string languageCode)
Parameters
| Type | Name | Description |
|---|---|---|
| string | languageCode | The ISO 639-1 language code. |
Events
| Edit this page View SourceFontChanged
Event raised when the current font changes (usually when language changes).
Declaration
event Action FontChanged
Event Type
| Type | Description |
|---|---|
| Action |
LanguageChanged
Event raised when the current language changes.
Declaration
event Action LanguageChanged
Event Type
| Type | Description |
|---|---|
| Action |