Text
Text
component provides ability to format string values.
It supports ICU Message Syntax. More information you can find on official website.
#
Displaying MessagesText
components required an ID to be display a message. The ID is can be provided on the TranslationsProvider
component.
As above example, component will display like:
Hello World!
Text
component can get a message by an ID provided in nested JSON locales, for example:
As above example, component will display like:
Hello World! Welcome to page1!
#
Displaying Fallback MessagesIf there are locales that do not provide some IDs, you can set defaultMessage
to display a fallback message.
The fallback message will be memorized for later use.
As above example, component will display like the first example.
#
Displaying HTML ContentIf you need to render html content, just provide html
property as true
.
As above example, component will display like:
Hello World!
#
Plural FormattingText
components support plural formatting. The following is an example of displaying the plural value.
If count='1'
, component will display You have one item.
If count='4'
, component will display You have 4 items.
#
Usage in React NativeIn React Native, there is a component named Text
for display texts already.
To avoid confusion, eo-locale/react-native
prepared a component named Translation
.
You need to use this within the Text
component to display a translated text.