Interface ITranslationService
- Namespace
- Vintagestory.API.Config
- Assembly
- VintagestoryAPI.dll
Represents a service, which provides access to translated strings, based on key/value pairs read from JSON files.
public interface ITranslationService
- Extension Methods
Properties
LanguageCode
Gets the language code that this translation service caters for.
string LanguageCode { get; }
Property Value
- string
A string, that contains the language code that this translation service caters for.
LineBreakBehavior
EnumLinebreakBehavior LineBreakBehavior { get; }
Property Value
Methods
Get(string, params object[])
Gets a translation for a given key.
string Get(string key, params object[] args)
Parameters
Returns
- string
Returns the key if no results are found; otherwise returns the pre-formatted, translated value.
GetAllEntries()
Retrieves a list of all translation entries within the cache.
IDictionary<string, string> GetAllEntries()
Returns
- IDictionary<string, string>
A dictionary of localisation entries.
GetIfExists(string, params object[])
Gets a translation for a given key, if any matching wildcarded keys are found within the cache.
string GetIfExists(string key, params object[] args)
Parameters
Returns
- string
Returns null if no results are found; otherwise returns the pre-formatted, translated value.
GetMatching(string, params object[])
Gets a translation for a given key, if any matching wildcarded keys are found within the cache.
string GetMatching(string key, params object[] args)
Parameters
Returns
- string
Returns the key if no results are found; otherwise returns the pre-formatted, translated value.
GetMatchingIfExists(string, params object[])
Gets a translation for a given key, if any matching wildcarded keys are found within the cache.
string GetMatchingIfExists(string key, params object[] args)
Parameters
Returns
- string
Returns
null
if no results are found; otherwise returns the pre-formatted, translated value.
GetUnformatted(string)
Gets the raw, unformatted translated value for the key provided.
string GetUnformatted(string key)
Parameters
key
stringThe key.
Returns
- string
Returns the key if no results are found; otherwise returns the unformatted, translated value.
HasTranslation(string, bool)
Determines whether the specified key has a translation.
bool HasTranslation(string key, bool findWildcarded = true)
Parameters
key
stringThe key.
findWildcarded
boolif set to
true
, the scan will include any wildcarded values.
Returns
- bool
true
if the specified key has a translation; otherwise,false
.
HasTranslation(string, bool, bool)
Determines whether the specified key has a translation.
bool HasTranslation(string key, bool findWildcarded, bool logErrors)
Parameters
key
stringThe key.
findWildcarded
boolif set to
true
, the scan will include any wildcarded values.logErrors
boolif set to
true
, will add "Lang key not found" logging
Returns
- bool
true
if the specified key has a translation; otherwise,false
.
InitialiseSearch()
Used to compile the regexes, to save time on the first 'actual' wildcard search - saves about 300ms
void InitialiseSearch()
Invalidate()
Sets the loaded flag to false, so that the next lookup causes it to reload all translation entries
void Invalidate()
Load(bool)
Loads translation key/value pairs from all relevant JSON files within the Asset Manager.
void Load(bool lazyload = false)
Parameters
lazyload
bool
PreLoad(string, bool)
Loads only the vanilla JSON files, without dealing with mods, or resource-packs.
void PreLoad(string assetsPath, bool lazyLoad = false)
Parameters
PreLoadModWorldConfig(string, string, bool)
Loads the mod worldconfig language JSON files only.
void PreLoadModWorldConfig(string modPath, string modDomain, bool lazyLoad = false)
Parameters
modPath
stringThe assets path to load the mod files from.
modDomain
stringThe mod domain to use when loading the files.
lazyLoad
bool
UseAssetManager(IAssetManager)
Specifies an asset manager to use, when the service has been lazy-loaded.
void UseAssetManager(IAssetManager assetManager)
Parameters
assetManager
IAssetManagerThe IAssetManager instance used within the sided API.