Excluding a Link but keep text translated

Add method to translate specifix link

If you have an HTML anchor tag like:

<a href="http://weglot.com" id="my-link">this is my link</a>

When this content is translated to French, Weglot will produce:

<a href="http://weglot.com/fr/" id="my-link">c'est mon lien</a>

In this case:

  • The text content "this is my link" is translated to "c'est mon lien".

  • The URL in the href attribute is also automatically adjusted to include the language code (e.g., /fr/).

If your link is excluded from translation, the result would be:

<a href="http://weglot.com/fr/" id="my-link">this is my link</a>

Here, Weglot will still adjust the link to include the language code, but the text content will not be translated.

If you want to keep the link unchanged while still translating the text content, you can add the wg-excluded-link attribute to your tag:

<a href="http://weglot.com" id="my-link" wg-excluded-link>this is my link</a>

With this attribute, the translation result will be:

<a href="http://weglot.com" id="my-link" wg-excluded-link>ceci est mon lien</a>

Here, the text "this is my link" is translated to "ceci est mon lien", but the href remains the same without adding a language code.

The purpose of the wg-excluded-link attribute is to allow users to translate the text label of a link while keeping the actual link URL unchanged. This is useful when you want to preserve specific URLs but still provide localized content for users.

Last updated