diff options
author | Go MAEDA <maeda@farend.jp> | 2020-09-10 07:19:21 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2020-09-10 07:19:21 +0000 |
commit | 58eca8190e22e0c0ca83386ebea49b07c05dc0e1 (patch) | |
tree | b96a3ae46ae2b22fb32be2d3877da39871603f4f /lib/redmine/wiki_formatting | |
parent | d0c3f59f6f08996b9415108927ec053e9a45dd50 (diff) | |
download | redmine-58eca8190e22e0c0ca83386ebea49b07c05dc0e1.tar.gz redmine-58eca8190e22e0c0ca83386ebea49b07c05dc0e1.zip |
Internationalize error messages for wiki macros (#33426).
Patch by Go MAEDA.
git-svn-id: http://svn.redmine.org/redmine/trunk@20013 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine/wiki_formatting')
-rw-r--r-- | lib/redmine/wiki_formatting/macros.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb index c34e404e2..03eeecde9 100644 --- a/lib/redmine/wiki_formatting/macros.rb +++ b/lib/redmine/wiki_formatting/macros.rb @@ -45,12 +45,12 @@ module Redmine if self.class.instance_method(method_name).arity == 3 send(method_name, obj, args, text) elsif text - raise "This macro does not accept a block of text" + raise t(:error_macro_does_not_accept_block) else send(method_name, obj, args) end rescue => e - "<div class=\"flash error\">Error executing the <strong>#{h name}</strong> macro (#{h e.to_s})</div>".html_safe + %|<div class="flash error">#{t(:error_can_not_execute_macro_html, :name => name, :error => e.to_s)}</div>|.html_safe end end @@ -152,10 +152,10 @@ module Redmine def macro(name, options={}, &block) options.assert_valid_keys(:desc, :parse_args) unless /\A\w+\z/.match?(name.to_s) - raise "Invalid macro name: #{name} (only 0-9, A-Z, a-z and _ characters are accepted)" + raise t(:error_invalid_macro_name, :name => name) end unless block_given? - raise "Can not create a macro without a block!" + raise t(:error_can_not_create_macro_without_block) end name = name.to_s.downcase.to_sym available_macros[name] = {:desc => @@desc || ''}.merge(options) @@ -204,9 +204,9 @@ module Redmine elsif obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version) page = obj.page else - raise 'With no argument, this macro can be called from wiki pages only.' + raise t(:error_childpages_macro_no_argument) end - raise 'Page not found' if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project) + raise t(:error_page_not_found) if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project) pages = page.self_and_descendants(options[:depth]).group_by(&:parent_id) render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id) end @@ -216,9 +216,9 @@ module Redmine "{{include(projectname:Foo)}} -- to include a page of a specific project wiki" macro :include do |obj, args| page = Wiki.find_page(args.first.to_s, :project => @project) - raise 'Page not found' if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project) + raise t(:error_page_not_found) if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project) @included_wiki_pages ||= [] - raise 'Circular inclusion detected' if @included_wiki_pages.include?(page.id) + raise t(:error_circular_inclusion) if @included_wiki_pages.include?(page.id) @included_wiki_pages << page.id out = textilizable(page.content, :text, :attachments => page.attachments, :headings => false, :inline_attachments => @@inline_attachments) @included_wiki_pages.pop @@ -247,9 +247,9 @@ module Redmine macro :thumbnail do |obj, args| args, options = extract_macro_options(args, :size, :title) filename = args.first - raise 'Filename required' unless filename.present? + raise t(:error_filename_required) unless filename.present? size = options[:size] - raise 'Invalid size parameter' unless size.nil? || /^\d+$/.match?(size) + raise t(:error_invalid_size_parameter) unless size.nil? || /^\d+$/.match?(size) size = size.to_i size = 200 unless size > 0 if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename) @@ -260,7 +260,7 @@ module Redmine img = image_tag(thumbnail_url, :alt => attachment.filename) link_to(img, image_url, :class => 'thumbnail', :title => title) else - raise "Attachment #{filename} not found" + raise t(:error_attachment_not_found, :name => filename) end end |