Project

General

Profile

Defect #43906 » wiki-help-fix-for-locales-with-region-subtag.patch

Go MAEDA, 2026-03-25 04:31

View differences:

app/controllers/help_controller.rb
class HelpController < ApplicationController
def show_wiki_syntax
type = params[:type].nil? ? "" : "#{params[:type]}_"
lang = current_language.to_s
template = "help/wiki_syntax/#{Setting.text_formatting}/#{lang}/wiki_syntax_#{type}#{Setting.text_formatting}"
unless lookup_context.exists?(template)
lang = "en"
end
render template: "help/wiki_syntax/#{Setting.text_formatting}/#{lang}/wiki_syntax_#{type}#{Setting.text_formatting}", layout: nil
render template: wiki_syntax_template_for(params[:type]), layout: nil
end
def show_code_highlighting
@available_lexers = Rouge::Lexer.all.sort_by(&:tag)
render template: "help/wiki_syntax/code_highlighting_languages", layout: nil
end
private
def wiki_syntax_template_for(type)
# Region subtags are typically uppercase in locale tags (e.g., ta-IN),
# but some help templates use lowercase locale directories, so try both.
candidates = [current_language.to_s, current_language.to_s.downcase, "en"].uniq
template_name = "wiki_syntax_#{type.present? ? "#{type}_" : ""}#{Setting.text_formatting}"
candidates.each do |lang|
template = "help/wiki_syntax/#{Setting.text_formatting}/#{lang}/#{template_name}"
return template if lookup_context.exists?(template)
end
end
end
test/functional/help_controller_test.rb
assert_select 'h1', :text => "Wiki Syntax Schnellreferenz (CommonMark Markdown (GitHub Flavored))"
end
def test_get_help_wiki_syntax_should_fallback_to_lowercase_region_locale_directory
user = User.find(2)
user.language = 'ta-IN'
user.save!
@request.session[:user_id] = 2
with_settings :text_formatting => 'common_mark' do
get :show_wiki_syntax
end
assert_response :success
assert_select 'h1', :text => "விக்கி தொடரியல் விரைவு குறிப்பு (CommonMark Markdown (GitHub Flavored))"
end
def test_get_help_wiki_syntax_should_fallback_to_english
user = User.find(2)
user.language = 'ro'
user.save!
@request.session[:user_id] = 2
get :show_wiki_syntax
with_settings :text_formatting => 'common_mark' do
get :show_wiki_syntax
end
assert_response :success
assert_select 'h1', :text => "Wiki Syntax Quick Reference (CommonMark Markdown (GitHub Flavored))"
(1-1/2)