i18n/Text

An unstyled text translation component.

import Text from '@enact/i18n/Text';

Members

TextComponent

Translates its child string value in the current locale.

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

<Text>Go</Text>
import Text from '@enact/i18n/Text';
Properties
children
String

The string to be translated.

TextDecoratorHigher-Order Component

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 avaiable, 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: ''
    }
  }
})
import {TextDecorator} from '@enact/i18n/Text';
Configuration
mapPropsToText
ObjectString

Configures the translated text passed to the wrapped component.

Default: null
Properties added to wrapped component
children
Any

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.

locale
String

The locale for translation.

If not supplied, the current locale is used.

ArrayBooleanFunctionModuleNumberObjectString