Class BaseTranslationSource
Base class for classes that provide translations for phrases. The translations could be serialized in the scene or come from a File (FileTranslationSource) or from other places.
Namespace: NoSuchStudio.Localization
Assembly: NoSuchStudio-Localization.dll
Syntax
[ExecuteInEditMode]
public abstract class BaseTranslationSource : NoSuchMonoBehaviour, ITranslationSource, ILocalizationServiceComponent, IServiceComponent<LocalizationService>
Fields
_connected
Keeps the connection status to different services.
Declaration
[NonSerialized]
protected Dictionary<Type, bool> _connected
Field Value
| Type | Description |
|---|---|
| Dictionary<Type, Boolean> |
_readyToConnect
Whether the source is ready to be connected to the LocalizationService. Unless overriden, it happens in OnEnable().
Declaration
[NonSerialized]
protected bool _readyToConnect
Field Value
| Type | Description |
|---|---|
| Boolean |
_translations
Populated list of translations this source provides.
Declaration
[NonSerialized]
protected Dictionary<string, Dictionary<string, string>> _translations
Field Value
| Type | Description |
|---|---|
| Dictionary<String, Dictionary<String, String>> |
Properties
mono
Declaration
public MonoBehaviour mono { get; }
Property Value
| Type | Description |
|---|---|
| UnityEngine.MonoBehaviour |
translations
Declaration
public Dictionary<string, Dictionary<string, string>> translations { get; set; }
Property Value
| Type | Description |
|---|---|
| Dictionary<String, Dictionary<String, String>> |
Methods
Awake()
Declaration
protected virtual void Awake()
Clear()
Removes all translations from this translation source.
Declaration
public virtual void Clear()
Connect<ST>()
Try to connect to the given service. Check IsConnected<ST>() to check if the connection attempt was succssful.
Declaration
public void Connect<ST>()
where ST : Service<ST>
Type Parameters
| Name | Description |
|---|---|
| ST |
Disconnect<ST>()
Try to disconnect from the given service. Check IsConnected<ST>() to check if the connection attempt was succssful.
Declaration
public void Disconnect<ST>()
where ST : Service<ST>
Type Parameters
| Name | Description |
|---|---|
| ST |
GetTranslation(String, String)
Get translation for "phrase" in "locale" from this translation source.
Declaration
public virtual string GetTranslation(string phrase, string locale)
Parameters
| Type | Name | Description |
|---|---|---|
| String | phrase | phrase to get translation for. |
| String | locale | locale of the translation. |
Returns
| Type | Description |
|---|---|
| String | Translated string if one exists, null otherwise. |
Init()
Declaration
protected virtual void Init()
IsConnected<ST>()
Check connection to service.
Declaration
public virtual bool IsConnected<ST>()
where ST : Service<ST>
Returns
| Type | Description |
|---|---|
| Boolean | Returns true if connected to the service. |
Type Parameters
| Name | Description |
|---|---|
| ST |
LoadTranslationEntries(List<TranslationEntry>)
Declaration
public void LoadTranslationEntries(List<TranslationEntry> entries)
Parameters
| Type | Name | Description |
|---|---|---|
| List<TranslationEntry> | entries |
OnDisable()
Declaration
protected virtual void OnDisable()
OnEnable()
Declaration
protected virtual void OnEnable()
Reset()
Removes all translations from this translation source.
Declaration
protected virtual void Reset()