TIM.Translator
  • ⬇️Installation
  • ❔About
  • Guides
    • 🔖Change the language in Editor
    • 🏷️Text Translatable
    • ⛓️Complex Text Translatable
    • #️⃣C# code
      • #️⃣String Translatable
      • #️⃣Complex String Translatable
      • #️⃣Change the language
  • Projects with translator
    • 1️Gamedev Life Simulator
    • 2️21st UNIVERSE
Powered by GitBook
On this page
  • Example
  • Changing parts inside C# script
  1. Guides

Complex Text Translatable

PreviousText TranslatableNextC# code

Last updated 2 years ago

Example

ComplexTextTranslatable works like TextTranslatable but it can be useful when you want to build a text from different parts.

For example: "Health: 100" should be translated to Russian as "Здоровье: 100"

This example contains 2 parts:

  1. "Health:" - StringTranslatable

  2. "100" - string

Just add new part by click on "+"

And then choose a type of part: StringTranslatable or string

Our example will look like this:

Changing parts inside C# script

There is an example of changing the second part (index = 1) of the text:

public ComplexTextTranslatable ComplexTextTranslatable;

private int health;

public void Refresh()
{
    ComplexTextTranslatable.Text.Parts[1].String = health.ToString();
}

If you are changing a translatable part (part with StringTranslatable as selected variant) you can probably want to translate it right after editing the text. But you must keep in mind that runtime translator outside the Editor doesn't work! So it can be useful only for writing an editor code.

If you really want to add runtime translation you can ask me about it. Just keep in mind that if your game will reach for example 1 000 000 players it can make translation traffic too high (and it will cost too much for you)!

public ComplexTextTranslatable ComplexTextTranslatable;

public void Refresh()
{
    ComplexTextTranslatable.Text.Parts[0].StringTranslatable.MainTranslation = new StringTranslatable.TextTranslation("Something", Language.English);
    ComplexTextTranslatable.Text.Parts[0].StringTranslatable.Translate();
}

⛓️