mirror of
https://github.com/godotengine/godot.git
synced 2024-11-25 05:33:11 +00:00
Merge pull request #53207 from o01eg/virtual-translation-3.x
This commit is contained in:
commit
01ae4888e9
@ -871,6 +871,10 @@ void Translation::add_message(const StringName &p_src_text, const StringName &p_
|
||||
translation_map[p_src_text] = p_xlated_text;
|
||||
}
|
||||
StringName Translation::get_message(const StringName &p_src_text) const {
|
||||
if (get_script_instance()) {
|
||||
return get_script_instance()->call("_get_message", p_src_text);
|
||||
}
|
||||
|
||||
const Map<StringName, StringName>::Element *E = translation_map.find(p_src_text);
|
||||
if (!E) {
|
||||
return StringName();
|
||||
@ -904,6 +908,8 @@ void Translation::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("_set_messages"), &Translation::_set_messages);
|
||||
ClassDB::bind_method(D_METHOD("_get_messages"), &Translation::_get_messages);
|
||||
|
||||
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_message", PropertyInfo(Variant::STRING, "src_message")));
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::POOL_STRING_ARRAY, "messages", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_messages", "_get_messages");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "locale"), "set_locale", "get_locale");
|
||||
}
|
||||
|
@ -11,6 +11,13 @@
|
||||
<link>https://docs.godotengine.org/en/3.4/tutorials/i18n/locales.html</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="_get_message" qualifiers="virtual">
|
||||
<return type="String" />
|
||||
<argument index="0" name="src_message" type="String" />
|
||||
<description>
|
||||
Virtual method to override [method get_message].
|
||||
</description>
|
||||
</method>
|
||||
<method name="add_message">
|
||||
<return type="void" />
|
||||
<argument index="0" name="src_message" type="String" />
|
||||
|
Loading…
Reference in New Issue
Block a user