0

Exactly as the title suggests. How would I internationalize something such as this:

 = link_to t('.close'), topic_path(@topic, topic: { closed: '0' }),
    method: :put, confirm: 'Are you sure you want to close this topic?',
    class: 'btn btn-mini', title: "Close topic '#{@topic.title}'"

What I want to do is to I18n the the confirmation part of the link to method. How would I go about doing that? I've been playing around with my topics.en.yml file (shown below) for too long now. Some help would be appreciated.

en:

topics:
  new:
    create_topic: 'Post Topic'
  create:
    success: 'Topic successfully created'
    error: 'Unable to successfully create topic'
  show:
    close: 'Close'
    # close_confirm: 'Are you sure you want to close this topic?'
    delete: 'Delete'
    reopen: 'Re-open'
  edit:
    save_changes: 'Save Changes'
  update:
    success: 'Topic updated'
    error: 'Sorry, there was a problem updating the topic'
  destroy:
    success: 'Topic successfully removed'
    error: 'There was a problem deleting the forum'
  form:
    title: 'Title (required)'
    enter_topic_title: 'Enter the topic title.'
    message: 'Message'
    first_post: 'This will be the first post'
    sticky: 'Sticky'
    closed: 'Closed'
Joel
  • 4,503
  • 1
  • 27
  • 41
Dan Rubio
  • 4,709
  • 10
  • 49
  • 106

1 Answers1

0

Uncomment the close_confirm key in topics.en.yml and use the t helper method.

= link_to t('.close'), topic_path(@topic, topic: { closed: '0' }),
   method: :put, confirm: t('.close_confirm'),
   class: 'btn btn-mini', title: "Close topic '#{@topic.title}'"

http://api.rubyonrails.org/classes/ActionView/Helpers/TranslationHelper.html#method-i-translate

messanjah
  • 8,977
  • 4
  • 27
  • 40