Skip to content

Commit

Permalink
Online docs now open in the editor language
Browse files Browse the repository at this point in the history
  • Loading branch information
tetrapod00 committed Sep 6, 2024
1 parent 835808e commit 74cc6b5
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def version_info_builder(target, source, env):
#define VERSION_MODULE_CONFIG "{module_config}"
#define VERSION_WEBSITE "{website}"
#define VERSION_DOCS_BRANCH "{docs_branch}"
#define VERSION_DOCS_URL "https://docs.godotengine.org/en/" VERSION_DOCS_BRANCH
#define VERSION_DOCS_URL "https://docs.godotengine.org/"
""".format(**env.version_info)
)

Expand Down
6 changes: 6 additions & 0 deletions doc/classes/EditorSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,12 @@
<member name="interface/editor/mouse_extra_buttons_navigate_history" type="bool" setter="" getter="">
If [code]true[/code], the mouse's additional side buttons will be usable to navigate in the script editor's file history. Set this to [code]false[/code] if you're using the side buttons for other purposes (such as a push-to-talk button in a VoIP program).
</member>
<member name="interface/editor/online_docs_language" type="String" setter="" getter="">
If [member interface/editor/override_online_docs_language] is true, then the online docs will open in this language.
</member>
<member name="interface/editor/override_online_docs_language" type="bool" setter="" getter="">
If [code]true[/code], the online docs will open in the language specified in [member interface/editor/online_docs_language]. If [code]false[/code], then the online docs will open in the default editor language specified in [member interface/editor/editor_language]. If the default editor language does not have an online translation, the English translation will be opened.
</member>
<member name="interface/editor/project_manager_screen" type="int" setter="" getter="">
The preferred monitor to display the project manager.
</member>
Expand Down
3 changes: 2 additions & 1 deletion editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3185,7 +3185,8 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
command_palette->open_popup();
} break;
case HELP_DOCS: {
OS::get_singleton()->shell_open(VERSION_DOCS_URL "/");
String doc_url = EditorSettings::get_singleton()->get_online_docs_url();
OS::get_singleton()->shell_open(doc_url);
} break;
case HELP_FORUM: {
OS::get_singleton()->shell_open("https://forum.godotengine.org/");
Expand Down
37 changes: 37 additions & 0 deletions editor/editor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,12 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
best = "en";
}

// These are the languages with a translation for the online docs
String docs_lang_hint = "en,cs,de,es,fr,it,ja,ko,pl,pt-br,ru,uk,zh-cn,zh-tw";

EDITOR_SETTING_USAGE(Variant::STRING, PROPERTY_HINT_ENUM, "interface/editor/editor_language", best, lang_hint, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
EDITOR_SETTING(Variant::BOOL, PROPERTY_HINT_NONE, "interface/editor/override_online_docs_language", false, "");
EDITOR_SETTING(Variant::STRING, PROPERTY_HINT_ENUM, "interface/editor/online_docs_language", "en", docs_lang_hint);
}

/* Interface */
Expand Down Expand Up @@ -1144,6 +1149,38 @@ void EditorSettings::setup_language() {
load_extractable_translations(lang);
}

String EditorSettings::get_online_docs_url() {
String language = EditorSettings::get_singleton()->get_setting("interface/editor/editor_language");
bool override = EditorSettings::get_singleton()->get_setting("interface/editor/override_online_docs_language");
String override_language = EditorSettings::get_singleton()->get_setting("interface/editor/online_docs_language");

Vector<String> doc_languages;
doc_languages.push_back("en");
doc_languages.push_back("cs");
doc_languages.push_back("de");
doc_languages.push_back("es");
doc_languages.push_back("fr");
doc_languages.push_back("it");
doc_languages.push_back("ja");
doc_languages.push_back("ko");
doc_languages.push_back("pl");
doc_languages.push_back("pt-br");
doc_languages.push_back("ru");
doc_languages.push_back("uk");
doc_languages.push_back("zh-cn");
doc_languages.push_back("zh-tw");

if (override && (doc_languages.find(override_language) > 0)) {
language = override_language;
} else if (!(doc_languages.find(language) > 0)) {
language = "en";
}

// The translated online docs only use version "4.x", not "4.3" or "latest" or "stable".
String version = (language == "en") ? VERSION_DOCS_BRANCH : "4.x";
return vformat(VERSION_DOCS_URL "/%s/%s/", language, version);
}

void EditorSettings::setup_network() {
List<IPAddress> local_ip;
IP::get_singleton()->get_local_addresses(&local_ip);
Expand Down
1 change: 1 addition & 0 deletions editor/editor_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class EditorSettings : public Resource {

static void create();
void setup_language();
String get_online_docs_url();
void setup_network();
static void save();
static void destroy();
Expand Down
3 changes: 2 additions & 1 deletion editor/export/project_export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,8 @@ void ProjectExportDialog::_enc_filters_changed(const String &p_filters) {
}

void ProjectExportDialog::_open_key_help_link() {
OS::get_singleton()->shell_open(vformat("%s/contributing/development/compiling/compiling_with_script_encryption_key.html", VERSION_DOCS_URL));
String doc_url = EditorSettings::get_singleton()->get_online_docs_url();
OS::get_singleton()->shell_open(vformat("%s/contributing/development/compiling/compiling_with_script_encryption_key.html", doc_url));
}

void ProjectExportDialog::_enc_pck_changed(bool p_pressed) {
Expand Down
6 changes: 4 additions & 2 deletions editor/plugins/script_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,12 +1367,14 @@ void ScriptEditor::_menu_option(int p_option) {
const HashMap<String, DocData::ClassDoc>::ConstIterator E = EditorHelp::get_doc_data()->class_list.find(eh->get_class());
native_class_doc = E && !E->value.is_script_doc;
}

String doc_url_base = EditorSettings::get_singleton()->get_online_docs_url();
if (native_class_doc) {
String name = eh->get_class().to_lower();
String doc_url = vformat(VERSION_DOCS_URL "/classes/class_%s.html", name);
String doc_url = vformat("%s/classes/class_%s.html", doc_url_base, name);
OS::get_singleton()->shell_open(doc_url);
} else {
OS::get_singleton()->shell_open(VERSION_DOCS_URL "/");
OS::get_singleton()->shell_open(doc_url_base);
}
} break;
case WINDOW_NEXT: {
Expand Down
3 changes: 2 additions & 1 deletion editor/plugins/text_shader_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,8 @@ void TextShaderEditor::_menu_option(int p_option) {
code_editor->remove_all_bookmarks();
} break;
case HELP_DOCS: {
OS::get_singleton()->shell_open(vformat("%s/tutorials/shaders/shader_reference/index.html", VERSION_DOCS_URL));
String doc_url = EditorSettings::get_singleton()->get_online_docs_url();
OS::get_singleton()->shell_open(vformat("%s/tutorials/shaders/shader_reference/index.html", doc_url));
} break;
}
if (p_option != SEARCH_FIND && p_option != SEARCH_REPLACE && p_option != SEARCH_GOTO_LINE) {
Expand Down

0 comments on commit 74cc6b5

Please sign in to comment.