Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling when the link label is the same as the link #33

Open
professor opened this issue Nov 3, 2021 · 0 comments
Open

Handling when the link label is the same as the link #33

professor opened this issue Nov 3, 2021 · 0 comments

Comments

@professor
Copy link

professor commented Nov 3, 2021

In a few cases, I'd like the label and the link to "be the same." Notice that the url (https://example.com) and the email address ('[email protected]') is in both the ruby and the translation file. In my case these are dynamic values coming from the code.

If you'd like me to suggest a PR for the readme, let me know.

Example 1

It.it "example", link: "https://example.com"

en:
  example:
    'Go see %{link:https://example.com}.'

Example 2

It.it "example", email_link: "mailto:[email protected]"

en:
  example:
     'We are here to help. Email %{email_link:[email protected]}.'

The following solution works. I'm not sure if there is something better for Example 2.

Example 1 Solution

CORRECTION: this does not work.

It.it "example", link: "https://example.com"

en:
  example:
    'Go see %{link:link}.'

This does work:

raw I18n.t "example", link: link_to("https://example.com", "https://example.com")

en:
  example:
    'Go see %{link}.'

Example 2 Solution

CORRECTION: this does not work.

It.it "example", email_link: "mailto:[email protected]", email_address: '[email protected]'

en:
  example:
    'We are here to help. Email %{email_link:email_address}.'

This does work:

I18n.t "example", email_link: mail_to("[email protected]")

en:
  example:
    'We are here to help. Email %{email_link}.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant