the "locales" directory tries to load from curdir, not from __dirname #24

Closed
brettcave opened this Issue Jun 7, 2012 · 3 comments

Comments

Projects
None yet
2 participants

If I have a node application in /path/to/myapp, with /path/to/myapp/app.js as the runner and /path/to/myapp/locales with i18n language definitions in, then i18n works if I:

cd /path/to/myapp
node app.js

however, if i start the app from outside the directory, i18n does not load up locales, searching within the current dir:

cd /path/to
node myapp/app.js

No languages will load in the 2nd instance.

Owner

mashpie commented Jun 11, 2012

for now you might want to change default setting of your directory, i.e.:

i18n.configure({
  locales: ['en', 'de'],
  register: global,
  directory: '/path/to/myapp/locales',
});

Or just set that dynamic by using __dirname in your configure statement.
I'll leave that issue open as I think, using __dirname/locales as default setting sound like a good option.
Thanks!

@ghost ghost assigned mashpie Jun 11, 2012

Hi mashpie,

I had a look at the source and saw the directory config option, which I did not come across in the documentation (i.e. reading the README file). It works great when setting it to __dirname/locales manually.

From an implementation, I agree that defaulting would be better to use __dirname/locales as default, as I am assuming most i18n users would use it this way.

Thanks

Owner

mashpie commented Mar 16, 2013

agreed - 9 months later - sry for delay

@mashpie mashpie closed this in 9669904 Mar 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment