EasyTalk API
Loading...
Searching...
No Matches
EasyTalk.Localization.TranslationSet Class Reference

A TranslationSet contains lines of text which have been translated into a particular language. More...

Public Member Functions

Translation AddOrFindTranslation (string text)
 Checks the translation set to see if the text provided is in the current list of translations. If it isn't, a new translation entry is added for the text.
 
void ExpandToSize (int size)
 Adds new translations to the translation set until it reaches a certain size.
 
void SetTranslation (int id, string text)
 Sets the translation at the specified source ID to the value provided.
 
Translation GetTranslation (int id)
 Returns the Translation for the specified ID, if it exists.
 
bool ContainsTranslation (string text)
 Returns whether the translation set contains a translation with the text specified.
 
Translation FindTranslation (string text)
 Finds the Translation object attributed to the text specified, if it exists.
 

Static Public Member Functions

static string RemoveAllTags (string text)
 Removes all node tags and TextMeshPro/HTML markup tags from the string provided.
 
static string RemoveTMPTags (string text)
 Removes TextMeshPro/HTML markup tags from the string provided.
 
static string RemoveNodeTags (string text)
 Removes all node tags from the string provided.
 
static string IndexVariableNames (string text, Dictionary< string, string > variableNameMap)
 Replaces all variable references in the provided string with numeric, indexed variable names. The new variable names are stored as keys in the variableNameMap provided and the original variable names are stored as the respective values.
 
static string ReplaceVariables (string text, Dictionary< string, string > variableNameMap)
 Replaces all variable references in the provided string with the respective variable names stored as values in the provided Dictionary. Each of the variable names referenced in the string must match a key in the variableNameMap in order to be replaced.
 

Public Attributes

string languageCode
 The ISO-639 language code for the translation set.
 
List< Translationtranslations = new List<Translation>()
 A List of translated liens for the translation set.
 

Private Member Functions

Translation TryAddTranslation (int id, string text)
 Attempts to add a new translation for the specified translation ID.
 

Private Attributes

int counter = 0
 The current counter of the translation set.
 
bool preventTagInclusion = true
 Whether node tags and TextMeshPro/HTML markup tags should be removed from text prior to putting it into the list of translated lines.
 

Detailed Description

A TranslationSet contains lines of text which have been translated into a particular language.

Member Function Documentation

◆ AddOrFindTranslation()

Translation EasyTalk.Localization.TranslationSet.AddOrFindTranslation ( string text)

Checks the translation set to see if the text provided is in the current list of translations. If it isn't, a new translation entry is added for the text.

Parameters
textThe text to find/add a translation for.
Returns
The Translation for the translated line.

◆ ContainsTranslation()

bool EasyTalk.Localization.TranslationSet.ContainsTranslation ( string text)

Returns whether the translation set contains a translation with the text specified.

Parameters
textThe translation text to check.
Returns
True if the translation set contains the text provided; otherwise returns false.

◆ ExpandToSize()

void EasyTalk.Localization.TranslationSet.ExpandToSize ( int size)

Adds new translations to the translation set until it reaches a certain size.

Parameters
sizeThe size which the translation set should be set to.

◆ FindTranslation()

Translation EasyTalk.Localization.TranslationSet.FindTranslation ( string text)

Finds the Translation object attributed to the text specified, if it exists.

Parameters
textThe text to find a Translation object for.
Returns
The Translation object which contains the text specified, if it exists; otherwise returns null.

◆ GetTranslation()

Translation EasyTalk.Localization.TranslationSet.GetTranslation ( int id)

Returns the Translation for the specified ID, if it exists.

Parameters
idThe ID of the Translation to retrieve.
Returns
The Translation for the specified ID if it exists; null otherwise.

◆ IndexVariableNames()

static string EasyTalk.Localization.TranslationSet.IndexVariableNames ( string text,
Dictionary< string, string > variableNameMap )
static

Replaces all variable references in the provided string with numeric, indexed variable names. The new variable names are stored as keys in the variableNameMap provided and the original variable names are stored as the respective values.

Parameters
textThe text to index variable references on.
variableNameMapA Dictionary to insert mappings of indexed variable names to old variable names into.
Returns
A modified version of the original string, with all variable names replaced by indexed variable names.

◆ RemoveAllTags()

static string EasyTalk.Localization.TranslationSet.RemoveAllTags ( string text)
static

Removes all node tags and TextMeshPro/HTML markup tags from the string provided.

Parameters
textThe string to remove tags from.
Returns
A modified version of the original string will all tags removed.

◆ RemoveNodeTags()

static string EasyTalk.Localization.TranslationSet.RemoveNodeTags ( string text)
static

Removes all node tags from the string provided.

Parameters
textThe string to remove tags from.
Returns
A modified version of the original string with all node tags removed.

◆ RemoveTMPTags()

static string EasyTalk.Localization.TranslationSet.RemoveTMPTags ( string text)
static

Removes TextMeshPro/HTML markup tags from the string provided.

Parameters
textThe string to remove tags from.
Returns
A modified version of the original string with all TextMeshPro/HTML markup tags removed.

◆ ReplaceVariables()

static string EasyTalk.Localization.TranslationSet.ReplaceVariables ( string text,
Dictionary< string, string > variableNameMap )
static

Replaces all variable references in the provided string with the respective variable names stored as values in the provided Dictionary. Each of the variable names referenced in the string must match a key in the variableNameMap in order to be replaced.

Parameters
textThe string to replace variable names in.
variableNameMapA Dictionary with current variable names as keys and replacement variable names as values.
Returns
A modified version of the original string, with all variable names replaced if they were found as keys in the Dictionary.

◆ SetTranslation()

void EasyTalk.Localization.TranslationSet.SetTranslation ( int id,
string text )

Sets the translation at the specified source ID to the value provided.

Parameters
idThe source ID the translation applies to.
textThe translated text to set.

◆ TryAddTranslation()

Translation EasyTalk.Localization.TranslationSet.TryAddTranslation ( int id,
string text )
private

Attempts to add a new translation for the specified translation ID.

Parameters
idThe source ID the translation applies to.
textThe translated text.
Returns
The added Translation, or null if a translation couldn't be added.

Member Data Documentation

◆ counter

int EasyTalk.Localization.TranslationSet.counter = 0
private

The current counter of the translation set.

◆ languageCode

string EasyTalk.Localization.TranslationSet.languageCode

The ISO-639 language code for the translation set.

◆ preventTagInclusion

bool EasyTalk.Localization.TranslationSet.preventTagInclusion = true
private

Whether node tags and TextMeshPro/HTML markup tags should be removed from text prior to putting it into the list of translated lines.

◆ translations

List<Translation> EasyTalk.Localization.TranslationSet.translations = new List<Translation>()

A List of translated liens for the translation set.