Translation
继承: Resource
< RefCounted
< Object
A language translation that maps a collection of strings to their individual translations.
描述
Translation s are resources that can be loaded and unloaded on demand. They map a collection of strings to their individual translations, and they also provide convenience methods for pluralization.
属性
方法
StringName | _get_message ( src_message: StringName , context: StringName ) virtual1 const2 |
StringName | _get_plural_message ( src_message: StringName , src_plural_message: StringName , n: int , context: StringName ) virtual1 const2 |
void | add_message ( src_message: StringName , xlated_message: StringName , context: StringName = &"" ) |
void | add_plural_message ( src_message: StringName , xlated_messages: PackedStringArray , context: StringName = &"" ) |
void | erase_message ( src_message: StringName , context: StringName = &"" ) |
StringName | get_message ( src_message: StringName , context: StringName = &"" ) const2 |
int | get_message_count ( ) const2 |
PackedStringArray | get_message_list ( ) const2 |
StringName | get_plural_message ( src_message: StringName , src_plural_message: StringName , n: int , context: StringName = &"" ) const2 |
PackedStringArray | get_translated_message_list ( ) const2 |
属性说明
String
locale = "en"
The locale of the translation.
方法说明
StringName
_get_message ( src_message: StringName
, context: StringName
) virtual1 const2
Virtual method to override get_message
.
StringName
_get_plural_message ( src_message: StringName
, src_plural_message: StringName
, n: int
, context: StringName
) virtual1 const2
Virtual method to override get_plural_message
.
void
add_message ( src_message: StringName
, xlated_message: StringName
, context: StringName
= &"" )
Adds a message if nonexistent, followed by its translation.
An additional context could be used to specify the translation context or differentiate polysemic words.
void
add_plural_message ( src_message: StringName
, xlated_messages: PackedStringArray
, context: StringName
= &"" )
Adds a message involving plural translation if nonexistent, followed by its translation.
An additional context could be used to specify the translation context or differentiate polysemic words.
void
erase_message ( src_message: StringName
, context: StringName
= &"" )
Erases a message.
StringName
get_message ( src_message: StringName
, context: StringName
= &"" ) const2
Returns a message's translation.
int
get_message_count ( ) const2
Returns the number of existing messages.
PackedStringArray
get_message_list ( ) const2
Returns all the messages (keys).
StringName
get_plural_message ( src_message: StringName
, src_plural_message: StringName
, n: int
, context: StringName
= &"" ) const2
Returns a message's translation involving plurals.
The number n
is the number or quantity of the plural object. It will be used to guide the translation system to fetch the correct plural form for the selected language.
PackedStringArray
get_translated_message_list ( ) const2
Returns all the messages (translated text).
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。