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

Add support for links in translated strings #11

Open
casungo opened this issue Mar 21, 2024 · 3 comments
Open

Add support for links in translated strings #11

casungo opened this issue Mar 21, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested

Comments

@casungo
Copy link
Contributor

casungo commented Mar 21, 2024

Description:
Currently, the i18n integration does not support adding links within translated strings. This feature would be very useful for cases where a translated phrase needs to include a link to external content.

For example, consider the following string:
"Hi everyone, follow me on github, bye!"
It would be great if the word "github" could be turned into a link pointing to the relevant GitHub profile or repository.

Adding support for links in translations would enhance the flexibility and usability of the i18n system. This would allow for more dynamic and interactive content within translated strings.

Possible implementation ideas:

  • Use a special syntax to denote links within the string, such as [link text](url)
  • Provide a way to specify the link target (URL) for each translated string that contains a link
  • Render the links properly in the output, converting them to actual <a> tags with the correct href attribute

I believe this feature would be a valuable addition to the i18n integration and would greatly benefit users who need to include links in their translated content.
Please let me know if you need any further information or clarification. Thank you for considering this feature request!

@florian-lefebvre
Copy link
Member

astro-i18next have the Trans component (inspired by i18next react I think): https://github.com/yassinedoghri/astro-i18next#trans-component. I don't like this API but I can definitely take inspiration

@florian-lefebvre florian-lefebvre self-assigned this Mar 21, 2024
@florian-lefebvre florian-lefebvre added enhancement New feature or request question Further information is requested help wanted Extra attention is needed labels Mar 21, 2024
@firxworx
Copy link

Chipping in that I think a nice thing about their Trans component is that its similar API to react-i18next, so on a project with both react and astro components there is a consistent feel to the code that uses i18next. I agree its not the world's greatest approach though.

FWIW I try to avoid using words and links as much as possible inline prose because I find it can lead to some funny translations due to grammatical differences between languages, and automated translation tools I've found to be particularly bad at correctly lining up what should be a link vs. not.

For example, I would prefer to do something like label an element or list, and then simply put the link in that element or as a list item, so the translations have no interpolation.

@florian-lefebvre
Copy link
Member

I need to have a look at how it works more closely, will tackle it soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants