Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

tooltip: Add "download" text to tooltips on files.

isakhagg9d291c9d3fb2
diff --git a/frontend_tests/node_tests/util.js b/frontend_tests/node_tests/util.js
index 11fab0fea67..cbb55440e1a 100644
--- a/frontend_tests/node_tests/util.js
+++ b/frontend_tests/node_tests/util.js
@@ -291,7 +291,7 @@ run_test("clean_user_content_links", () => {
'<a href="/#fragment" target="_blank">fragment</a>',
),
'<a href="http://example.com" target="_blank" rel="noopener noreferrer" title="http://example.com/">good</a> ' +
- '<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/file.png" target="_blank" rel="noopener noreferrer" title="file.png">upload</a> ' +
+ '<a href="http://zulip.zulipdev.com/user_uploads/w/ha/tever/file.png" target="_blank" rel="noopener noreferrer" title="translated: Download file.png">upload</a> ' +
"<a>invalid</a> " +
"<a>unsafe</a> " +
'<a href="/#fragment" title="http://zulip.zulipdev.com/#fragment">fragment</a>',
diff --git a/static/js/util.js b/static/js/util.js
index 82026568b9c..bdc5e5baaf8 100644
--- a/static/js/util.js
+++ b/static/js/util.js
@@ -1,5 +1,7 @@
import _ from "lodash";
+import {$t} from "./i18n";
+
// From MDN: https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Math/random
export function random_int(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
@@ -298,7 +300,14 @@ export function clean_user_content_links(html) {
let title;
let legacy_title;
if (url.origin === window.location.origin && url.pathname.startsWith("/user_uploads/")) {
- title = legacy_title = url.pathname.slice(url.pathname.lastIndexOf("/") + 1);
+ // We add the word "download" to make clear what will
+ // happen when clicking the file. This is particularly
+ // important in the desktop app, where hovering a URL does
+ // not display the URL like it does in the web app.
+ title = legacy_title = $t(
+ {defaultMessage: "Download {filename}"},
+ {filename: url.pathname.slice(url.pathname.lastIndexOf("/") + 1)},
+ );
} else {
title = url;
legacy_title = href;