|
@@ -187,7 +187,7 @@
|
|
|
<param index="0" name="message" type="String" />
|
|
|
<param index="1" name="context" type="StringName" default="""" />
|
|
|
<description>
|
|
|
- Translates a [param message], using the translation catalogs configured in the Project Settings. Further [param context] can be specified to help with the translation.
|
|
|
+ Translates a [param message], using the translation catalogs configured in the Project Settings. Further [param context] can be specified to help with the translation. Note that most [Control] nodes automatically translate their strings, so this method is mostly useful for formatted strings or custom drawn text.
|
|
|
This method works the same as [method Object.tr], with the addition of respecting the [member auto_translate_mode] state.
|
|
|
If [method Object.can_translate_messages] is [code]false[/code], or no translation is available, this method returns the [param message] without changes. See [method Object.set_message_translation].
|
|
|
For detailed examples, see [url=$DOCS_URL/tutorials/i18n/internationalizing_games.html]Internationalizing games[/url].
|
|
@@ -1201,7 +1201,15 @@
|
|
|
Implemented only on iOS.
|
|
|
</constant>
|
|
|
<constant name="NOTIFICATION_TRANSLATION_CHANGED" value="2010">
|
|
|
- Notification received when translations may have changed. Can be triggered by the user changing the locale. Can be used to respond to language changes, for example to change the UI strings on the fly. Useful when working with the built-in translation support, like [method Object.tr].
|
|
|
+ Notification received when translations may have changed. Can be triggered by the user changing the locale, changing [member auto_translate_mode] or when the node enters the scene tree. Can be used to respond to language changes, for example to change the UI strings on the fly. Useful when working with the built-in translation support, like [method Object.tr].
|
|
|
+ [b]Note:[/b] This notification is received alongside [constant NOTIFICATION_ENTER_TREE], so if you are instantiating a scene, the child nodes will not be initialized yet. You can use it to setup translations for this node, child nodes created from script, or if you want to access child nodes added in the editor, make sure the node is ready using [method is_node_ready].
|
|
|
+ [codeblock]
|
|
|
+ func _notification(what):
|
|
|
+ if what == NOTIFICATION_TRANSLATION_CHANGED:
|
|
|
+ if not is_node_ready():
|
|
|
+ await ready # Wait until ready signal.
|
|
|
+ $Label.text = atr("%d Bananas") % banana_counter
|
|
|
+ [/codeblock]
|
|
|
</constant>
|
|
|
<constant name="NOTIFICATION_WM_ABOUT" value="2011">
|
|
|
Notification received from the OS when a request for "About" information is sent.
|