Translation of HTML context (e.g. paragraph with links inside)
See original GitHub issueHi,
by default all HTML in a translation key is rendered as string and no possibility is given to render also translated HTML within a translation key. Right? How is it possible to capacitate the package and having something like the component interpolation of <i18n>
in vue-i18n? So the code would look like:
<i18n path="term" tag="label" for="tos">
<a :href="url" target="_blank">{{ $t('tos') }}</a>
</i18n>
… that renders to something like this:
<label for="tos">
I accept xxx <a href="/term" target="_blank">Term of Service</a>.
</label>
Or more advanced to put HTML to named target-“places” in the parent translation context:
en: {
info: 'You can {action} until {limit} minutes from departure.',
change: 'change your flight'
}
… coded as:
<i18n path="info" tag="p">
<span place="limit">{{ changeLimit }}</span>
<a place="action" :href="changeUrl">{{ $t('change') }}</a>
</i18n>
… renders to:
<p>
You can <a href="/change">change your flight</a> until <span>15</span> minutes from departure.
</p>
What can I code to get this functionality? Or how can one implement this?
Or is there another work around to come to this?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Using HTML's translate attribute - W3C
This is how articles such as the one you are reading handle links to translated versions of a page – the title attribute...
Read more >How to translate HTML with examples - Lokalise Blog
So, in this article, I will explain how to get started on translating HTML code into different languages using Lokalise: a simple yet...
Read more >Dynamic or static links and HTML in translatable strings - Drupal
Breaking text out to paragraphs makes it possible for translators to work on smaller chunks, which makes it more likely that they will...
Read more >HTML Links Hyperlinks - W3Schools
HTML Links · HTML Links - Syntax. The HTML <a> tag defines a hyperlink. · HTML Links - The target Attribute. By default,...
Read more >rails i18n - translating text with links inside - Stack Overflow
en.yml log_in_message_html: "This is a text, with a %{href} inside." log_in_href: "link". login.html.erb <p> <%= t("log_in_message_html" ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can use
v-html
to html elements as followsI’ve made a quick solution to this problem. It’s forked here. The example: doc. It assumes that you’re using
{
and}
as the identifiers (I didn’t manage to access plugin config value from the external file in order to pick the actual ones).