astrolicious / i18n

Yet another i18n integration for Astro with server and client utilities, type safety and translations built-in.

Home Page:https://astro-i18n.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for links in translated strings

casungo opened this issue · comments

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!

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

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.

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