# ComponentBased Mode

## ComponentBased Mode

In **ComponentBased Mode**, you do not need to manage external files or predefined lists of translations. Instead, this mode allows you to handle translations directly through the `LocalizedText` component on each text object. This provides a dynamic and flexible solution for smaller projects or when you want to manage translations directly in the Unity Editor.

***

#### Using the LocalizedText Component:

1. Add the `LocalizedText` component to any `Text` or `TextMeshProUGUI` object in your scene.
2. In the `LocalizedText` component, you'll find a field for `TextID` where you can define the unique identifier for each piece of text. This `TextID` will be used to refer to this particular piece of text across all languages.
3. Below the `TextID` field, you will find fields for translations. For each language, you can define the **LanguageID** (e.g., `en` for English, `pt-br` for Brazilian Portuguese, etc.) and provide the corresponding **TranslatedText**.
4. When the language is changed in your game, the `LocalizedText` component will automatically update the displayed text based on the current language. There’s no need to manage external files, as all translations are stored within the component itself.

#### Example of Adding a LocalizedText:

1. **Add the Component**: Select your `Text` or `TextMeshProUGUI` object and click **Add Component**. Search for the `LocalizedText` component.
2. **Define the TextID**: Set a unique `TextID` for this text, for example, `greeting`.
3. **Add Translations**: For each supported language, add the `LanguageID` and the corresponding translation:
   * For English (en): "Hello World"
   * For Brazilian Portuguese (pt-br): "Olá Mundo"
   * For Spanish (es): "Hola Mundo"
4. **Automatic Update**: When the language changes in your game, the text will automatically update to the correct translation based on the `TextID`.

***

#### Benefits of ComponentBased Mode:

* **No need for external files**: All translations are managed directly in Unity using the `LocalizedText` component.
* **Dynamic updates**: When the language is switched, each `LocalizedText` component will update its displayed text without the need for reloading data from files.
* **Great for small-scale projects**: This mode is ideal if you have a limited number of texts and want a quick, efficient way to localize them.

***

#### Switching Languages:

As with other modes, you can change the language in **ComponentBased Mode** dynamically. Once the language is switched, all `LocalizedText` components in the scene will automatically refresh to display the appropriate translations.

<figure><img src="https://3626215024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF9jo80etwnAiJ4U7LlGC%2Fuploads%2FSPpgazhetwt0IKQvxYuB%2FComponentBased.png?alt=media&#x26;token=7cdb310a-4a4f-4c69-9fdc-a7452c2837c0" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3626215024-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FF9jo80etwnAiJ4U7LlGC%2Fuploads%2F3gofuPa9XwQEBqVdNE1L%2FLocalizedTextComponent.png?alt=media&#x26;token=b519a3be-e1d5-4229-990d-c31ecb46db51" alt=""><figcaption></figcaption></figure>

> Make sure to follow this process for all texts that you want to be translated within your game.

> **Reminder: LanguageManagerEditor Tool**
>
> We offer a **free LanguageManagerEditor tool**, specifically designed for the LanguageSystem Pro format. It has a friendly interface and supports easy import, editing, and export of files in CSV, JSON, and XML formats. You can use this tool to export global files for the **InternalDatabase** and **GlobalExternal** modes or individual files per language for **ExternalFiles** mode.
>
> For more details on using this editor, see the LanguageManagerEditor section.
