mirror of
https://github.com/redmine/redmine.git
synced 2025-12-16 05:20:28 +01:00
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
This commit is contained in:
@@ -233,6 +233,16 @@ en:
|
|||||||
error_can_not_delete_auth_source: "This authentication mode is in use and cannot be deleted."
|
error_can_not_delete_auth_source: "This authentication mode is in use and cannot be deleted."
|
||||||
error_spent_on_future_date: "Cannot log time on a future date"
|
error_spent_on_future_date: "Cannot log time on a future date"
|
||||||
error_not_allowed_to_log_time_for_other_users: "You are not allowed to log time for other users"
|
error_not_allowed_to_log_time_for_other_users: "You are not allowed to log time for other users"
|
||||||
|
error_can_not_execute_macro_html: "Error executing the <strong>%{name}</strong> macro (%{error})"
|
||||||
|
error_macro_does_not_accept_block: "This macro does not accept a block of text"
|
||||||
|
error_invalid_macro_name: "Invalid macro name: %{name} (only 0-9, A-Z, a-z and _ characters are accepted)"
|
||||||
|
error_can_not_create_macro_without_block: "Can not create a macro without a block!"
|
||||||
|
error_childpages_macro_no_argument: "With no argument, this macro can be called from wiki pages only"
|
||||||
|
error_circular_inclusion: "Circular inclusion detected"
|
||||||
|
error_page_not_found: "Page not found"
|
||||||
|
error_filename_required: "Filename required"
|
||||||
|
error_invalid_size_parameter: "Invalid size parameter"
|
||||||
|
error_attachment_not_found: "Attachment %{name} not found"
|
||||||
|
|
||||||
mail_subject_lost_password: "Your %{value} password"
|
mail_subject_lost_password: "Your %{value} password"
|
||||||
mail_body_lost_password: 'To change your password, click on the following link:'
|
mail_body_lost_password: 'To change your password, click on the following link:'
|
||||||
|
|||||||
@@ -45,12 +45,12 @@ module Redmine
|
|||||||
if self.class.instance_method(method_name).arity == 3
|
if self.class.instance_method(method_name).arity == 3
|
||||||
send(method_name, obj, args, text)
|
send(method_name, obj, args, text)
|
||||||
elsif text
|
elsif text
|
||||||
raise "This macro does not accept a block of text"
|
raise t(:error_macro_does_not_accept_block)
|
||||||
else
|
else
|
||||||
send(method_name, obj, args)
|
send(method_name, obj, args)
|
||||||
end
|
end
|
||||||
rescue => e
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -152,10 +152,10 @@ module Redmine
|
|||||||
def macro(name, options={}, &block)
|
def macro(name, options={}, &block)
|
||||||
options.assert_valid_keys(:desc, :parse_args)
|
options.assert_valid_keys(:desc, :parse_args)
|
||||||
unless /\A\w+\z/.match?(name.to_s)
|
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
|
end
|
||||||
unless block_given?
|
unless block_given?
|
||||||
raise "Can not create a macro without a block!"
|
raise t(:error_can_not_create_macro_without_block)
|
||||||
end
|
end
|
||||||
name = name.to_s.downcase.to_sym
|
name = name.to_s.downcase.to_sym
|
||||||
available_macros[name] = {:desc => @@desc || ''}.merge(options)
|
available_macros[name] = {:desc => @@desc || ''}.merge(options)
|
||||||
@@ -204,9 +204,9 @@ module Redmine
|
|||||||
elsif obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version)
|
elsif obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version)
|
||||||
page = obj.page
|
page = obj.page
|
||||||
else
|
else
|
||||||
raise 'With no argument, this macro can be called from wiki pages only.'
|
raise t(:error_childpages_macro_no_argument)
|
||||||
end
|
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)
|
pages = page.self_and_descendants(options[:depth]).group_by(&:parent_id)
|
||||||
render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id)
|
render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id)
|
||||||
end
|
end
|
||||||
@@ -216,9 +216,9 @@ module Redmine
|
|||||||
"{{include(projectname:Foo)}} -- to include a page of a specific project wiki"
|
"{{include(projectname:Foo)}} -- to include a page of a specific project wiki"
|
||||||
macro :include do |obj, args|
|
macro :include do |obj, args|
|
||||||
page = Wiki.find_page(args.first.to_s, :project => @project)
|
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 ||= []
|
@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
|
@included_wiki_pages << page.id
|
||||||
out = textilizable(page.content, :text, :attachments => page.attachments, :headings => false, :inline_attachments => @@inline_attachments)
|
out = textilizable(page.content, :text, :attachments => page.attachments, :headings => false, :inline_attachments => @@inline_attachments)
|
||||||
@included_wiki_pages.pop
|
@included_wiki_pages.pop
|
||||||
@@ -247,9 +247,9 @@ module Redmine
|
|||||||
macro :thumbnail do |obj, args|
|
macro :thumbnail do |obj, args|
|
||||||
args, options = extract_macro_options(args, :size, :title)
|
args, options = extract_macro_options(args, :size, :title)
|
||||||
filename = args.first
|
filename = args.first
|
||||||
raise 'Filename required' unless filename.present?
|
raise t(:error_filename_required) unless filename.present?
|
||||||
size = options[:size]
|
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 = size.to_i
|
||||||
size = 200 unless size > 0
|
size = 200 unless size > 0
|
||||||
if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename)
|
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)
|
img = image_tag(thumbnail_url, :alt => attachment.filename)
|
||||||
link_to(img, image_url, :class => 'thumbnail', :title => title)
|
link_to(img, image_url, :class => 'thumbnail', :title => title)
|
||||||
else
|
else
|
||||||
raise "Attachment #{filename} not found"
|
raise t(:error_attachment_not_found, :name => filename)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user