MyLocalization Decument
  • v1.3
    • MyLocalization English Document
      • MyLocalization Data Flow Diagram
      • Quick Start
        • Run the Demo Correctly
        • Preparation
        • Localize Text
        • Localize Texture
        • Localization of Other Types of Resources
      • Load Assets
        • Only Load Resources Corresponding to the Current Language
        • Implement IResLoader interface
        • Enable IResLoader Subclass
        • Convert Resource References Associations to Paths
        • Text Localization Items Do Not Need to Be Loaded with Language Type
      • Edit Text for Localization
        • Basic Operation
        • Automatic Translation
        • Find and Replace
        • Speech Binding Text
        • CSV Table Export and Import
        • Essay on the Importance of Text Table (StringTable)
      • Display and Setter Components
        • Correspondence between Setter Components and Display Components
        • RTL (Right To Left) Related Settings
        • Dynamic Splicing of Localized Text
        • Quickly create and modify localized field text using properties of MyString
    • MyLocalization 中文文档
      • MyLocalization 数据流程图
      • 快速开始
        • 正确运行 Demo
        • 准备工作
        • 文本本地化
        • 图片本地化
        • 其他资源的本地化
      • 加载当前语言资源
        • 只加载当前语言对应的资源
        • 实现 IResLoader 接口
        • 启用 IResLoader 子类
        • 将资源引用关联转为路径
        • 文本的本地化项不能随语言类型加载
      • 编辑文本表
        • 基本操作
        • 自动翻译
        • 搜索与替换
        • 语音绑定文字
        • CSV表格导出与导入
        • 使用 MyString 的属性快速创建和修改本地化字段文本
      • 一切准备都为了Setter组件实现本地化
        • Setter 组件与显示组件的对应关系
        • RTL (Right To Left)相关设置
        • 动态拼接本地化文本
Powered by GitBook
On this page
  1. v1.3
  2. MyLocalization English Document
  3. Display and Setter Components

Dynamic Splicing of Localized Text

PreviousRTL (Right To Left) Related SettingsNextQuickly create and modify localized field text using properties of MyString

Last updated 2 years ago

Dynamic concatenation of localizable text usually requires some preparation before concatenation of text takes effect.

A component is automatically attached to the LocalizationSetting GameObject: MyStringPack

This component keeps two StringTable lists, one for access, one for lookup access by field name; The other is to look up access based on the name of the text table and the field name or field ID.

For example, the code in Demo DynamicSetTextDemo.cs, the next line of code, after the string. L(), which means you need to query to get localized text.

if (index % 2 == 0) {

uiTextSetter.text = "Now Index = ".L() + ("<color=yellow>" + index + "</color>, ") + "Come on!".L();

}

The MyStringPack component in the Demo is associated with a text table called 'DemoCommonTexts' in its list of code concatenation texts, with the following contents:

From the table can be found: any code appears after added. The strings for L() are present in the field names in the text table.

In other words, it's added. The string of L() must be queried in the MyStringPack script during concatenation. The field data from the MyStringPack component is used when the code of the MyStringPack component concatenates fields of the same name that appear in multiple text tables in the text set list.

When you need to query localized text based on a text table name + field name or text table name + field ID, the MyStringPack component's list of table concatenation text sets is used as follows: Excel file name _ child table name :: Field name, Excel file name _ child table name combined to form a text table StringTable name. This solves the awkwardness of using the game's numerical table as a translation table.

introduction

Detailed introduction

simpleDescription

detailDescription

string

string

PlayerRoleConfig_PlayerRole :: Introduction to Yang Xiaofan

PlayerRoleConfig_PlayerRole :: Yang Xiaofan

PlayerRoleConfig_PlayerRole :: Introduction of Lin Xinyi

PlayerRoleConfig_PlayerRole :: Lin Xinyi Detailed introduction

PlayerRoleConfig_PlayerRole :: Evil Remains unchanged Introduction

PlayerRoleConfig_PlayerRole :: Evil remains unchanged

PlayerRoleConfig_PlayerRole :: Introduction to Fang Tianchen

PlayerRoleConfig_PlayerRole :: Fang Tianchen

You can also easily access localized text in your code in this way:

while (enabled) {

uiTextSetter.text = "Player Name".L() + ": <color=yellow>" +

$"PlayerAttributeForm::PlayerName{index}".LN()

+ "</color>";

if (index >= 2) {

index = 0;

}

index++;

yield return new WaitForSeconds(duration);

}

There was a row in the above code examples: $" PlayerAttributeForm: : PlayerName {index} ". LN (), which can index value is 0, 1, 2, this string is followed. LN() represents the data that needs to be searched for localization data in the list of table concatenation literal sets of the MyStringPack component. The data in the PlayerAttributeForm table is as follows:

stickPicture.png
stickPicture.png
截图.png