简体   繁体   中英

Rails I18n word as a link

In my I18n file i have the following translation:

reservation:
  please_accept: "Please accept regulation"

And in my view i'm using it in the following way:

= t('reservation.please_accept')

Now I want to the word "regulation" be a link to some action in my app. How can I do that? Thanks in advance.

Answer for my question:

= t('reservation.please_accept', href: link_to(t('reservation.regulation_word'), '#', "data-toggle" => "modal", 'data-target' => "##{@car.id}")).html_safe

reservation:
    regulation_word: "regulamin"
    please_accept: "Proszę zaakceptować %{href} wypożyczalni"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM