Class CustomLocalization
Wrapper to hold each mod localization data.
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: Jotunn.Entities
Assembly: Jotunn.dll
Syntax
public class CustomLocalization : CustomEntity
Constructors
| Improve this Doc View SourceCustomLocalization()
Default constuctor.
Declaration
public CustomLocalization()
CustomLocalization(BepInPlugin)
SourceMod hint constuctor.
Declaration
public CustomLocalization(BepInPlugin sourceMod)
Parameters
Type | Name | Description |
---|---|---|
BepInPlugin | sourceMod | Mod data in the shape of BepInPlugin class. |
Methods
| Improve this Doc View SourceAddFileByPath(String, Boolean)
Add a translation file via absolute path.
Declaration
public void AddFileByPath(string path, bool isJson = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | Absolute path to file. |
System.Boolean | isJson | Is the language file a json file. |
AddJsonFile(String, String)
Add a json language file (match crowdin format).
Declaration
public void AddJsonFile(string language, string fileContent)
Parameters
Type | Name | Description |
---|---|---|
System.String | language | Language for the json file, for example, "English" |
System.String | fileContent | Entire file as string |
AddLanguageFile(String)
Add a Unity style translation file.
Declaration
public void AddLanguageFile(string fileContent)
Parameters
Type | Name | Description |
---|---|---|
System.String | fileContent | Contents of the language file in string format. |
AddTranslation(String, Dictionary<String, String>)
Add a group of translations.
Declaration
public void AddTranslation(in string language, Dictionary<string, string> tokenValue)
Parameters
Type | Name | Description |
---|---|---|
System.String | language | Language of the translation you want to add. |
System.Collections.Generic.Dictionary<System.String, System.String> | tokenValue | Token-Value dictionary. |
AddTranslation(String, String)
Add a translation.
Declaration
public void AddTranslation(in string token, string translation)
Parameters
Type | Name | Description |
---|---|---|
System.String | token | Token of the translation you want to add. |
System.String | translation | The translation. |
AddTranslation(String, String, String)
Add a translation.
Declaration
public void AddTranslation(in string language, in string token, string translation)
Parameters
Type | Name | Description |
---|---|---|
System.String | language | Language of the translation you want to add. |
System.String | token | Token of the translation you want to add. |
System.String | translation | The translation. |
ClearAll()
Clear all localization data.
Declaration
public void ClearAll()
ClearLanguage(String)
Attempts to remove given language.
Declaration
public void ClearLanguage(in string language)
Parameters
Type | Name | Description |
---|---|---|
System.String | language | Language to clear. |
ClearToken(String)
Attempts to remove a given token from default language.
Declaration
public void ClearToken(in string token)
Parameters
Type | Name | Description |
---|---|---|
System.String | token | Token to clear. |
ClearToken(String, String)
Attempts to remove a given token from certain language.
Declaration
public void ClearToken(in string language, in string token)
Parameters
Type | Name | Description |
---|---|---|
System.String | language | Language from which to search the token. |
System.String | token | Token to clear. |
Contains(String, String)
Checks if a translation exists for given language and token.
Declaration
public bool Contains(in string language, in string token)
Parameters
Type | Name | Description |
---|---|---|
System.String | language | Language being checked. |
System.String | token | Token being checked. |
Returns
Type | Description |
---|---|
System.Boolean | True if the token was found. |
GetLanguages()
Retrieve list of languages that have been added.
Declaration
public IEnumerable<string> GetLanguages()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> |
GetTranslations(String)
Retrieve translations for given language.
Declaration
public IReadOnlyDictionary<string, string> GetTranslations(in string language)
Parameters
Type | Name | Description |
---|---|---|
System.String | language | Language of the translation you want to retrieve. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyDictionary<System.String, System.String> |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |
Overrides
System.Object.ToString()
|
Improve this Doc
View Source
TryTranslate(String)
Retrieve a translation from this custom localization or .
Searches with the user language with a fallback to English.
Declaration
public string TryTranslate(string word)
Parameters
Type | Name | Description |
---|---|---|
System.String | word | Word to translate. |
Returns
Type | Description |
---|---|
System.String | Translated word in player language or english as a fallback. |