Project

General

Profile

Defect #33426 » 33426.patch

Go MAEDA, 2020-05-10 15:29

View differences:

config/locales/en.yml
233 233
  error_can_not_delete_auth_source: "This authentication mode is in use and cannot be deleted."
234 234
  error_spent_on_future_date: "Cannot log time on a future date"
235 235
  error_not_allowed_to_log_time_for_other_users: "You are not allowed to log time for other users"
236
  error_can_not_execute_macro_html: "Error executing the <strong>%{name}</strong> macro (%{error})"
237
  error_macro_does_not_accept_block: "This macro does not accept a block of text"
238
  error_invalid_macro_name: "Invalid macro name: %{name} (only 0-9, A-Z, a-z and _ characters are accepted)"
239
  error_can_not_create_macro_without_block: "Can not create a macro without a block!"
240
  error_childpages_macro_no_argument: "With no argument, this macro can be called from wiki pages only"
241
  error_circular_inclusion: "Circular inclusion detected"
242
  error_page_not_found: "Page not found"
243
  error_filename_required: "Filename required"
244
  error_invalid_size_parameter: "Invalid size parameter"
245
  error_attachment_not_found: "Attachment %{name} not found"
236 246

  
237 247
  mail_subject_lost_password: "Your %{value} password"
238 248
  mail_body_lost_password: 'To change your password, click on the following link:'
lib/redmine/wiki_formatting/macros.rb
45 45
            if self.class.instance_method(method_name).arity == 3
46 46
              send(method_name, obj, args, text)
47 47
            elsif text
48
              raise "This macro does not accept a block of text"
48
              raise t(:error_macro_does_not_accept_block)
49 49
            else
50 50
              send(method_name, obj, args)
51 51
            end
52 52
          rescue => e
53
            "<div class=\"flash error\">Error executing the <strong>#{h name}</strong> macro (#{h e.to_s})</div>".html_safe
53
            %|<div class="flash error">#{t(:error_can_not_execute_macro_html, :name => name, :error => e.to_s)}</div>|.html_safe
54 54
          end
55 55
        end
56 56

  
......
152 152
        def macro(name, options={}, &block)
153 153
          options.assert_valid_keys(:desc, :parse_args)
154 154
          unless /\A\w+\z/.match?(name.to_s)
155
            raise "Invalid macro name: #{name} (only 0-9, A-Z, a-z and _ characters are accepted)"
155
            raise t(:error_invalid_macro_name, :name => name)
156 156
          end
157 157
          unless block_given?
158
            raise "Can not create a macro without a block!"
158
            raise t(:error_can_not_create_macro_without_block)
159 159
          end
160 160
          name = name.to_s.downcase.to_sym
161 161
          available_macros[name] = {:desc => @@desc || ''}.merge(options)
......
204 204
        elsif obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version)
205 205
          page = obj.page
206 206
        else
207
          raise 'With no argument, this macro can be called from wiki pages only.'
207
          raise t(:error_childpages_macro_no_argument)
208 208
        end
209
        raise 'Page not found' if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project)
209
        raise t(:error_page_not_found) if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project)
210 210
        pages = page.self_and_descendants(options[:depth]).group_by(&:parent_id)
211 211
        render_page_hierarchy(pages, options[:parent] ? page.parent_id : page.id)
212 212
      end
......
216 216
             "{{include(projectname:Foo)}} -- to include a page of a specific project wiki"
217 217
      macro :include do |obj, args|
218 218
        page = Wiki.find_page(args.first.to_s, :project => @project)
219
        raise 'Page not found' if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project)
219
        raise t(:error_page_not_found) if page.nil? || !User.current.allowed_to?(:view_wiki_pages, page.wiki.project)
220 220
        @included_wiki_pages ||= []
221
        raise 'Circular inclusion detected' if @included_wiki_pages.include?(page.id)
221
        raise t(:error_circular_inclusion) if @included_wiki_pages.include?(page.id)
222 222
        @included_wiki_pages << page.id
223 223
        out = textilizable(page.content, :text, :attachments => page.attachments, :headings => false,  :inline_attachments => @@inline_attachments)
224 224
        @included_wiki_pages.pop
......
247 247
      macro :thumbnail do |obj, args|
248 248
        args, options = extract_macro_options(args, :size, :title)
249 249
        filename = args.first
250
        raise 'Filename required' unless filename.present?
250
        raise t(:error_filename_required) unless filename.present?
251 251
        size = options[:size]
252
        raise 'Invalid size parameter' unless size.nil? || /^\d+$/.match?(size)
252
        raise t(:error_invalid_size_parameter) unless size.nil? || /^\d+$/.match?(size)
253 253
        size = size.to_i
254 254
        size = 200 unless size > 0
255 255
        if obj && obj.respond_to?(:attachments) && attachment = Attachment.latest_attach(obj.attachments, filename)
......
260 260
          img = image_tag(thumbnail_url, :alt => attachment.filename)
261 261
          link_to(img, image_url, :class => 'thumbnail', :title => title)
262 262
        else
263
          raise "Attachment #{filename} not found"
263
          raise t(:error_attachment_not_found, :name => filename)
264 264
        end
265 265
      end
266 266

  
(2-2/3)