Skip to content

Quick Start

Tony van Loon edited this page Sep 27, 2024 · 11 revisions

1 Import the package

Use the Unity package manager to import the package from GitHub with te following url: https://github.com/3Dimensions-NL/Localization.git

2 Import the samples

The samples contain important starter files for your localization and some examples of how you can use the package. Go to the samples tab in the Unity Package Manager to import the samples.

Samples

You can find the folder here: Assets/Samples/3Dimensions Localization/(version number)/Sample assets

3 Creating localization languages

In the samples folder under Localizations you will find to premade 'LanguageObjects'.

These are scriptable objects that define the available languages in your project. Every Language Objects needs a corresponding Flag and a list of locales (f.e. en-US for United States English, but also en-UK for United Kingdom)

Languages

You can make new ones simply by duplicating one of these and renaming them and filling the needed data.

LanguageObject

4 Creating Translation Assets

Translations can be three things (for now):

  • A string
  • A sprite (image)
  • A audio clip

In a Unity Project window, navigate to a folder where you want to store your translations.

Rightclick somewhere in the project window and navigate to Create > 3Dimensions > Localization

Select the translation asset type you want to create (string, sprite or audio clip) and name it to something logical.

Creation menu

Now select your newly created Translation Asset and add some translation info.

Translation

5 Adding a Translation Asset to a object

On the GameObject you want to translate, Click the "Add Component" button in the inspector and add the TranslationComponent.

This is a generic component that can translate other Unity components. Compatible components are:

  • UnityEngine.UI.Image object (sprite)
  • TextMeshPro text object (string)
  • TextMeshPro Input Field (string)
  • Legacy Text object (string)
  • UnityEngine.AudioClipt (audio clip)

We are planning to add more, but these are the most used ones for now. Let us know which components you want to see supported.

Alright, drag n drop your Translation Asset created in step 4 into the Translation Asset slot on the component.

To preview the translation, click the Apply Translation button or the Switch Translation button This way you can check if the used text is not to large for certain UI elements for example.

TranslationComponent

6 Add the LocalizationManager prefab

The Localization Manager is used to setup all the Translation Components.

LocalizationManager

When an application is first started it will try to set the language based on the locale of the device it is running on. It also handles the changing to other languages and stores the player selected default language in player prefs of the device.

You can find the prefab in the samples folder under Prefabs. Add the prefab to the first scene that is loaded to work directly from the start. The prefab will be persistent through the applications lifetime.

7 Add the Language Select Button

Why localizing a project and not give the players the option to change to a different language?! Add the Prefab LanguageSelectButton in your settings page (or wherever you want). You can off course style it the way you want.

LanguageSelectButton

The Localization Editor window

We also added an editor window if you want to change multiple translations at once. The window is found in the top menu under: 3Dimensions > Localization > Localization Editor

LocalizationEditor

When you open it for the first time, you will get the question to specify a folder for your translations. After that, all new translation (created by the editor window) will be stored in this folder. You can change te folder at any time you want, but remember that the editor window will only load translations present in that folder.

Another neat feature is that you can export or import csv files to create or update translations in bulk. The csv needs to be (off course) in the right format. The easiest way is to create a few string translations assets and export the file to see the csv structure.

Unfortunately this does not work for sprits or audio clips... duh!

That are the basics!

Alright, you can now create a localized unity project!

Clone this wiki locally