Skip to content

Simplify how we translate strings outside components #2812

@gnprice

Description

@gnprice

For user-facing text whose source code is in the code of a component, Label and friends give us a nice convenient way to pass the text through translation.

When the code is in a function elsewhere, we have this way of doing it:

    const getString = value => this.context.intl.formatMessage({ id: value });

and then pass getString down the stack. We only do this in MessageList and its helpers, though -- everywhere else, we just don't translate. #1538 and #1539 cover two such areas.

This pattern is the right basic architecture, but it's wordy. The state we ought to get to is that basically every string in the source code that looks like it's meant for the user is clearly marked right there for translation. To do that, we'll be writing this a lot; we need to make it concise and low-noise.

This only needs two small changes:

  • Change the name to _. This is a traditional name that's been widely used for this since at least the '90s, and the backend uses it.
  • Put the handy wrapper (getString above, now to be called _) directly on context.

A good followup will be the equivalent of #1538 and #1539 with this style, and then to sweep to find untranslated strings that remain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions