Zh/Dota 2 Workshop Tools/Panorama/Localization: Difference between revisions
(Created page with "{{otherlang2 |title = 本地化 |en= Dota 2 Workshop Tools/Panorama/ocalization }} 为了让Panorama支持多语言,大多数UI都会使用本地化标识而不是简单的...") |
No edit summary |
||
Line 1: | Line 1: | ||
{{otherlang2 | {{otherlang2 | ||
|title = | |title = 方言 | ||
|en= Dota 2 Workshop Tools/Panorama/ocalization | |en= Dota 2 Workshop Tools/Panorama/ocalization | ||
}} | }} | ||
Line 7: | Line 7: | ||
In order to support multiple languages, most Panorama UIs are built with references to "localization tokens" instead of literal user-facing strings. These tokens are then dynamically replaced with the correct localized string depending on the user's language selection. | In order to support multiple languages, most Panorama UIs are built with references to "localization tokens" instead of literal user-facing strings. These tokens are then dynamically replaced with the correct localized string depending on the user's language selection. | ||
在XML文件中,方言标识标有“#”前缀,并可以按以下的标准文本被使用: | |||
<code><Label text="#hello_message" /></code> | <code><Label text="#hello_message" /></code> | ||
当UI被加载完成后,这些带标识的文本会自动被替换成本地化文件中对应的字符: | 当UI被加载完成后,这些带标识的文本会自动被替换成本地化文件中对应的字符: | ||
Line 13: | Line 13: | ||
<code>"hello_message" "Hello, world!"</code> | <code>"hello_message" "Hello, world!"</code> | ||
'''注意''': | '''注意''': 和大多数Panorama的文件不同,方言文件放在<font color=red>game/</font> 下而不是<font color=red>content</font>。 | ||
在dotaAddon中,方言文件在:<code><font color=red>game/</font>dota_addons/ADDON_NAME/panorama/localization/addon_LANGUAGE_NAME.txt</code> | |||
在很多情况下,你需要方言字符中包含一些动态的内容。这可以通过使用“会话变量”来实现。这些设置在板上的变量可以被本地化文件引用。 | |||
<code>XML: | <code>XML: | ||
<Label id="msg" text="#MessageText" /> | <Label id="msg" text="#MessageText" /> | ||
Line 29: | Line 29: | ||
"MessageText" "My {s:adjective} number is {d:number}."</code> | "MessageText" "My {s:adjective} number is {d:number}."</code> | ||
{{注意| | {{注意|如果你在Javascript中动态地设置了一个标签的文本,它是不会自动使用方言的。如果要同样动态地给这个标签分派一个方言标识,你需要在Javascript中把这个字符也进行方言翻译(这种方法只能给会话变量有限的支持)。 | ||
<code>$( "#PanelID" ).text = $.Localize( "#LocalizationToken" );</code> | <code>$( "#PanelID" ).text = $.Localize( "#LocalizationToken" );</code> |
Revision as of 16:16, 20 September 2021
为了让Panorama支持多语言,大多数UI都会使用本地化标识而不是简单的给用户看的字符。这些标识让程序根据用户的语言选择,正确地应用对应的语言环境。 In order to support multiple languages, most Panorama UIs are built with references to "localization tokens" instead of literal user-facing strings. These tokens are then dynamically replaced with the correct localized string depending on the user's language selection.
在XML文件中,方言标识标有“#”前缀,并可以按以下的标准文本被使用:
<Label text="#hello_message" />
当UI被加载完成后,这些带标识的文本会自动被替换成本地化文件中对应的字符:
"hello_message" "Hello, world!"
注意: 和大多数Panorama的文件不同,方言文件放在game/ 下而不是content。
在dotaAddon中,方言文件在:game/dota_addons/ADDON_NAME/panorama/localization/addon_LANGUAGE_NAME.txt
在很多情况下,你需要方言字符中包含一些动态的内容。这可以通过使用“会话变量”来实现。这些设置在板上的变量可以被本地化文件引用。
XML:
<Label id="msg" text="#MessageText" />
Javascript:
$("#msg").SetDialogVariable( "adjective", "favorite" );
$("#msg").SetDialogVariableInt( "number", 2 );
Localization file:
"MessageText" "My {s:adjective} number is {d:number}."
{{注意|如果你在Javascript中动态地设置了一个标签的文本,它是不会自动使用方言的。如果要同样动态地给这个标签分派一个方言标识,你需要在Javascript中把这个字符也进行方言翻译(这种方法只能给会话变量有限的支持)。
$( "#PanelID" ).text = $.Localize( "#LocalizationToken" );