Project

General

Profile

Actions

Defect #39755

closed

CommonMark Markdown help page does not reflect user's language setting

Added by Go MAEDA 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Text formatting
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

Description

The CommonMark Markdown help should open the translated version if one exists, but in fact it always opens the English version.

Step to reproduce:

1. Change the text formatting to CommonMark markdown in Administration > Settings > General
2. Change the language to German in the "My account"
3. Open the issue creation page and click "[?]" in the toolbar

Expected Behavior:

The help should open in the selected interface language, which in this case is German.

Actual Behavior:

Despite the language setting being German and the file public/help/de/wiki_syntax_common_mark.html exists, the help page opens in English.


Files

39755.patch (3.18 KB) 39755.patch Go MAEDA, 2023-12-01 03:19

Related issues

Blocks Redmine - Patch #39751: Additional translation for Tamil languageNew

Actions
Actions #1

Updated by Go MAEDA 3 months ago

The cause of this issue is that the condition for unless in the following code (at source:tags/5.1.1/lib/redmine/wiki_formatting/common_mark/helper.rb#L29) always returns false. The leading slash in the path value of help_file variable causes the problem.

          help_file = "/help/#{current_language.to_s.downcase}/wiki_syntax_common_mark.html" 
          # fall back to the english help page if there is none for the current
          # language
          unless File.readable? Rails.public_path.join(help_file)
            help_file = "/help/en/wiki_syntax_common_mark.html" 
          end
          end

The following change fixes the issue.

diff --git a/lib/redmine/wiki_formatting/common_mark/helper.rb b/lib/redmine/wiki_formatting/common_mark/helper.rb
index 28e2fe10a..c14fe3f6a 100644
--- a/lib/redmine/wiki_formatting/common_mark/helper.rb
+++ b/lib/redmine/wiki_formatting/common_mark/helper.rb
@@ -23,13 +23,13 @@ module Redmine
       module Helper
         def wikitoolbar_for(field_id, preview_url = preview_text_path)
           heads_for_wiki_formatter
-          help_file = "/help/#{current_language.to_s.downcase}/wiki_syntax_common_mark.html" 
+          help_file = "help/#{current_language.to_s.downcase}/wiki_syntax_common_mark.html" 
           # fall back to the english help page if there is none for the current
           # language
-          unless File.readable? Rails.public_path.join(help_file)
-            help_file = "/help/en/wiki_syntax_common_mark.html" 
+          unless Rails.public_path.join(help_file).readable?
+            help_file = "help/en/wiki_syntax_common_mark.html" 
           end
-          url = "#{Redmine::Utils.relative_url_root}#{help_file}" 
+          url = File.join(Redmine::Utils.relative_url_root, help_file)
           javascript_tag(
             "var wikiToolbar = new jsToolBar(document.getElementById('#{field_id}')); " \
             "wikiToolbar.setHelpLink('#{escape_javascript url}'); " \
Actions #2

Updated by Go MAEDA 3 months ago

Here is a patch to fix the issue.

Actions #3

Updated by Go MAEDA 3 months ago

  • Blocks Patch #39751: Additional translation for Tamil language added
Actions #4

Updated by Go MAEDA 3 months ago

  • Target version set to 5.1.2

Setting the target version to 5.1.2.

Actions #5

Updated by Go MAEDA 3 months ago

  • Status changed from New to Resolved
  • Assignee set to Go MAEDA
  • Resolution set to Fixed

Committed the patch in r22496.

Actions #6

Updated by Go MAEDA 3 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF