|
@@ -1527,6 +1527,14 @@ void Object::initialize_class() {
|
|
|
initialized = true;
|
|
|
}
|
|
|
|
|
|
+StringName Object::get_translation_domain() const {
|
|
|
+ return _translation_domain;
|
|
|
+}
|
|
|
+
|
|
|
+void Object::set_translation_domain(const StringName &p_domain) {
|
|
|
+ _translation_domain = p_domain;
|
|
|
+}
|
|
|
+
|
|
|
String Object::tr(const StringName &p_message, const StringName &p_context) const {
|
|
|
if (!_can_translate || !TranslationServer::get_singleton()) {
|
|
|
return p_message;
|
|
@@ -1541,7 +1549,8 @@ String Object::tr(const StringName &p_message, const StringName &p_context) cons
|
|
|
return TranslationServer::get_singleton()->tool_translate(p_message, p_context);
|
|
|
}
|
|
|
|
|
|
- return TranslationServer::get_singleton()->translate(p_message, p_context);
|
|
|
+ const Ref<TranslationDomain> domain = TranslationServer::get_singleton()->get_or_add_domain(get_translation_domain());
|
|
|
+ return domain->translate(p_message, p_context);
|
|
|
}
|
|
|
|
|
|
String Object::tr_n(const StringName &p_message, const StringName &p_message_plural, int p_n, const StringName &p_context) const {
|
|
@@ -1562,7 +1571,8 @@ String Object::tr_n(const StringName &p_message, const StringName &p_message_plu
|
|
|
return TranslationServer::get_singleton()->tool_translate_plural(p_message, p_message_plural, p_n, p_context);
|
|
|
}
|
|
|
|
|
|
- return TranslationServer::get_singleton()->translate_plural(p_message, p_message_plural, p_n, p_context);
|
|
|
+ const Ref<TranslationDomain> domain = TranslationServer::get_singleton()->get_or_add_domain(get_translation_domain());
|
|
|
+ return domain->translate_plural(p_message, p_message_plural, p_n, p_context);
|
|
|
}
|
|
|
|
|
|
void Object::_clear_internal_resource_paths(const Variant &p_var) {
|
|
@@ -1714,6 +1724,8 @@ void Object::_bind_methods() {
|
|
|
ClassDB::bind_method(D_METHOD("can_translate_messages"), &Object::can_translate_messages);
|
|
|
ClassDB::bind_method(D_METHOD("tr", "message", "context"), &Object::tr, DEFVAL(StringName()));
|
|
|
ClassDB::bind_method(D_METHOD("tr_n", "message", "plural_message", "n", "context"), &Object::tr_n, DEFVAL(StringName()));
|
|
|
+ ClassDB::bind_method(D_METHOD("get_translation_domain"), &Object::get_translation_domain);
|
|
|
+ ClassDB::bind_method(D_METHOD("set_translation_domain", "domain"), &Object::set_translation_domain);
|
|
|
|
|
|
ClassDB::bind_method(D_METHOD("is_queued_for_deletion"), &Object::is_queued_for_deletion);
|
|
|
ClassDB::bind_method(D_METHOD("cancel_free"), &Object::cancel_free);
|