Skip to content

Allow EuiI18n | string everywhere translated text is expected #2474

@pickypg

Description

@pickypg

While reviewing a PR making use of EuiI18n, I came across this fairly boilerplate code making use of the render method to get the translated text:

 <EuiI18n
  token="euiContext.openMenu"
  default="Open menu"
>
  {(openMenu: string) => (
    <EuiHeaderLogo
      iconType="apps"
      aria-label={openMenu}
      onClick={() => toggleOpen()}
    />
  )}
</EuiI18n>

It got me wondering, can we not generically allow HTML attributes to be specified as EuiI18n | string parameters, thus bridging the gap and enabling simpler usage of translation?

<EuiHeaderLogo
  iconType="apps"
  aria-label={
    <EuiI18n
      token="euiContext.openMenu"
      default="Open menu"
    />
  }
  onClick={() => toggleOpen()}
/>

Then could we take this a step further and push that into all EUI components, like EuiNavDrawerGroup's labels.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions