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

AutoTranslate is a component which can be placed on a GameObject with a text component. When used with an appropriate TranslationLibrary, it enables the text to be translated automatically whenever the language is changes on the EasyTalkGameState. More...

Inherits MonoBehaviour.

Public Member Functions

void SetText (string text)
 Sets the text value of the text component. The text passed to this method should be in the default/original language and will be translated automatically by this method if possible.
 

Protected Member Functions

void LanguageChanged (string oldLanguage, string newLanguage)
 Called whenever the language is changed on the EasyTalkGameState. This method will attempt to update the text to the translated version and update the font of the text element if necessary.
 

Properties

Text Text [get]
 

Private Member Functions

void Awake ()
 INitializes the AutoTranslate component.
 
void UpdateFont ()
 Updates the font of the text element to a font compatible with the current language (based on the language font overrides of the EasyTalkGameState).
 
void UpdateText ()
 Updates the text element to a translated version of the original text if a translation can be found for the current EasyTalkGameState language.
 

Private Attributes

Text text
 The text component to translate.
 
TranslationLibrary library
 The translation library to use for translations.
 
LanguageFontOverrides languageFontOverrides
 The set of fonts to use for various languages.
 
string originalText
 The original text value.
 

Detailed Description

AutoTranslate is a component which can be placed on a GameObject with a text component. When used with an appropriate TranslationLibrary, it enables the text to be translated automatically whenever the language is changes on the EasyTalkGameState.

Member Function Documentation

◆ Awake()

void EasyTalk.Localization.AutoTranslate.Awake ( )
private

INitializes the AutoTranslate component.

◆ LanguageChanged()

void EasyTalk.Localization.AutoTranslate.LanguageChanged ( string oldLanguage,
string newLanguage )
protected

Called whenever the language is changed on the EasyTalkGameState. This method will attempt to update the text to the translated version and update the font of the text element if necessary.

Parameters
oldLanguageThe prior language being used.
newLanguageThe new language to use.

◆ SetText()

void EasyTalk.Localization.AutoTranslate.SetText ( string text)

Sets the text value of the text component. The text passed to this method should be in the default/original language and will be translated automatically by this method if possible.

Parameters
textThe new text value.

◆ UpdateFont()

void EasyTalk.Localization.AutoTranslate.UpdateFont ( )
private

Updates the font of the text element to a font compatible with the current language (based on the language font overrides of the EasyTalkGameState).

◆ UpdateText()

void EasyTalk.Localization.AutoTranslate.UpdateText ( )
private

Updates the text element to a translated version of the original text if a translation can be found for the current EasyTalkGameState language.

Member Data Documentation

◆ languageFontOverrides

LanguageFontOverrides EasyTalk.Localization.AutoTranslate.languageFontOverrides
private

The set of fonts to use for various languages.

◆ library

TranslationLibrary EasyTalk.Localization.AutoTranslate.library
private

The translation library to use for translations.

◆ originalText

string EasyTalk.Localization.AutoTranslate.originalText
private

The original text value.

◆ text

Text EasyTalk.Localization.AutoTranslate.text
private

The text component to translate.

Property Documentation

◆ Text

Text EasyTalk.Localization.AutoTranslate.Text
get