Learn how to translate ICU messages

ICU Message Format for translators

{gender, select,
    male {Mr. {name}}
    female {Mrs. {name}}
    other {The {name}}
} learned the ICU Message format in
{count, plural,
    one {{count} second}
    other {{count} seconds}
}

Placeholder usage

Placeholders are replaced with data from the application before they are shown to users.
The placeholder name and surrounding curly brackets should not be translated.

Welcome, {name}!
Message
¡Bienvenido, {name}!
Message

+

name:

Placeholder

=

Welcome, John!
Output
¡Bienvenido, John!
Output

Placeholders order

Although you should not translate placeholders, you can move them around within a message.

Hello, {firstName} {lastName}!
¡Hola, {lastName} {firstName}!

Placeholder type

Placeholders can have a type, an additional parameter used for locale-specific formatting.
The type can have the following values: number, date, time, ordinal, duration, spellout, plural, selectordinal, and select.
The comma and the placeholder type should not be translated either.

Number
Date
Time
Articles {count,number}
Message

+

count:

Placeholder

=

Articles 25,000
Output

Placeholder style

Placeholders can have a style, or additional formatting info.
The placeholder style should not be translated also.

Number
Date
Time
Follow {num,number,::compact-short}
Message

+

num:

Placeholder

=

Follow 25K
Output

Complex placeholder structure

Placeholders of select, selectordinal, and plural type have a slightly more complex structure. They have inner messages that are chosen by matching the value against a selector.
This type of placeholders require translation of inner messages.
Whitespaces within the placeholder are not counted and can be used for better readability.

Select
Plural
{gender, select,
	male {He has a book}
	female {She has a book}
	other {Someone has a book}
}
Message

+

gender:

Placeholder

=

She has a book
Output

Hash placeholder

Inner plural messages can have a special placeholder #, which represents the shorthand for the plural value.
Plural placeholders can also have an offset and =num selectors (=0, =1, and =2 selectors are checked first, then the offset is subtracted before matching keywords zero, one, two, few, many, other).

{howMany, plural, offset:1
	=0 {None}
	=1 {Teacher}
	=2 {Student and teacher}
	other {# students and teacher}
}
Message

+

howMany:

Placeholder

=

4 students and teacher
Output
Open Editor

If this helped you, feel free to share it with others

Copyrights 2024 © Localizely