rails i18n - translating text with links inside

后端 未结 9 788
名媛妹妹
名媛妹妹 2020-11-30 21:05

I\'d like to i18n a text that looks like this:

Already signed up? Log in!

Note that there is a link on the text. On this example

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-30 21:50

    In en.yml

    registration:
        terms:
          text: "I do agree with the terms and conditions: %{gtc} / %{stc}"
          gtc: "GTC"
          stc: "STC"
    

    In de.yml

    registration:
        terms:
          text: "Ich stimme den Geschäfts- und Nutzungsbedingungen zu: %{gtc} / %{stc}"
          gtc: "AGB"
          stc: "ANB"
    

    in new.html.erb [assumed]

    <%= t(
       'registration.terms.text',
        gtc:  link_to(t('registration.terms.gtc'),  terms_and_conditions_home_index_url + "?tab=gtc"),
        stc: link_to(t('registration.terms.stc'), terms_and_conditions_home_index_url + "?tab=stc")
     ).html_safe %>
    

提交回复
热议问题