Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
timestamp: Translate 'invalid time format' message on the frontend.
Rohitt Vashishtha088b8e28c38a
diff --git a/frontend_tests/node_tests/rendered_markdown.js b/frontend_tests/node_tests/rendered_markdown.jsindex 1352450a146..f2a5e2988ad 100644--- a/frontend_tests/node_tests/rendered_markdown.js+++ b/frontend_tests/node_tests/rendered_markdown.js@@ -69,6 +69,7 @@ const get_content_element = () => {$content.set_find_results('a.stream', $array([]));$content.set_find_results('a.stream-topic', $array([]));$content.set_find_results('time', $array([]));+ $content.set_find_results('span.timestamp-error', $array([]));$content.set_find_results('.emoji', $array([]));$content.set_find_results('div.spoiler-header', $array([]));return $content;@@ -177,6 +178,22 @@ run_test('timestamp', () => {assert.equal($timestamp_invalid.text(), 'translated: Could not parse timestamp.');});+run_test('timestamp-error', () => {+ // Setup+ const $content = get_content_element();+ const $timestamp_error = $.create('timestamp-error');+ $timestamp_error.text('Invalid time format: the-time-format');+ $content.set_find_results('span.timestamp-error', $array([$timestamp_error]));++ // Initial assert+ assert.equal($timestamp_error.text(), 'Invalid time format: the-time-format');++ rm.update_elements($content);++ // Final assert+ assert.equal($timestamp_error.text(), 'translated: Invalid time format: the-time-format');+});+run_test('emoji', () => {// Setupconst $content = get_content_element();diff --git a/static/js/rendered_markdown.js b/static/js/rendered_markdown.jsindex b4154b9a163..a5cefa1796d 100644--- a/static/js/rendered_markdown.js+++ b/static/js/rendered_markdown.js@@ -162,6 +162,12 @@ exports.update_elements = (content) => {}});+ content.find('span.timestamp-error').each(function () {+ const time_str = $(this).text().replace('Invalid time format: ', '');+ const text = i18n.t('Invalid time format: __timestamp__', { timestamp: time_str });+ $(this).text(text);+ });+content.find('div.spoiler-header').each(function () {// If a spoiler block has no header content, it should have a default header// We do this client side to allow for i18n by the client