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

i18n: How to add new language to this repository #319

Open
mb-wali opened this issue Jul 1, 2021 · 1 comment
Open

i18n: How to add new language to this repository #319

mb-wali opened this issue Jul 1, 2021 · 1 comment

Comments

@mb-wali
Copy link
Contributor

mb-wali commented Jul 1, 2021

Let's pretend we want to add the French: fr language as a supported language to the repository.

  1. Modify package.json and add the French langugage in to the list of langugages.
---   "config": {"languages": ["en", "de", "tr"]},
+++   "config": {"languages": ["en", "de", "tr", "fr"]},
  1. Pull French language file from Transifex
    tx pull -l fr

  2. Run convert command
    npm run i18n-conv-po-all

  3. update i18next instance, to add the new language.
    modify i18next.js file to add the new language.

  • import the new translation file.
    import TRANSLATIONS_FR from './translations/fr/translations.json';

  • update resources and add the new language.

    resources: {
       ....
      fr: {
        translation: TRANSLATIONS_FR,
      },
    },
@mb-wali mb-wali self-assigned this Jul 1, 2021
@mb-wali mb-wali changed the title what are the needed steps to add a new language for translation? i18n: How to add new language to this repository Jul 2, 2021
@mb-wali mb-wali removed their assignment Jul 2, 2021
@zzacharo
Copy link
Member

zzacharo commented Jul 6, 2021

Translation with interpolation https://www.i18next.com/translation-function/interpolation
Example

i18next.t(`My dynamic {{myvar}} title`, 
    {myvar: 'awesome'}
)

will result in

My dynamic {{myvar}} title

in the .po file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants