Message & Placeholders format
For generic formats, Tolgee allows the export of data in various message and placeholder formats. Tolgee uses the ICU message format natively and is able to visualize ICU placeholders in the UI. Other message formats can be converted to Tolgee Universal ICU when importing. When exporting Tolgee, it can convert such ICU messages to other formats.
For generic formats like Gettext .po
, JSON
, YAML
or XLIFF
, you can choose from various formats when exporting.
ICU
ICU message format is a very powerful format tailored specifically for localization. You can read more about it's features here. Since the ICU message format is native to Tolgee, no conversion is performed when importing data in the ICU message format.
PHP Sprintf
In the PHP world, strings are often formatted using the sprinf
function.
This format is standard for PHP localization using Gettext (.po).
The official PHP documentation can be found
here
Only specifiers specified in the table below are supported. Tolgee doesn't support additional flags and modifiers and placeholders using them are not converted.
Specifier | ICU type | Example | Converted to ICU | Note |
---|---|---|---|---|
% | N/A | %% | % | %% is the way how to render %, in ICU we don't have such concept, so we just add %. When exporting, the % is converted back to %%. |
s | none | %s | {0} | |
d | number | %d | {0, number} | |
f | number, [precision string] | %f | {0, number, 0.000000} | By default %f uses 6 decimal places, that's why we convert it to the number with such precision. %.2 f would be {0, number, 0.00} and so on. |
e | number, scientific | %e | {0, number, scientific} | %E is not supported |
n$
positional specifiers. They are converted to the zero-based argument index. E.g. I am %2$@, and I have %1$lld dogs.
is converted toI am {1} and I have {(0, number)} dogs
.Java String.format
The Java documentation about format specifiers can be found here
Only specifiers specified in the table below are supported. Tolgee doesn't support additional flags and modifiers and placeholders using them are not converted.
Specifier | ICU type | Example | Converted to ICU | Note |
---|---|---|---|---|
% | N/A | %% | % | %% is the way how to render %, in ICU we don't have such concept, so we just add %. When exporting, the % is converted back to %%. |
s | none | %s | {0} | |
d | number | %d | {0, number} | |
f | number, [precision string] | %f | {0, number, 0.000000} | By default %f uses 6 decimal places, that's why we convert it to the number with such precision. %.2 f would be {0, number, 0.00} and so on. |
e | number, scientific | %e | {0, number, scientific} | %E is not supported |
n$
positional specifiers. They are converted to the zero-based argument index. E.g. I am %2$@, and I have %1$lld dogs.
is converted toI am {1} and I have {(0, number)} dogs
.C Sprintf
The C documentation about format specifiers can be found here
Only specifiers specified in the table below are supported. Tolgee doesn't support additional flags and modifiers and placeholders using them are not converted.
Specifier | ICU type | Example | Converted to ICU | Note |
---|---|---|---|---|
% | N/A | %% | % | %% is the way how to render %, in ICU we don't have such concept, so we just add %. When exporting, the % is converted back to %%. |
s | none | %s | {0} | |
d | number | %d | {0, number} | |
f | number, [precision string] | %f | {0, number, 0.000000} | By default %f uses 6 decimal places, that's why we convert it to the number with such precision. %.2 f would be {0, number, 0.00} and so on. |
e | number, scientific | %e | {0, number, scientific} | %E is not supported |
n$
positional specifiers. They are converted to the zero-based argument index. E.g. I am %2$@, and I have %1$lld dogs.
is converted toI am {1} and I have {(0, number)} dogs
.Apple Sprintf
The official Apple's string format specifiers documentation can be found here.
Only specifiers specified in the table below are supported. Tolgee doesn't support additional flags and modifiers and placeholders using them are not converted.
Specifier | ICU type | Example | Converted to ICU | Note |
---|---|---|---|---|
% | N/A | %% | % | %% is the way how to render %, in ICU we don't have such concept, so we just add %. When exporting, the % is converted back to %%. |
@ | none | %@ | {0} | |
lld | number | %lld | {0, number} | |
f | number, [precision string] | %f | {0, number, 0.000000} | By default %f uses 6 decimal places, that's why we convert it to the number with such precision. %.2 f would be {0, number, 0.00} and so on. |
e | number, scientific | %e | {0, number, scientific} | %E is not supported |
If your placeholder is not supported, you can use %@
and format the string yourself in the code.
Apple also supports n$
positional specifiers. There are converted to as well as the zero based argument index. E.g.
I am %2$@, and I have %1$lld dogs.
is converted to I am {1} and I have {0, number} dogs
.
Ruby Sprintf
Only specifiers specified in the table below are supported. Tolgee doesn't support additional flags and modifiers and placeholders using them are not converted.
Specifier | ICU type | Example | Converted to ICU | Note |
---|---|---|---|---|
% | N/A | %% | % | %% is the way how to render %, in ICU we don't have such concept, so we just add %. When exporting, the % is converted back to %%. |
s | none | %s, %<name>s | {0}, {name} | |
d | number | %d, %<count>d | {0, number}, {count, number} | |
f | number, [precision string] | %f, %<value>f | {0, number, 0.000000}, {value, number, 0.000000} | By default %f uses 6 decimal places, that's why we convert it to the number with such precision. %.2 f would be {0, number, 0.00} and so on. |
e | number, scientific | %e, %<value>e | {0, number, scientific}, {value, number, scientific} | %E is not supported |
Ruby supports named placeholders. Such placeholders are wrapped with curly brackets, e.g., %{name}
. When also specifying
the specifier, the name is wrapped in angle brackets, e.g., %<name>s
. The name is then used to convert to ICU.
Ruby also supportsn$
positional specifiers. They are converted to the zero-based argument index. E.g.
I am %2$@, and I have %1$lld dogs.
is converted toI am {1} and I have {0, number} dogs
.