OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Allow to specify whether links will be underlined
Jan Sandbrinkf7db89bf78fe
diff --git a/lib_static/redmine/i18n.rb b/lib_static/redmine/i18n.rbindex f51eef30427..3cef0e4e84b 100644--- a/lib_static/redmine/i18n.rb+++ b/lib_static/redmine/i18n.rb@@ -112,7 +112,8 @@ module Redmine# @param i18n_key [String] The I18n key to translate.# @param links [Hash] Link names mapped to URLs.# @param target [String] optional HTML target attribute for the links.- def link_translate(i18n_key, links: {}, locale: ::I18n.locale, target: nil)+ # @param underline [Boolean] Whether to underline links inserted into the text (default: true)+ def link_translate(i18n_key, links: {}, locale: ::I18n.locale, target: nil, underline: true)translation = ::I18n.t(i18n_key.to_s, locale:)result = translation.scan(link_regex).inject(translation) do |t, matches|link, text, key = matches@@ -123,7 +124,7 @@ module RedmineelseString(link_reference)end- link_tag = render(Primer::Beta::Link.new(href:, target:)) { text }+ link_tag = render(Primer::Beta::Link.new(href:, target:, underline:)) { text }t.sub(link, link_tag)enddiff --git a/spec/lib/redmine/i18n_spec.rb b/spec/lib/redmine/i18n_spec.rbindex 08ab7f6175b..a5effa7d76a 100644--- a/spec/lib/redmine/i18n_spec.rb+++ b/spec/lib/redmine/i18n_spec.rb@@ -188,7 +188,7 @@ module OpenProjectdescribe "link_translation" dolet(:locale) { :en }let(:urls) do- { url_1: "http://openproject.com/foobar", url_2: "/baz" }+ { url_1: "http://openproject.com/foo", url_2: "/baz" }endbefore do@@ -202,8 +202,8 @@ module OpenProjecttranslated = link_translate :translation_with_a_link, links: urlsexpect(translated).to eq(- 'There is a <a href="http://openproject.com/foobar" data-view-component="true" class="Link">link</a> in this' +- ' translation! Maybe even <a href="/baz" data-view-component="true" class="Link">two</a>?'+ 'There is a <a href="http://openproject.com/foo" data-view-component="true" class="Link Link--underline">link</a>' ++ ' in this translation! Maybe even <a href="/baz" data-view-component="true" class="Link Link--underline">two</a>?')end@@ -214,8 +214,8 @@ module OpenProjecttranslated = link_translate(:translation_with_a_link, links: urls, locale:)expect(translated).to eq(- 'There is a <a href="http://openproject.com/foobar" data-view-component="true" class="Link">link</a> in this' +- ' translation! Maybe even <a href="/baz" data-view-component="true" class="Link">two</a>?'+ 'There is a <a href="http://openproject.com/foo" data-view-component="true" class="Link Link--underline">link</a>' ++ ' in this translation! Maybe even <a href="/baz" data-view-component="true" class="Link Link--underline">two</a>?')expect(I18n).to have_received(:t).with(anything, locale:)end@@ -236,8 +236,8 @@ module OpenProjecttranslated = link_translate :translation_with_a_link, links: urlsexpect(translated).to eq(- 'There is a <a href="https://example.com/a-b" data-view-component="true" class="Link">link</a> in this' +- ' translation! Maybe even <a href="/a-c" data-view-component="true" class="Link">two</a>?'+ 'There is a <a href="https://example.com/a-b" data-view-component="true" class="Link Link--underline">link</a>' ++ ' in this translation! Maybe even <a href="/a-c" data-view-component="true" class="Link Link--underline">two</a>?')endend