Repository: godotengine/godot
File: editor/script/script_text_editor.cpp (C++)

Code before:

Variant ScriptTextEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) {
	return Variant();
}

bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const {
	Dictionary d = p_data;
	if (d.has("type") &&
			(String(d["type"]) == "resource" ||
					String(d["type"]) == "files" ||
					String(d["type"]) == "nodes" ||
					String(d["type"]) == "obj_property" ||
					String(d["type"]) == "files_and_dirs")) {
		set_drop_info_text(d);
		return true;
	}

	return false;
}

void ScriptTextEditor::set_drop_info_text(const Dictionary &p_info) const {
	String text;
	String c = keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL);

	static const String single_resource_text = TTR("Drag and drop to copy the file path into the script.") +
			"\n" + TTR("Hold " + c + " when dropping to add a const var, preloading the resource at that path.") +
			"\n" + TTR("Hold Shift to alter between referencing the resource by uid/file path.") +
			"\n" + TTR("Hold Alt when dropping to add an @export var pointing to the resource.");

	static const String multiple_resources_text = TTR("Drag and drop to copy the file paths into the script.") +
			"\n" + TTR("Hold " + c + " when dropping to add const vars, preloading the resources at those paths.") +
			"\n" + TTR("Hold Shift to alter between referencing the resources by uid/file path.") +
			"\n" + TTR("Hold Alt when dropping to add @export vars pointing to the resources.");

	static const String single_nodes_text = TTR("Drag and drop to copy the node path to the script.") +
			"\n" + TTR("Hold " + c + " when dropping to add an @onready var pointing to the node path.") +
			"\n" + TTR("Hold Alt when dropping to add an @export var pointing to the node.");

	static const String multiple_nodes_text = TTR("Drag and drop to copy the node paths to the script.") +
			"\n" + TTR("Hold " + c + " when dropping to add @onready vars pointing to the node paths.") +
			"\n" + TTR("Hold Alt when dropping to add @export vars pointing to the nodes.");

	String type = String(p_info["type"]);

	if (type == "files" || type == "files_and_dirs") {
		Array files = p_info["files"];
		text = files.size() > 1 ? multiple_resources_text : single_resource_text;
	} else if (type == "nodes") {
		Array nodes = p_info["nodes"];
		text = nodes.size() > 1 ? multiple_nodes_text : single_nodes_text;
	} else if (type == "resource") {

Review comment (refactor):
```suggestion
			"\n" + vformat(TTR("Hold %s when dropping to add a const var, preloading the resource at that path."), c) +
```
Can't use expressions in `TTR` as it's extracted and shouldn't be dynamic 

Code after:
					continue;
				}

				bool is_unique = node->is_unique_name_in_owner() && (node->get_owner() == sn || node->get_owner() == sn->get_owner());
				String path = is_unique ? String(node->get_name()) : String(sn->get_path_to(node));
				for (const String &segment : path.split("/")) {
					if (!segment.is_valid_unicode_identifier()) {
						path = _quote_drop_data(path);
						break;
					}
				}

				String variable_name = String(node->get_name()).to_snake_case().validate_unicode_identifier();
				if (use_type) {
					StringName custom_class_name;
					Ref<Script> node_script = node->get_script();
					while (node_script.is_valid() && custom_class_name.is_empty()) {
						custom_class_name = node_script->get_global_name();
						node_script = node_script->get_base_script();
					}
					const StringName class_name = custom_class_name.is_empty() ? node->get_class_name() : custom_class_name;
					text_to_drop += vformat("@onready var %s: %s = %c%s", variable_name, class_name, is_unique ? '%' : '$', path);
				} else {
					text_to_drop += vformat("@onready var %s = %c%s", variable_name, is_unique ? '%' : '$', path);
				}
				if (i < nodes.size() - 1) {
					text_to_drop += "\n";
				}
			}

			if (is_empty_line || drop_at_column == 0) {
				text_to_drop += "\n";
			}
		} else if (export_drop_modifier_pressed) {
			Vector<ObjectID> obj_ids = _get_objects_for_export_assignment();

			for (int i = 0; i < nodes.size(); i++) {
				NodePath np = nodes[i];
				Node *node = get_node(np);
				if (!node) {
					continue;
				}

				String variable_name = String(node->get_name()).to_snake_case().validate_unicode_identifier();
				StringName class_name = node->get_class_name();
				Ref<Script> node_script = node->get_script();
				if (node_script.is_valid()) {
					StringName global_node_script_name = node_script->get_global_name();
					if (!global_node_script_name.is_empty()) {
						class_name = global_node_script_name;
					}