简体   繁体   中英

rails i18n - translating text with multiple links inside

I like to have multiple links inside one yml-key.

This post rails i18n - translating text with links inside covers one link inside a yaml-key and i'm wondering if it's possible to have multiple links:

Something like:

# 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."

In my View:

 <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>

Have you tried it like this?

<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>

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