Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement array type translations #12

Merged
merged 4 commits into from
May 4, 2021
Merged

Conversation

DRFR0ST
Copy link
Collaborator

@DRFR0ST DRFR0ST commented May 3, 2021

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.

@DRFR0ST DRFR0ST added the enhancement New feature or request label May 3, 2021
@DRFR0ST DRFR0ST requested a review from norwegianbegginer May 3, 2021 23:59
@DRFR0ST DRFR0ST changed the title Array type translations Implement array type translations May 4, 2021
@DRFR0ST DRFR0ST merged commit 36d2232 into master May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants