summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-03-25 10:42:37 +0100
committerRémi Verschelde <rverschelde@gmail.com>2024-03-25 10:42:37 +0100
commit0e36df69f963fc965dcd781210778d3d0c3e829c (patch)
treeb6058b2bb8618ad11ba72b2c1bbc8959c8e07051
parent2a4b47e064ec72558eef547cc33c57adeb668379 (diff)
parent83789426cc036f213074234d0de115c389200083 (diff)
downloadredot-engine-0e36df69f963fc965dcd781210778d3d0c3e829c.tar.gz
Merge pull request #89815 from KoBeWi/translates_bananas
Improve some notification and translation docs
-rw-r--r--doc/classes/Control.xml8
-rw-r--r--doc/classes/Node.xml12
-rw-r--r--doc/classes/Object.xml2
3 files changed, 19 insertions, 3 deletions
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index 697afed636..cc32964e87 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -1182,6 +1182,14 @@
- One of the node's theme property overrides is changed.
- The node enters the scene tree.
[b]Note:[/b] As an optimization, this notification won't be sent from changes that occur while this node is outside of the scene tree. Instead, all of the theme item updates can be applied at once when the node enters the scene tree.
+ [b]Note:[/b] This notification is received alongside [constant Node.NOTIFICATION_ENTER_TREE], so if you are instantiating a scene, the child nodes will not be initialized yet. You can use it to setup theming 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 Node.is_node_ready].
+ [codeblock]
+ func _notification(what):
+ if what == NOTIFICATION_THEME_CHANGED:
+ if not is_node_ready():
+ await ready # Wait until ready signal.
+ $Label.add_theme_color_override("font_color", Color.YELLOW)
+ [/codeblock]
</constant>
<constant name="NOTIFICATION_SCROLL_BEGIN" value="47">
Sent when this node is inside a [ScrollContainer] which has begun being scrolled when dragging the scrollable area [i]with a touch event[/i]. This notification is [i]not[/i] sent when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.
diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml
index c69e5edf0c..1ddcdce439 100644
--- a/doc/classes/Node.xml
+++ b/doc/classes/Node.xml
@@ -187,7 +187,7 @@
<param index="0" name="message" type="String" />
<param index="1" name="context" type="StringName" default="&quot;&quot;" />
<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.
diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml
index 85b9cf16f2..b69326b6e0 100644
--- a/doc/classes/Object.xml
+++ b/doc/classes/Object.xml
@@ -1024,7 +1024,7 @@
<param index="0" name="message" type="StringName" />
<param index="1" name="context" type="StringName" default="&amp;&quot;&quot;" />
<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.
If [method can_translate_messages] is [code]false[/code], or no translation is available, this method returns the [param message] without changes. See [method set_message_translation].
For detailed examples, see [url=$DOCS_URL/tutorials/i18n/internationalizing_games.html]Internationalizing games[/url].
</description>