> For the complete documentation index, see [llms.txt](https://fuliufuliu.gitbook.io/mylocalization-decument/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fuliufuliu.gitbook.io/mylocalization-decument/v1.3/mylocalization-english-document/display-and-setter-components/dynamic-splicing-of-localized-text.md).

# Dynamic Splicing of Localized Text

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

![stickPicture.png](https://2393128398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpNvIT2FzQN3Mk0Zlv1E%2Fuploads%2FNXNnX3KtpZTNmfcD7y2S%2F0.png?alt=media)

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:

![stickPicture.png](https://2393128398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpNvIT2FzQN3Mk0Zlv1E%2Fuploads%2F13620fD7nF3Naa6h7oFr%2F1.png?alt=media)

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:

![截图.png](https://2393128398-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpNvIT2FzQN3Mk0Zlv1E%2Fuploads%2FBvx94EDR9fqBmrP7mcRB%2F2.png?alt=media)
