Loco supports several formatting styles. See the developer guide for full technical details.
Guidance for translators
When translating text for embedding in software, you may encounter formatting syntax of various kinds.
Broadly, Loco's supported syntax falls into two categories:
printf
syntax where the symbols must be kept intact.- More complex syntax where some parts might look like words.
It's important that translators (1) don't break the syntax, and (2) don't translate placeholders that look like words.
Printf
Here's an example of the most basic printf
formatting. This example is compatible with numerous platform-specific formats.
Hello %s
.
The %s
sequence is a placeholder that might be substituted with a person's name. It must not be altered.
A common error is to mistake the "s"
character for part of the translatable text, and cause it to be removed or changed.
This more complex example has two placeholders:
Hello %1$s, my name is %2$s
The full sequences (%1$s
and %2$s
) must not be altered, but they may be swapped around if the translation requires a different order.
However, the positions (1
and 2
) must still refer to the same parts of the sentence.
Named placeholders
Here's a simple example of a "wordy" syntax where the curly braces enclose an identifier. This is ICU MessageFormat syntax.
Hello {name}
.
The braces must be left intact, and the word "name" must not be translated.
Code highlighting
Clicking the editor's :code icon: will enable syntax highlighting. It's highly recommended to switch to this view when translating formatted texts, or at least when errors are detected.
The following example shows the placeholders highlighted in the source code (%1$s
and %2$s
). The translation has only one placeholder (%s
), which is an error in this case.
Common errors
String formatting is invalid
This means the syntax is broken. This can apply to the original source text too, if the developer made a mistake.e.g.
"Hello %"
or"Hello %S"
will both cause errors in most applications that useprintf
.Translation is missing 1 placeholder
Missing placeholders may not break your application, but they won't render all the data that the source text does.e.g.
"Hello there"
,"Hello s"
or"Hello $s"
have no placeholders. If one is expected, it is likely that"%s"
is missing.Translation requires too many parameters
This means more placeholders have been entered into a translation than exist in the source text. This is likely to cause errors in your application.Formatting differs for argument
This means the syntax has the right number of placeholders, but they don't match the source text and might render wrongly in your application.e.g.
"Hello %d"
is valid, but expects a number. Give a person's name it will likely produce"Hello 0"
(or worse).Translation contains the wrong placeholder name
For wordy syntax (like ICU) it's likely that the placeholder is translated by accident. Either by human, or machine.e.g.
"Bonjour {nom}"
should probably be"Bonjour {name}"
.