Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid text substitution in EditorHelp messages #81346

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions editor/editor_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ void EditorHelp::_update_method_list(const Vector<DocData::MethodDoc> p_methods)
class_desc->add_newline();
}

void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, const String &p_method_type) {
void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, MethodType p_method_type) {
String link_color_text = theme_cache.title_color.to_html(false);

class_desc->add_newline();
Expand Down Expand Up @@ -699,11 +699,24 @@ void EditorHelp::_update_method_descriptions(const DocData::ClassDoc p_classdoc,
class_desc->add_image(get_theme_icon(SNAME("Error"), SNAME("EditorIcons")));
class_desc->add_text(" ");
class_desc->push_color(theme_cache.comment_color);

String message;
if (p_classdoc.is_script_doc) {
class_desc->append_text(vformat(TTR("There is currently no description for this %s."), p_method_type));
static const char *messages_by_type[METHOD_TYPE_MAX] = {
TTRC("There is currently no description for this method."),
TTRC("There is currently no description for this constructor."),
TTRC("There is currently no description for this operator."),
};
message = TTRGET(messages_by_type[p_method_type]);
} else {
class_desc->append_text(vformat(TTR("There is currently no description for this %s. Please help us by [color=$color][url=$url]contributing one[/url][/color]!"), p_method_type).replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text));
static const char *messages_by_type[METHOD_TYPE_MAX] = {
TTRC("There is currently no description for this method. Please help us by [color=$color][url=$url]contributing one[/url][/color]!"),
TTRC("There is currently no description for this constructor. Please help us by [color=$color][url=$url]contributing one[/url][/color]!"),
TTRC("There is currently no description for this operator. Please help us by [color=$color][url=$url]contributing one[/url][/color]!"),
};
message = TTRGET(messages_by_type[p_method_type]).replace("$url", CONTRIBUTE_URL).replace("$color", link_color_text);
}
class_desc->append_text(message);
class_desc->pop();
}

Expand Down Expand Up @@ -1842,7 +1855,7 @@ void EditorHelp::_update_doc() {
class_desc->add_text(TTR("Constructor Descriptions"));
_pop_title_font();

_update_method_descriptions(cd, cd.constructors, "constructor");
_update_method_descriptions(cd, cd.constructors, METHOD_TYPE_CONSTRUCTOR);
}

// Method descriptions
Expand All @@ -1852,7 +1865,7 @@ void EditorHelp::_update_doc() {
class_desc->add_text(TTR("Method Descriptions"));
_pop_title_font();

_update_method_descriptions(cd, methods, "method");
_update_method_descriptions(cd, methods, METHOD_TYPE_METHOD);
}

// Operator descriptions
Expand All @@ -1862,7 +1875,7 @@ void EditorHelp::_update_doc() {
class_desc->add_text(TTR("Operator Descriptions"));
_pop_title_font();

_update_method_descriptions(cd, cd.operators, "operator");
_update_method_descriptions(cd, cd.operators, METHOD_TYPE_OPERATOR);
}

// Free the scroll.
Expand Down
15 changes: 6 additions & 9 deletions editor/editor_help.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,11 @@ class FindBar : public HBoxContainer {
class EditorHelp : public VBoxContainer {
GDCLASS(EditorHelp, VBoxContainer);

enum Page {
PAGE_CLASS_LIST,
PAGE_CLASS_DESC,
PAGE_CLASS_PREV,
PAGE_CLASS_NEXT,
PAGE_SEARCH,
CLASS_SEARCH,

enum MethodType {
METHOD_TYPE_METHOD,
METHOD_TYPE_CONSTRUCTOR,
METHOD_TYPE_OPERATOR,
METHOD_TYPE_MAX
};

bool select_locked = false;
Expand Down Expand Up @@ -181,7 +178,7 @@ class EditorHelp : public VBoxContainer {
Error _goto_desc(const String &p_class);
//void _update_history_buttons();
void _update_method_list(const Vector<DocData::MethodDoc> p_methods);
void _update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, const String &p_method_type);
void _update_method_descriptions(const DocData::ClassDoc p_classdoc, const Vector<DocData::MethodDoc> p_methods, MethodType p_method_type);
void _update_doc();

void _request_help(const String &p_string);
Expand Down
Loading