astrolicious / i18n

Yet another i18n integration for Astro with server and client utilities, type safety and translations built-in.
https://astro-i18n.netlify.app/
MIT License
57 stars 3 forks source link

Add support for links in translated strings #11

Open casungo opened 8 months ago

casungo commented 8 months ago

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:

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 commented 8 months ago

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

firxworx commented 7 months ago

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 commented 7 months ago

I'd need to have a look at how it works more closely