i18next: Custom json format with comments for translation bureau

Viewed 434

We are using a custom json format for our i18n resources that contain comments for the translation bureau, so they understand better the context of the strings to translate:

Example en.json:

{
  "headerbar": {
    "search": {
      "placeholder": {
        "value": "Enter your search here...",
        "comment": "This string will be shown in the search input if empty. Truncated after 100 characters."
    }
  },
  "welcome": {
    "heading": {
      "value": "Welcome, {{name}}!",
      "comment": "This string should not be longer than 50 characters."
    }
  }
}

How can I configure i18next (or react-i18next) such that the translation is always retrieved from the value property? Without having to use {returnObjects} in every t().

t('headerbar.search.placeholder')  // === 'Enter your search here...'
t('welcome.heading', {name: 'Bob'}) // === 'Welcome, Bob!'
1 Answers
Related