Working with Placeholders and Tags

In some strings, you will see placeholders (e.g.  %1$s, %s, %d) and tags (e.g. {{strong}}), which allow for the insertion of dynamic content after the string has been translated.

If there is a placeholder or tag in the source string, the exact same tag or placeholder must appear in the translation. These can be moved around within a string but should not be translated or modified.

Here are a few examples of strings with placeholders or tags:

Screen Shot 2018-04-17 at 3.48.19 PM.png

Some placeholderes and tags include English words, such as %(author)s%(days)d, or {{updateButton/}}. The English words tell you what the placeholder refers to. When translating, the entire placeholder (including the English word) should be kept intact and not translated. Rare exceptions are noted in locale-specific translation guides.

GlotPress will throw a warning if tags or variable placeholders are missing from the translation.

*Tip: Below the translation field, you will see a list of placeholders for each string  Screen Shot 2018-06-26 at 2.41.29 PM.png. Clicking on these variables will automatically insert them into the translation field. These can be very helpful while translating.

**Tip: For strings with several placeholders or tags, use the Copy from original button to copy the entire source text into the translation field. You can then insert your translations around the tags and placeholders.

What do these placeholders stand for?

%s: this is a placeholder for a string, meaning that %s will be replaced with either a word or a string of words. You might see English words between the % and s that tell you what placeholder stands for. For example, %(author)s stands for the name of the author.

%s: used when only one placeholder is present.
%1$s%2$s%3$s, …:  used when there are several placeholders within a string. You can rearrange the order of these numbered placeholders when translating. This allows for more flexibility in the translated string while ensuring the dynamic content will still be inserted in the right places.

%d: this is a placeholder for a decimal, meaning that %d will be replaced with a number. The English word tells you what the number refers to.  For example, %(days)s refers to the number of days.

Tags: {{tagname}} or <​tag​>. These come in two types: tag pairs and placeholder tags.

  • Tag pairs always have an opening and a closing tag (e.g. {{strong}}text{{/strong}}) and are often used for formatting or links. Tag pairs must start with an opening tag and end with a closing tag. When translating, make sure that the opening and closing tags are placed around the correct word(s).
  • Placeholder tags indicate the presence of non-translatable information in a string, such as a button.

Finding Context

The grey highlighted text next to the original string provides context for the given string and allows you to see what the variables stand for.

Screen Shot 2018-04-17 at 11.46.49 AM.pngScreen Shot 2018-04-17 at 11.46.45 AM.png

In some cases, you may find the description as a comment.

Screen Shot on 2018-06-26 at 15:03:48.png

HTML Entities

You may also see HTML entities in some strings. An HTML entity is a piece of text that begins with an ampersand (&) and ends with a semicolon (;) and is used to represent special characters in HTML.

Example:

Original String:
Click &​#8220;Next&​#8221; to start adding links to your new menu.

Translation:
Cliquez sur « Suivant » pour commencer à ajouter des liens à votre nouveau menu.

If there is an HTML entity in the English string, it may or may not need to be in the translated string. Unlike tags and placeholders, you can omit an entity from the translation if it’s not needed.

If you are unsure of what an entity stands for, you can see a full list of entities here.

Common HTML Entities:

&​#8220; = “ (left double quotation)
&​#8221; = ” (right double quotation)
&​#8217; = ’ (apostrophe)
&​amp; = & (ampersand)
&​nbsp; = non-breaking space

*Tip 1: for quotation marks, you can replace the quotation entities with the quotation mark used in your language (e.g. « » in French).

*Tip 2: if ampersands are not commonly used in your language, you can replace it with the translation for the word “and”.