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

How to prefix translation json files? #472

Closed
darde opened this issue Jul 11, 2018 · 8 comments
Closed

How to prefix translation json files? #472

darde opened this issue Jul 11, 2018 · 8 comments

Comments

@darde
Copy link

darde commented Jul 11, 2018

Is there any way to prefix my translation json files? I need to do something like that:

i18n/locales/en/common.json

"en" {
  "editor": {
    "sidebar": {
      "header": {
        ...
      }
    }
  }
}

i18n/locales/pt/common.json

"pt-BR" {
  "editor": {
    "sidebar": {
      "header": {
        ...
      }
    }
  }
}

Without the prefixes en and pt-BR my project is working well. This is my index:

i18n/index.js

import i18n from 'i18next';
// import LanguageDetector from 'i18next-browser-languagedetector';
import pt from './locales/pt/common.json';
import en from './locales/en/common.json';

const options = {
  interpolation: { escapeValue: false },
  lng: 'en',

  resources: {
    pt: {
      common: pt,
    },
    en: {
      common: en,
    },
  },

  fallbackLng: 'pt',

  ns: ['common'],

  defaultNS: 'common',

  react: {
    wait: true,
  },
};

i18n.init(options);


export default i18n;

I also posted this question in stackoverflow.

@jamuhl
Copy link
Member

jamuhl commented Jul 11, 2018

why you need that prefix?

@jamuhl
Copy link
Member

jamuhl commented Jul 11, 2018

 resources: {
    pt: {
      common: pt[pt-BR],
    },
    en: {
      common: en.en,
    },
  },

@darde
Copy link
Author

darde commented Jul 11, 2018

Because I'm using https://crowdin.com/. This is a localization management platform and I'm only able to create prefixed json files.

@jamuhl
Copy link
Member

jamuhl commented Jul 11, 2018

use https://locize.com instead -> that's from us - so you support i18next directly.

Beside that just see the last comment:

resources: {
pt: {
common: pt[pt-BR],
},
en: {
common: en.en,
},
},

@darde
Copy link
Author

darde commented Jul 11, 2018

Thank you very much man. Your solution works fine. Congrats for the awsome work!!!

@darde darde closed this as completed Jul 11, 2018
@jamuhl
Copy link
Member

jamuhl commented Jul 11, 2018

Still using locize.com and supporting us would be more awesome ;)

@darde
Copy link
Author

darde commented Jul 11, 2018

I'll suggest this for my team. Thanks!!!

@jamuhl
Copy link
Member

jamuhl commented Jul 11, 2018

https://www.youtube.com/watch?v=9NOzJhgmyQE might be helpful

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