L20n with HTML markup?

How to use l20n if I wanted to create something like this:

About <strong>Firefox</strong> 

I want to translate the phrase as a whole, but also want the markup. I do not want to do this:

 <aboutBrowser "About {{ browserBrandShortName }}"> <aboutBrowserStrong "About &lt;strong&gt;{{ browserBrandShortName }}&lt;/strong&gt;"> 

... since the translation itself is now duplicated.

I understand that this may not be in the l20n volume, but this is probably a fairly common case in the real world. Is there any specific way to do this?

+4
source share
1 answer

Sometimes duplicating a translation is the best you can do. Redundancy is good at localization: this allows you to make fewer assumptions about translations into other languages. One of the basic principles of the L20n is that only the localizer will know what they really need .

Your decision is really ok

The solution you proposed is actually not bad. It is possible that the accent you are trying to express with <strong> will have some unknown consequences in some language that we might not be aware of. For example, some languages ​​may use deviations or postpositions to mean “about something,” in which case you, as a developer, should not make too many assumptions about the exact position of the <strong> element. Perhaps the entire translation will be in one word surrounded by <strong> .

Here is your code again, formatted using multi-line L20n literals:

 <aboutBrowser "About {{ browserBrandShortName }}"> <aboutBrowserEmphasized """ About <strong>{{ browserBrandShortName }}</strong> """> 

Note that for this, as expected, you need to add the data-l10n-overlay attribute to the DOM node using data-l10n-id=aboutBrowserEmphasized . Otherwise, < and > will be escaped.

Fulfilling a few assumptions matters

Let me quickly get distracted and bring Error 859035 - Do not use the same "unknown" entity for Size and Author when installing WebApp from Firefox OS. The English-language developer suggested that they could use the "unknown" adjective to qualify both the size and the author in the setup dialog. However, in some languages, such as French or Polish, the adjective must match the object in terms of gender and plural. Therefore, although in English we can only have one line:

 <unknown "Unknown"> 

... other languages ​​may require two separate lines for each of the contexts in which they are used. In French you say "auteur inconnu" (unknown author, male), but "taille inconnue" (unknown size, female)

 <unknownSize "inconnue"> <unknownAuthor "inconnu"> 

In English, this means some redundancy:

 <unknownSize "Unknown"> <unknownAuthor "Unknown"> 

... but that's OK, because in the end, the quality of localization improves. As a rule, it is good practice to use unique strings around the world and reuse them. Ideally, you would allow different translations for all lines. Even something as simple and general as “Yes” and “No” can be complicated if you consider languages ​​such as Welsh:

The Welshman does not have a word to use every time for yes and no questions asked. The word used depends on the form of the question. You should usually answer using the appropriate form of the verb used in the question, or in questions where the verb is not the first element that you use either "ie" / "nage".

+7
source

Source: https://habr.com/ru/post/1496294/


All Articles