4

I am using the twitter-bootstrap-rails gem in my app. It seems to come with a range of helper methods that create for example the edit and delete buttons in a themed view:

<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
                  cohort_path(cohort),
                  :method => :delete,
                  :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')),
                  :class => 'btn btn-mini btn-danger' %>

Where are these t() methods and helpers defined? How can I alter them? For example, if I want to change the label on the Destroy button to "Delete" I can change the above to:

<%= link_to t('.destroy', :default => "Delete"),
                  cohort_path(cohort),
                  :method => :delete,
                  :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')),
                  :class => 'btn btn-mini btn-danger' %>

What I would really like to do is change t("helpers.links.destroy") to display "Delete" instead of "Destroy" in all my views. Can I do that? Appreciate your help!

donsteffenski
  • 477
  • 3
  • 15
  • Doooh. I found it. Nothing to do with Bootstrap. l18n translation API: t short for tranlation, l short for locale http://guides.rubyonrails.org/i18n.html – donsteffenski Jun 27 '12 at 11:11

1 Answers1

4

All you have to do is add the following to your i18n Rails file (in path "config/locales/en.yml"):

<pre>
en:
 helpers:
    links:
      back: "Back Page"
      destroy: "Delete"
</pre>

The method t() is using to i18n a Rails Application.

Chris Gerken
  • 16,221
  • 6
  • 44
  • 59
alexs1010
  • 41
  • 3