rails i18n - 使用

时间:2016-09-08 15:30:06

标签: ruby-on-rails rails-i18n

我喜欢在一个yml-key中有多个链接。

这篇文章rails i18n - translating text with links inside涵盖了yaml-key中的一个链接,我想知道是否可以有多个链接:

类似的东西:

# en.yml
additional_terms: additional terms
data_privacy: data privacy terms
gtc_link: GTCs
terms_html: "By accepting the GTCs %{gtc_link}, you confirm that you agree to the %{data_privacy} and %{additional_terms} of the Wirecard payment option."

在我的观点中:

 <div class="terms">
 <%= t('view.user.account.terms_html',
   {
     gtc_link: link_to(t('pages.imprint.gtc'),"/pdf/agb_#{I18n.locale}.pdf", { target: '_blank' }
   },
   {
     data_privacy: link_to(t('view.account.data_privacy'),"https://www.wirecardbank.de/privacy-documents/datenschutzhinweis-fur-die-wirecard-zahlarten/", { target: '_blank' }
   },
   {
     additional_terms: link_to(t('view.account.additional_terms'),"https://www.wirecardbank.de/privacy-documents/datenschutzhinweis-fur-die-wirecard-zahlarten/", { target: '_blank' }
   },
    )) %>
 </div>

1 个答案:

答案 0 :(得分:1)

你试过这样的吗?

<div class="terms">
  <%= t('view.user.account.terms_html',
        gtc_link: link_to(t('pages.imprint.gtc'),"/pdf/agb_# {I18n.locale}.pdf", { target: '_blank' }),
        data_privacy: link_to(t('view.account.data_privacy'),"https://www.wirecardbank.de/privacy-documents/datenschutzhinweis-fur-die-wirecard-zahlarten/", { target: '_blank' }),
        additional_terms: link_to(t('view.account.additional_terms'),"https://www.wirecardbank.de/privacy-documents/datenschutzhinweis-fur-die-wirecard-zahlarten/", { target: '_blank' })
      ) %>
</div>