The package for easy localization of assets in Unity3d.
- Open the Package Manager:
Window
->Package Manager
. - Click on the
+
at the top. - Select
Add package from git URL...
in the drop-down list. - Paste the link to this repository into the field that appears and press
Enter
. - Wait for the code generation to finish.
Warning
Do not change the package folder structure, otherwise you risk losing all localization data.
Select from the top menu: Window
-> Localization Storage
.
You can edit the default localization by selecting it and clicking on the tools icon in the upper right corner of the localization window.
This unlocks the resources of the languages used to change.Select the object that needs localization.
Add a resource localization component to it: Add component
-> Localize
-> [Resource type]Localization
.
You can change the localization directly on the object. To do this, click the Change Localization
button in the inspector window of the localization component.
The new localization will link to the same resources as the standard one. They can be changed directly on the component.
Attention! When editing a localization used by several objects, the changes will affect all objects using an instance of this localization.
To control localization in Runtime, you need to add the LocalizationController
component to the stage.
Scriptable Object of type LocalizationStorage
must be added to the Localization Storage
field.
In the On Chage Language
event field you can add a handler that receives a string with the name of the language.
To interact with an object of type LocalizationController
in code, you can use the following methods:
Method | Description |
---|---|
GetInstance | A static method that creates or returns a ready-made instance from the stage. Accepts a dontDestroy argument which allows you to save the object instance when changing scenes. Returns an instance of LocalizationController . |
Subscribe | Allows an instance of a LocalizationComponent derived type, passed as an argument, to subscribe to localization changes. |
Unsubscribe | Allows an instance of a LocalizationComponent derived type, passed as an argument, to subscribe to localization changes. |
SetNextLanguage | Changes the language to the next one in the localization list. |
SetPrevLanguage | Changes the language to the previous one in the localization list. |
SetLanguage | Sets the current language and loads localized resources. Takes an object of type Language as an argument |