bunqCommunity / bunqDesktop

The unofficial, free and open source desktop application for the bunq API
https://bunqdesk.top
MIT License
272 stars 53 forks source link

Proposal: use namespaces and placeholders for translations #559

Open firstred opened 4 years ago

firstred commented 4 years ago

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