Skip to content

Why do we need to duplicate the translation text in the React component? #647

@MurzNN

Description

@MurzNN

Here is an example from the React Tutorial: https://github.com/projectfluent/fluent.js/wiki/React-Tutorial

        <Localized id="hello-world">
            <p>Hello, World!</p>
        </Localized>

So, we have the translation id "hello-world", and, together with this, <p>Hello, World!</p>. Could you please explain why do we need to store the "Hello, World!" phrase twice?

  1. In the component HTML content, as <p>Hello, World!</p>

  2. In the translation list, like this

const MESSAGES_ALL = {
    'en-US': 'hello-world = Hello, World!',
};

And, if ten React components reuse this message, we will have 11 copies of the message in the code, so changing the actual text to something like "Hi World" will lead to many changes in different files.

So, could you please explain the core idea of this duplication and potential benefits?

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