Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Proposal: use namespaces and placeholders for translations #559

Open
firstred opened this issue Feb 3, 2020 · 0 comments
Open

Proposal: use namespaces and placeholders for translations #559

firstred opened this issue Feb 3, 2020 · 0 comments

Comments

@firstred
Copy link
Contributor

firstred commented Feb 3, 2020

Describe the requested feature:

In order to make translating easier and making sure that sentences that may be ambiguous in English are still translatable, we can group the original strings with namespaces and introduce placeholders.
In certain cases it may even be possible to remove the necessity for future translations, for example, when bunq introduces a new card.
Plurals and nesting are supported by i18next, so we can prevent adding a lot of unnecessary strings.

Probably the best way to migrate is to start with namespaces first and let Crowdin's auto-translate feature automatically grab the strings from the global namespace. Then, we could try to replace duplicate sentences and the ones with plurals in them.

Additional context:

This is an example of what the source strings could look like after these changes:

{
  "card": "card",
  "card_plural": "cards",
  "travelCard": "travel card",
  "travelCard_plural": "travel cards",
  "greenCard": "green card",
  "greenCard_plural": "green cards",
  "youHaveItems": "You have one {{item}}",
  "youHaveItems_plural": "You have several {{item}}",
  "youHaveItemsWithCount": "You have {{count}} {{item}}",
  "youHaveItemsWithCount_plural": "You have {{count}} {{item}}"
}

JavaScript code:

t("youHaveItemsWithCount", { count: 2, item: "$t(travelCard)" });

Output:

You have 2 travel cards
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant