fix: make translation for link field value irrespective of user permissions only if the source doctype is in translated doctypes (#35803)

Co-authored-by: sudarshan-g <sudarshan@cliniexperts.com>
This commit is contained in:
Sudarshan 2026-02-20 10:41:41 +05:30 committed by GitHub
parent fef9d89ce0
commit e9e90a68b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -164,6 +164,7 @@ frappe.form.formatters = {
return `<input type="checkbox" disabled
class="disabled-${value ? "selected" : "deselected"}">`;
},
Link: function (value, docfield, options, doc) {
var doctype = docfield._options || docfield.options;
var original_value = value;
@ -178,7 +179,7 @@ frappe.form.formatters = {
}
if (options && (options.for_print || options.only_value)) {
return link_title || value;
return get_link_display_value(doctype, link_title, value);
}
if (frappe.form.link_formatters[doctype]) {
@ -211,10 +212,10 @@ frappe.form.formatters = {
a.innerText = __((options && options.label) || link_title || value);
return a.outerHTML;
} else {
return link_title || value;
return get_link_display_value(doctype, link_title, value);
}
} else {
return link_title || value;
return get_link_display_value(doctype, link_title, value);
}
},
Date: function (value) {
@ -407,6 +408,13 @@ frappe.form.formatters = {
AttachImage: format_attachment_url,
};
function get_link_display_value(doctype, link_title, value) {
let translated_doctypes = frappe.boot?.translated_doctypes || [];
if (translated_doctypes.includes(doctype)) {
return __(link_title || value);
}
return link_title || value;
}
function format_attachment_url(url) {
return url ? `<a href="${url}" target="_blank">${url}</a>` : "";
}