aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/ustring.cpp22
-rw-r--r--core/ustring.h11
-rw-r--r--core/variant.cpp44
-rw-r--r--core/variant.h2
4 files changed, 78 insertions, 1 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 1f0eadc03..c2520a7a8 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -3963,11 +3963,31 @@ String String::sprintf(const Array& values, bool* error) const {
#include "translation.h"
+#ifdef TOOLS_ENABLED
String TTR(const String& p_text) {
if (TranslationServer::get_singleton()) {
- return TranslationServer::get_singleton()->translate(p_text);
+ return TranslationServer::get_singleton()->tool_translate(p_text);
}
return p_text;
}
+
+#endif
+
+String RTR(const String& p_text) {
+
+
+
+ if (TranslationServer::get_singleton()) {
+ String rtr = TranslationServer::get_singleton()->tool_translate(p_text);
+ if (rtr==String() || rtr==p_text) {
+ return TranslationServer::get_singleton()->translate(p_text);
+ } else {
+ return rtr;
+ }
+ }
+
+ return p_text;
+}
+
diff --git a/core/ustring.h b/core/ustring.h
index 78c041fb9..e03f74f50 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -257,6 +257,17 @@ struct NoCaseComparator {
/* end of namespace */
//tool translate
+#ifdef TOOLS_ENABLED
+
String TTR(const String&);
+#else
+
+#define TTR(m_val) (String())
+
+#endif
+
+//tool or regular translate
+String RTR(const String&);
+
#endif
diff --git a/core/variant.cpp b/core/variant.cpp
index ea5a378ad..38f5e69cc 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -3048,3 +3048,47 @@ String Variant::get_call_error_text(Object* p_base, const StringName& p_method,c
}
return "'"+class_name+"::"+String(p_method)+"': "+err_text;
}
+
+
+String vformat(const String& p_text, const Variant& p1,const Variant& p2,const Variant& p3,const Variant& p4,const Variant& p5) {
+
+ Array args;
+ if (p1.get_type()!=Variant::NIL) {
+
+ args.push_back(p1);
+
+ if (p2.get_type()!=Variant::NIL) {
+
+ args.push_back(p2);
+
+ if (p3.get_type()!=Variant::NIL) {
+
+ args.push_back(p3);
+
+ if (p4.get_type()!=Variant::NIL) {
+
+ args.push_back(p4);
+
+ if (p5.get_type()!=Variant::NIL) {
+
+ args.push_back(p5);
+
+ }
+
+ }
+
+
+ }
+
+ }
+
+ }
+
+ bool error=false;
+ String fmt = p_text.sprintf(args,&error);
+
+ ERR_FAIL_COND_V(error,String());
+
+ return fmt;
+
+}
diff --git a/core/variant.h b/core/variant.h
index ed33de666..b95223ecf 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -469,4 +469,6 @@ const Variant::ObjData& Variant::_get_obj() const {
return *reinterpret_cast<const ObjData*>(&_data._mem[0]);
}
+
+String vformat(const String& p_text, const Variant& p1=Variant(),const Variant& p2=Variant(),const Variant& p3=Variant(),const Variant& p4=Variant(),const Variant& p5=Variant());
#endif