Localize Text
Last updated
Last updated
To create a StringTable resource, run the following command: Assets (or right-click menu in Project) > Create > fuliu > Language Localization (Localization) > StringTable. The StringTable resource is named TextTable.
Usually the language type file properties will be automatically populated with LocalizationSetting's language type file that exists in the scene. If the autopopulated or autopopulated file is not what you want, you can manually populate it again.
Click the Open Editor button in the image above to open the text table editor. If all is well, the window should look like the following:
In the text table editor, click the + button to the left of the Create field to create a new field. By default, the field ID starts at 0. Then enter the field name in the field name input box, for example, "TestField 0"; Then click on the field name or the right arrow in front of the field name to open the text input field for each language:
We manually enter the first line (simplified Chinese): 'Test field 0' and the second line (English): 'TestField 0'. When we enter text into these two lines, we can see that the language name that was previously displayed in red is now displayed in white (if Unity's skin is Light, the text will only be displayed in black and will not change color, this is Unity's problem, but it does not affect use).
Let's go to the current scene and create a new Ugui Text UI object and attach the UITextStaticSetter component to it.
Drag the StringTable resource file created above into the object reference box below the static text in the image above. A drop-down list appears to the right of the object reference box. Select the field we created earlier: TestField 0 from the drop-down list.
The localization of the text is complete. The next step is to test whether it works properly. Click the "Set to Display component" button in the above image. You can see that the Text component in the Scene window changes into Chinese: "test field 0", indicating that it has been successful.
Click the button in the figure below to loop between different languages to see the Text display. If the text display is abnormal in different languages, you can adjust the text component parameters and Setter component parameters in time.