facebook / fbt

A JavaScript Internationalization Framework
https://facebook.github.io/fbt
MIT License
3.9k stars 178 forks source link

Examples of TranslationScriptInput for Variations #146

Closed jatinsandilya closed 4 years ago

jatinsandilya commented 4 years ago

Hi could someone give me an example on how the translationScriptInput would look like for plurals and other variations like gender,pronouns etc?

We're using the ReactNative sample app that is available as a starter.

{
  "fb-locale": "es_ES",
  "translations": {
    "2dcba29d4a842c6be5d76fe996fcd9f4": {
      "tokens": [],
      "types": [],
      "translations": [
        {
          "translation": "Primer paso",
          "variations": {}
        }
      ]
    },
    "e379f5ddf643bc28c3a9db67b8f67155": {
      "tokens": [],
      "types": [],
      "translations": [
        {
          "translation": "Edita App.js para cambiar esta pantalla y luego verifica tus resultados.",
          "variations": {}
        }
      ]
    }
  }
}

Cheers

jrwats commented 4 years ago

Hi @jatinsandilya, you can look at the vanilla demo-app's translation_input.json for some examples. The es_ES translations don't happen to have any variations, but you can look at the fb_HX section for examples of how variations are intended to work.

es_ES: https://github.com/facebook/fbt/blob/master/demo-app/translation_input.json#L2033-L2396

An example fb_HX variation: https://github.com/facebook/fbt/blob/master/demo-app/translation_input.json#L441-L466

If this doesn't fully answer your question, please re-open this issue!