Skip to content
Enact

An unstyled text translation component.

Translates its child string value in the current locale.

If translations are not available yet, Text will render nothing. Once translations are available, the component will update with the translated string.

<Text>Go</Text>

Wrapped with: i18n/Texti18n/Text.TextDecorator

Properties

The string to be translated.

A higher-order component that is used to translate text and provide the translations via props.

TextDecorator accepts an optional mapPropsToText config prop which defines the props it will populate and the text to translate and provide in that prop. defaultText can also be provided when appropriate.

If translations are not available yet and all props do not include a default value, TextDecorator will render nothing. Once translations are available, the component will update with the translated strings.

TextDecorator({
  mapPropsToText: {
    // Always translate "Go" and pass it in the `children` prop
    children: 'Go',
    // Translate "Go to next page" but pass "" (value always untranslated) while
    // waiting for the translated strings to be fetched.
    'aria-label': {
      text: 'Go to next page',
      defaultText: ''
    }
  }
})

Configuration
Object(String, StringObject)

Configures the translated text passed to the wrapped component.

Default: null
Properties added to wrapped component

Passed to the wrapped component.

If mapPropsToText is null and children is a string, the string will be translated before being passed to the wrapped component.


The locale for translation.

If not supplied, the current locale is used.