Pārlūkot izejas kodu

Merge pull request #105519 from KoBeWi/translation_library

Improve AssetLib auto-translation
Thaddeus Crews 3 mēneši atpakaļ
vecāks
revīzija
df3485812a

+ 16 - 16
editor/editor_asset_installer.cpp

@@ -428,7 +428,7 @@ void EditorAssetInstaller::_check_has_toplevel() {
 	toplevel_prefix = "";
 	skip_toplevel_check->set_pressed(false);
 	skip_toplevel_check->set_disabled(true);
-	skip_toplevel_check->set_tooltip_text(TTR("This asset doesn't have a root directory, so it can't be ignored."));
+	skip_toplevel_check->set_tooltip_text(TTRC("This asset doesn't have a root directory, so it can't be ignored."));
 
 	if (asset_files.is_empty()) {
 		return;
@@ -453,7 +453,7 @@ void EditorAssetInstaller::_check_has_toplevel() {
 
 	toplevel_prefix = first_asset;
 	skip_toplevel_check->set_disabled(false);
-	skip_toplevel_check->set_tooltip_text(TTR("Ignore the root directory when extracting files."));
+	skip_toplevel_check->set_tooltip_text(TTRC("Ignore the root directory when extracting files."));
 }
 
 void EditorAssetInstaller::_set_skip_toplevel(bool p_checked) {
@@ -471,7 +471,7 @@ void EditorAssetInstaller::_open_target_dir_dialog() {
 	if (!target_dir_dialog) {
 		target_dir_dialog = memnew(EditorFileDialog);
 		target_dir_dialog->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
-		target_dir_dialog->set_title(TTR("Select Install Folder"));
+		target_dir_dialog->set_title(TTRC("Select Install Folder"));
 		target_dir_dialog->set_current_dir(target_dir_path);
 		target_dir_dialog->connect("dir_selected", callable_mp(this, &EditorAssetInstaller::_target_dir_selected));
 		add_child(target_dir_dialog);
@@ -578,7 +578,7 @@ void EditorAssetInstaller::_install_asset() {
 		}
 	} else {
 		if (EditorNode::get_singleton() != nullptr) {
-			EditorNode::get_singleton()->show_warning(vformat(TTR("Asset \"%s\" installed successfully!"), asset_name), TTR("Success!"));
+			EditorNode::get_singleton()->show_warning(vformat(TTR("Asset \"%s\" installed successfully!"), asset_name), TTRC("Success!"));
 		}
 	}
 
@@ -669,7 +669,7 @@ EditorAssetInstaller::EditorAssetInstaller() {
 	vb->add_child(asset_status);
 
 	Label *asset_label = memnew(Label);
-	asset_label->set_text(TTR("Asset:"));
+	asset_label->set_text(TTRC("Asset:"));
 	asset_label->set_theme_type_variation("HeaderSmall");
 	asset_status->add_child(asset_label);
 
@@ -684,22 +684,22 @@ EditorAssetInstaller::EditorAssetInstaller() {
 
 	show_source_files_button = memnew(Button);
 	show_source_files_button->set_toggle_mode(true);
-	show_source_files_button->set_tooltip_text(TTR("Open the list of the asset contents and select which files to install."));
+	show_source_files_button->set_tooltip_text(TTRC("Open the list of the asset contents and select which files to install."));
 	show_source_files_button->set_accessibility_name(TTRC("Show Asset Contents"));
 	remapping_tools->add_child(show_source_files_button);
 	show_source_files_button->connect(SceneStringName(toggled), callable_mp(this, &EditorAssetInstaller::_toggle_source_tree).bind(false));
 
 	Button *target_dir_button = memnew(Button);
-	target_dir_button->set_text(TTR("Change Install Folder"));
-	target_dir_button->set_tooltip_text(TTR("Change the folder where the contents of the asset are going to be installed."));
+	target_dir_button->set_text(TTRC("Change Install Folder"));
+	target_dir_button->set_tooltip_text(TTRC("Change the folder where the contents of the asset are going to be installed."));
 	remapping_tools->add_child(target_dir_button);
 	target_dir_button->connect(SceneStringName(pressed), callable_mp(this, &EditorAssetInstaller::_open_target_dir_dialog));
 
 	remapping_tools->add_child(memnew(VSeparator));
 
 	skip_toplevel_check = memnew(CheckBox);
-	skip_toplevel_check->set_text(TTR("Ignore asset root"));
-	skip_toplevel_check->set_tooltip_text(TTR("Ignore the root directory when extracting files."));
+	skip_toplevel_check->set_text(TTRC("Ignore asset root"));
+	skip_toplevel_check->set_tooltip_text(TTRC("Ignore the root directory when extracting files."));
 	skip_toplevel_check->connect(SceneStringName(toggled), callable_mp(this, &EditorAssetInstaller::_set_skip_toplevel));
 	remapping_tools->add_child(skip_toplevel_check);
 
@@ -708,13 +708,13 @@ EditorAssetInstaller::EditorAssetInstaller() {
 	asset_conflicts_label = memnew(Label);
 	asset_conflicts_label->set_focus_mode(Control::FOCUS_ACCESSIBILITY);
 	asset_conflicts_label->set_theme_type_variation("HeaderSmall");
-	asset_conflicts_label->set_text(TTR("No files conflict with your project"));
+	asset_conflicts_label->set_text(TTRC("No files conflict with your project"));
 	remapping_tools->add_child(asset_conflicts_label);
 	asset_conflicts_link = memnew(LinkButton);
 	asset_conflicts_link->set_accessibility_name(TTRC("Show Conflicting Files"));
 	asset_conflicts_link->set_theme_type_variation("HeaderSmallLink");
 	asset_conflicts_link->set_v_size_flags(Control::SIZE_SHRINK_CENTER);
-	asset_conflicts_link->set_tooltip_text(TTR("Show contents of the asset and conflicting files."));
+	asset_conflicts_link->set_tooltip_text(TTRC("Show contents of the asset and conflicting files."));
 	asset_conflicts_link->set_visible(false);
 	remapping_tools->add_child(asset_conflicts_link);
 	asset_conflicts_link->connect(SceneStringName(pressed), callable_mp(this, &EditorAssetInstaller::_toggle_source_tree).bind(true, true));
@@ -731,7 +731,7 @@ EditorAssetInstaller::EditorAssetInstaller() {
 	tree_split->add_child(source_tree_vb);
 
 	Label *source_tree_label = memnew(Label);
-	source_tree_label->set_text(TTR("Contents of the asset:"));
+	source_tree_label->set_text(TTRC("Contents of the asset:"));
 	source_tree_label->set_theme_type_variation("HeaderSmall");
 	source_tree_vb->add_child(source_tree_label);
 
@@ -748,7 +748,7 @@ EditorAssetInstaller::EditorAssetInstaller() {
 	tree_split->add_child(destination_tree_vb);
 
 	Label *destination_tree_label = memnew(Label);
-	destination_tree_label->set_text(TTR("Installation preview:"));
+	destination_tree_label->set_text(TTRC("Installation preview:"));
 	destination_tree_label->set_theme_type_variation("HeaderSmall");
 	destination_tree_vb->add_child(destination_tree_label);
 
@@ -761,7 +761,7 @@ EditorAssetInstaller::EditorAssetInstaller() {
 
 	// Dialog configuration.
 
-	set_title(TTR("Configure Asset Before Installing"));
-	set_ok_button_text(TTR("Install"));
+	set_title(TTRC("Configure Asset Before Installing"));
+	set_ok_button_text(TTRC("Install"));
 	set_hide_on_ok(true);
 }

+ 50 - 44
editor/plugins/asset_library_editor_plugin.cpp

@@ -161,7 +161,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem(bool p_clickable) {
 	vb->add_child(author_price_hbox);
 
 	author = memnew(LinkButton);
-	author->set_tooltip_text(TTR("Author"));
+	author->set_tooltip_text(TTRC("Author"));
 	author->set_accessibility_name(TTRC("Author"));
 	author_price_hbox->add_child(author);
 
@@ -188,7 +188,7 @@ EditorAssetLibraryItem::EditorAssetLibraryItem(bool p_clickable) {
 	price = memnew(Label);
 	price->set_focus_mode(FOCUS_ACCESSIBILITY);
 	price->add_theme_style_override(CoreStringName(normal), label_margin);
-	price->set_tooltip_text(TTR("License"));
+	price->set_tooltip_text(TTRC("License"));
 	price->set_accessibility_name(TTRC("License"));
 	price->set_mouse_filter(MOUSE_FILTER_PASS);
 
@@ -365,8 +365,8 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
 	preview_hb->set_v_size_flags(Control::SIZE_EXPAND_FILL);
 
 	previews->add_child(preview_hb);
-	set_ok_button_text(TTR("Download"));
-	set_cancel_button_text(TTR("Close"));
+	set_ok_button_text(TTRC("Download"));
+	set_cancel_button_text(TTRC("Close"));
 }
 
 ///////////////////////////////////////////////////////////////////////////////////
@@ -379,37 +379,37 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int
 		case HTTPRequest::RESULT_CONNECTION_ERROR:
 		case HTTPRequest::RESULT_BODY_SIZE_LIMIT_EXCEEDED: {
 			error_text = TTR("Connection error, please try again.");
-			status->set_text(TTR("Can't connect."));
+			status->set_text(TTRC("Can't connect."));
 		} break;
 		case HTTPRequest::RESULT_CANT_CONNECT:
 		case HTTPRequest::RESULT_TLS_HANDSHAKE_ERROR: {
 			error_text = TTR("Can't connect to host:") + " " + host;
-			status->set_text(TTR("Can't connect."));
+			status->set_text(TTRC("Can't connect."));
 		} break;
 		case HTTPRequest::RESULT_NO_RESPONSE: {
 			error_text = TTR("No response from host:") + " " + host;
-			status->set_text(TTR("No response."));
+			status->set_text(TTRC("No response."));
 		} break;
 		case HTTPRequest::RESULT_CANT_RESOLVE: {
 			error_text = TTR("Can't resolve hostname:") + " " + host;
-			status->set_text(TTR("Can't resolve."));
+			status->set_text(TTRC("Can't resolve."));
 		} break;
 		case HTTPRequest::RESULT_REQUEST_FAILED: {
 			error_text = TTR("Request failed, return code:") + " " + itos(p_code);
-			status->set_text(TTR("Request failed."));
+			status->set_text(TTRC("Request failed."));
 		} break;
 		case HTTPRequest::RESULT_DOWNLOAD_FILE_CANT_OPEN:
 		case HTTPRequest::RESULT_DOWNLOAD_FILE_WRITE_ERROR: {
 			error_text = TTR("Cannot save response to:") + " " + download->get_download_file();
-			status->set_text(TTR("Write error."));
+			status->set_text(TTRC("Write error."));
 		} break;
 		case HTTPRequest::RESULT_REDIRECT_LIMIT_REACHED: {
 			error_text = TTR("Request failed, too many redirects");
-			status->set_text(TTR("Redirect loop."));
+			status->set_text(TTRC("Redirect loop."));
 		} break;
 		case HTTPRequest::RESULT_TIMEOUT: {
 			error_text = TTR("Request failed, timeout");
-			status->set_text(TTR("Timeout."));
+			status->set_text(TTRC("Timeout."));
 		} break;
 		default: {
 			if (p_code != 200) {
@@ -420,7 +420,7 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int
 				if (sha256 != download_sha256) {
 					error_text = TTR("Bad download hash, assuming file has been tampered with.") + "\n";
 					error_text += TTR("Expected:") + " " + sha256 + "\n" + TTR("Got:") + " " + download_sha256;
-					status->set_text(TTR("Failed SHA-256 hash check"));
+					status->set_text(TTRC("Failed SHA-256 hash check"));
 				}
 			}
 		} break;
@@ -439,7 +439,7 @@ void EditorAssetLibraryItemDownload::_http_download_completed(int p_status, int
 	}
 
 	install_button->set_disabled(false);
-	status->set_text(TTR("Ready to install!"));
+	status->set_text(TTRC("Ready to install!"));
 
 	set_process(false);
 
@@ -496,17 +496,17 @@ void EditorAssetLibraryItemDownload::_notification(int p_what) {
 			if (cstatus != prev_status) {
 				switch (cstatus) {
 					case HTTPClient::STATUS_RESOLVING: {
-						status->set_text(TTR("Resolving..."));
+						status->set_text(TTRC("Resolving..."));
 						progress->set_max(1);
 						progress->set_value(0);
 					} break;
 					case HTTPClient::STATUS_CONNECTING: {
-						status->set_text(TTR("Connecting..."));
+						status->set_text(TTRC("Connecting..."));
 						progress->set_max(1);
 						progress->set_value(0);
 					} break;
 					case HTTPClient::STATUS_REQUESTING: {
-						status->set_text(TTR("Requesting..."));
+						status->set_text(TTRC("Requesting..."));
 						progress->set_max(1);
 						progress->set_value(0);
 					} break;
@@ -550,7 +550,7 @@ void EditorAssetLibraryItemDownload::_make_request() {
 
 	Error err = download->request(host);
 	if (err != OK) {
-		status->set_text(TTR("Error making request"));
+		status->set_text(TTRC("Error making request"));
 	} else {
 		progress->set_indeterminate(true);
 		set_process(true);
@@ -592,7 +592,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
 
 	vb->add_spacer();
 
-	status = memnew(Label(TTR("Idle")));
+	status = memnew(Label(TTRC("Idle")));
 	vb->add_child(status);
 	progress = memnew(ProgressBar);
 	progress->set_editor_preview_indeterminate(true);
@@ -603,12 +603,12 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
 	hb2->add_spacer();
 
 	install_button = memnew(Button);
-	install_button->set_text(TTR("Install..."));
+	install_button->set_text(TTRC("Install..."));
 	install_button->set_disabled(true);
 	install_button->connect(SceneStringName(pressed), callable_mp(this, &EditorAssetLibraryItemDownload::install));
 
 	retry_button = memnew(Button);
-	retry_button->set_text(TTR("Retry"));
+	retry_button->set_text(TTRC("Retry"));
 	retry_button->connect(SceneStringName(pressed), callable_mp(this, &EditorAssetLibraryItemDownload::_make_request));
 	// Only show the Retry button in case of a failure.
 	retry_button->hide();
@@ -624,7 +624,7 @@ EditorAssetLibraryItemDownload::EditorAssetLibraryItemDownload() {
 
 	download_error = memnew(AcceptDialog);
 	panel->add_child(download_error);
-	download_error->set_title(TTR("Download Error"));
+	download_error->set_title(TTRC("Download Error"));
 
 	asset_installer = memnew(EditorAssetInstaller);
 	panel->add_child(asset_installer);
@@ -643,6 +643,12 @@ void EditorAssetLibrary::_notification(int p_what) {
 			error_label->move_to_front();
 		} break;
 
+		case NOTIFICATION_TRANSLATION_CHANGED: {
+			if (!initial_loading) {
+				_rerun_search(-1);
+			}
+		} break;
+
 		case NOTIFICATION_THEME_CHANGED: {
 			error_tr->set_texture(get_editor_theme_icon(SNAME("Error")));
 			filter->set_right_icon(get_editor_theme_icon(SNAME("Search")));
@@ -1036,7 +1042,7 @@ void EditorAssetLibrary::_request_image(ObjectID p_for, int p_asset_id, String p
 }
 
 void EditorAssetLibrary::_repository_changed(int p_repository_id) {
-	_set_library_message(TTR("Loading..."));
+	_set_library_message(TTRC("Loading..."));
 
 	asset_top_page->hide();
 	asset_bottom_page->hide();
@@ -1211,7 +1217,7 @@ void EditorAssetLibrary::_api_request(const String &p_request, RequestType p_req
 	error_hb->hide();
 
 	if (loading_blocked) {
-		_set_library_message_with_action(TTR("The Asset Library requires an online connection and involves sending data over the internet."), TTR("Go Online"), callable_mp(this, &EditorAssetLibrary::_force_online_mode));
+		_set_library_message_with_action(TTRC("The Asset Library requires an online connection and involves sending data over the internet."), TTRC("Go Online"), callable_mp(this, &EditorAssetLibrary::_force_online_mode));
 		return;
 	}
 
@@ -1243,7 +1249,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
 			error_label->set_text(TTR("Request failed, return code:") + " " + itos(p_code));
 		} break;
 		case HTTPRequest::RESULT_REDIRECT_LIMIT_REACHED: {
-			error_label->set_text(TTR("Request failed, too many redirects"));
+			error_label->set_text(TTRC("Request failed, too many redirects"));
 
 		} break;
 		default: {
@@ -1257,7 +1263,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
 
 	if (error_abort) {
 		if (requesting == REQUESTING_CONFIG) {
-			_set_library_message_with_action(TTR("Failed to get repository configuration."), TTR("Retry"), callable_mp(this, &EditorAssetLibrary::_request_current_config));
+			_set_library_message_with_action(TTRC("Failed to get repository configuration."), TTRC("Retry"), callable_mp(this, &EditorAssetLibrary::_request_current_config));
 		}
 		error_hb->show();
 		return;
@@ -1276,7 +1282,7 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
 	switch (requested) {
 		case REQUESTING_CONFIG: {
 			categories->clear();
-			categories->add_item(TTR("All"));
+			categories->add_item(TTRC("All"));
 			categories->set_item_metadata(0, 0);
 			if (d.has("categories")) {
 				Array clist = d["categories"];
@@ -1436,14 +1442,14 @@ void EditorAssetLibrary::_http_request_completed(int p_status, int p_code, const
 			EditorAssetLibraryItemDownload *download_item = _get_asset_in_progress(description->get_asset_id());
 			if (download_item) {
 				if (download_item->can_install()) {
-					description->set_ok_button_text(TTR("Install"));
+					description->set_ok_button_text(TTRC("Install"));
 					description->get_ok_button()->set_disabled(false);
 				} else {
-					description->set_ok_button_text(TTR("Downloading..."));
+					description->set_ok_button_text(TTRC("Downloading..."));
 					description->get_ok_button()->set_disabled(true);
 				}
 			} else {
-				description->set_ok_button_text(TTR("Download"));
+				description->set_ok_button_text(TTRC("Download"));
 				description->get_ok_button()->set_disabled(false);
 			}
 
@@ -1596,9 +1602,9 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
 
 	filter = memnew(LineEdit);
 	if (templates_only) {
-		filter->set_placeholder(TTR("Search Templates, Projects, and Demos"));
+		filter->set_placeholder(TTRC("Search Templates, Projects, and Demos"));
 	} else {
-		filter->set_placeholder(TTR("Search Assets (Excluding Templates, Projects, and Demos)"));
+		filter->set_placeholder(TTRC("Search Assets (Excluding Templates, Projects, and Demos)"));
 	}
 	filter->set_clear_button_enabled(true);
 	search_hb->add_child(filter);
@@ -1618,12 +1624,12 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
 	}
 
 	Button *open_asset = memnew(Button);
-	open_asset->set_text(TTR("Import..."));
+	open_asset->set_text(TTRC("Import..."));
 	search_hb->add_child(open_asset);
 	open_asset->connect(SceneStringName(pressed), callable_mp(this, &EditorAssetLibrary::_asset_open));
 
 	Button *plugins = memnew(Button);
-	plugins->set_text(TTR("Plugins..."));
+	plugins->set_text(TTRC("Plugins..."));
 	search_hb->add_child(plugins);
 	plugins->connect(SceneStringName(pressed), callable_mp(this, &EditorAssetLibrary::_manage_plugins));
 
@@ -1635,10 +1641,10 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
 	HBoxContainer *search_hb2 = memnew(HBoxContainer);
 	library_main->add_child(search_hb2);
 
-	search_hb2->add_child(memnew(Label(TTR("Sort:") + " ")));
+	search_hb2->add_child(memnew(Label(TTRC("Sort:"))));
 	sort = memnew(OptionButton);
 	for (int i = 0; i < SORT_MAX; i++) {
-		sort->add_item(TTRGET(sort_text[i]));
+		sort->add_item(sort_text[i]);
 	}
 
 	search_hb2->add_child(sort);
@@ -1649,9 +1655,9 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
 
 	search_hb2->add_child(memnew(VSeparator));
 
-	search_hb2->add_child(memnew(Label(TTR("Category:") + " ")));
+	search_hb2->add_child(memnew(Label(TTRC("Category:"))));
 	categories = memnew(OptionButton);
-	categories->add_item(TTR("All"));
+	categories->add_item(TTRC("All"));
 	search_hb2->add_child(categories);
 	categories->set_h_size_flags(Control::SIZE_EXPAND_FILL);
 	categories->set_clip_text(true);
@@ -1659,7 +1665,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
 
 	search_hb2->add_child(memnew(VSeparator));
 
-	search_hb2->add_child(memnew(Label(TTR("Site:") + " ")));
+	search_hb2->add_child(memnew(Label(TTRC("Site:"))));
 	repository = memnew(OptionButton);
 
 	_update_repository_options();
@@ -1674,11 +1680,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
 
 	support = memnew(MenuButton);
 	search_hb2->add_child(support);
-	support->set_text(TTR("Support"));
+	support->set_text(TTRC("Support"));
 	support->get_popup()->set_hide_on_checkable_item_selection(false);
-	support->get_popup()->add_check_item(TTRGET(support_text[SUPPORT_FEATURED]), SUPPORT_FEATURED);
-	support->get_popup()->add_check_item(TTRGET(support_text[SUPPORT_COMMUNITY]), SUPPORT_COMMUNITY);
-	support->get_popup()->add_check_item(TTRGET(support_text[SUPPORT_TESTING]), SUPPORT_TESTING);
+	support->get_popup()->add_check_item(support_text[SUPPORT_FEATURED], SUPPORT_FEATURED);
+	support->get_popup()->add_check_item(support_text[SUPPORT_COMMUNITY], SUPPORT_COMMUNITY);
+	support->get_popup()->add_check_item(support_text[SUPPORT_TESTING], SUPPORT_TESTING);
 	support->get_popup()->set_item_checked(SUPPORT_FEATURED, true);
 	support->get_popup()->set_item_checked(SUPPORT_COMMUNITY, true);
 	support->get_popup()->connect(SceneStringName(id_pressed), callable_mp(this, &EditorAssetLibrary::_support_toggled));
@@ -1767,7 +1773,7 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) {
 	asset_open = memnew(EditorFileDialog);
 
 	asset_open->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
-	asset_open->add_filter("*.zip", TTR("Assets ZIP File"));
+	asset_open->add_filter("*.zip", TTRC("Assets ZIP File"));
 	asset_open->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_FILE);
 	add_child(asset_open);
 	asset_open->connect("file_selected", callable_mp(this, &EditorAssetLibrary::_asset_file_selected));