Assembless / react-littera

🌐 Modern react library for managing translations.
MIT License
19 stars 1 forks source link

Implement array type translations #12

Closed DRFR0ST closed 3 years ago

DRFR0ST commented 3 years ago

Hi! I've finished working on the support for array translations. These will allow passing multiple translations and avoid using incremented key naming (eg. greeting01, greeting02, greeting03).

An example of translations:

const translations = {
  greetings: [
      {
        pl_PL: "Dzień dobry",
        en_US: "Good morning",
        de_DE: "Guten Morgen"
      },
      {
        pl_PL: "Cześć",
        en_US: "Hello",
        de_DE: "Hallo"
      },
    ]
}

 const translated = translate(translations, "en_US");

 translated.slogans[1] // => "Hello"

I've also added some unit tests but it still needs some real testing.