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

Using namespaces #12

Closed
valichek opened this issue Sep 11, 2015 · 3 comments
Closed

Using namespaces #12

valichek opened this issue Sep 11, 2015 · 3 comments

Comments

@valichek
Copy link

I do have following setup:

instance.setup({
        resGetPath: 'locale/__lng__/__ns__.json',
        lng: 'de-DE',
        attributes: ['t', 'i18n'],
        getAsync: true,
        sendMissing: false,
        fallbackLng: 'en',
        debug: false
      });

I have default translation.json and nav.json
Default namespace works fine:

tr('myProp'); // => 'fine'
tr('translation:myProp'); // => 'fine'

but nav namespace do not:

tr('nav:myProp'); // => 'nav:myProp'

Have checked the log, but nav.json is never loaded.

@zewa666
Copy link
Member

zewa666 commented Sep 11, 2015

Translation is the default namespace thus this one always works.
I think you have to register multiple namespaces during setup phase. Take a look here http://i18next.com/pages/doc_init.html and search for Multiple namespace:.

If I understand correctly just adding the next to the setup should be enough:

namespaces: ['nav'],

not sure if you need to include translation as well, haven't tried it myself.

@valichek
Copy link
Author

thx, @zewa666 , just checked that
here is correct config for my case

instance.setup({
        resGetPath: 'locale/__lng__/__ns__.json',
        lng: 'de-DE',
        attributes: ['t', 'i18n'],
        getAsync: true,
        sendMissing: false,
        fallbackLng: 'en',
        debug: false,
        ns: { 
          namespaces: ['translation','nav'],
          defaultNs: 'translation'
        }

      });

If we define namespaces, the defaultNs property has to be set explicitly

@zewa666
Copy link
Member

zewa666 commented Sep 11, 2015

perfect, good to know and thanks for sharing the insights ... may I ask you to create a PR updating the README and put that information in? Also make sure you you've signed our CLA

zewa666 added a commit that referenced this issue Oct 6, 2015
add information on how to use multiple namespaces

fixes issue #12
@zewa666 zewa666 closed this as completed Oct 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants