@@ -93,33 +93,35 @@ void EditorAutoloadSettings::_notification(int p_what) {
93
93
}
94
94
95
95
bool EditorAutoloadSettings::_autoload_name_is_valid (const String &p_name, String *r_error) {
96
+ String invalid_name_msg = vformat (TTR (" Invalid name: %s" ), p_name);
97
+
96
98
if (!p_name.is_valid_unicode_identifier ()) {
97
99
if (r_error) {
98
- *r_error = TTR ( " Invalid name. " ) + " " + TTR (" Must be a valid Unicode identifier." );
100
+ *r_error = invalid_name_msg + " " + TTR (" Must be a valid Unicode identifier." );
99
101
}
100
102
101
103
return false ;
102
104
}
103
105
104
106
if (ClassDB::class_exists (p_name)) {
105
107
if (r_error) {
106
- *r_error = TTR ( " Invalid name. " ) + " " + TTR (" Must not collide with an existing engine class name." );
108
+ *r_error = invalid_name_msg + " " + TTR (" Must not collide with an existing engine class name." );
107
109
}
108
110
109
111
return false ;
110
112
}
111
113
112
114
if (ScriptServer::is_global_class (p_name)) {
113
115
if (r_error) {
114
- *r_error = TTR ( " Invalid name. " ) + " \n " + TTR (" Must not collide with an existing global script class name." );
116
+ *r_error = invalid_name_msg + " \n " + TTR (" Must not collide with an existing global script class name." );
115
117
}
116
118
117
119
return false ;
118
120
}
119
121
120
122
if (Variant::get_type_by_name (p_name) < Variant::VARIANT_MAX) {
121
123
if (r_error) {
122
- *r_error = TTR ( " Invalid name. " ) + " " + TTR (" Must not collide with an existing built-in type name." );
124
+ *r_error = invalid_name_msg + " " + TTR (" Must not collide with an existing built-in type name." );
123
125
}
124
126
125
127
return false ;
@@ -128,7 +130,7 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
128
130
for (int i = 0 ; i < CoreConstants::get_global_constant_count (); i++) {
129
131
if (CoreConstants::get_global_constant_name (i) == p_name) {
130
132
if (r_error) {
131
- *r_error = TTR ( " Invalid name. " ) + " " + TTR (" Must not collide with an existing global constant name." );
133
+ *r_error = invalid_name_msg + " " + TTR (" Must not collide with an existing global constant name." );
132
134
}
133
135
134
136
return false ;
@@ -139,7 +141,7 @@ bool EditorAutoloadSettings::_autoload_name_is_valid(const String &p_name, Strin
139
141
for (const String &keyword : ScriptServer::get_language (i)->get_reserved_words ()) {
140
142
if (keyword == p_name) {
141
143
if (r_error) {
142
- *r_error = TTR ( " Invalid name. " ) + " " + TTR (" Keyword cannot be used as an Autoload name." );
144
+ *r_error = invalid_name_msg + " " + TTR (" Keyword cannot be used as an Autoload name." );
143
145
}
144
146
145
147
return false ;
0 commit comments