Giter Club home page Giter Club logo

Comments (9)

mashpie avatar mashpie commented on August 15, 2024

ok, I guess you didn't setup a custom storage directory in configure? That will help you mitigate that issue. Anyway I'd like to review. coul you post some more details? pwd and start command of your app would help.

from i18n-node.

djungowski avatar djungowski commented on August 15, 2024

I did setup a custom storage by simply putting

directory: './locales',

in the configure call. I'll just build a reproducable minimum and get back at you

from i18n-node.

mashpie avatar mashpie commented on August 15, 2024

I'd suggest using __dirname in your app, too as this ensures reading from same directory regardless of pwd (ie.: starting manually could be different than starting as an init service). Minimal example: https://gist.github.com/mashpie/5188567

from i18n-node.

djungowski avatar djungowski commented on August 15, 2024

How to reproduce

Step 1. Create empty dir
Step 2. Create directory "locales" in directory
Step 3. Install i18n and express.js:
sudo npm install i18n express
Step 4. Run the following command and see that there is no locales directory
ls node_modules/i18n/
Step 5. Create a basic node-server

var express = require('express');
var i18n = require('i18n');

var app = express();
// i18n config
i18n.configure({
    locales: ['en', 'de']
});

app.configure(function() {
    app.use(i18n.init);
});

app.get('/hello.txt', function(req, res){
  res.send('Hello World');
});

app.listen(80);

Step 6. Start the server
Step 7. See that command from Step 4. shows a locales directory that has 2 files de.json and en.json
Step 8. See that the locales folder that should have been used remains empty
ls locales

from i18n-node.

mashpie avatar mashpie commented on August 15, 2024

looks obvious, as i18n would try to write json inside it's own directory. You need to configure locales directory in your app, esp. when i18n installed globally. The default behavior is just fine for packaged deploys, using i18n with global installs requires setting that directory in your app server, or you'd end up using the same locales for each app running on the same server. And you won't be able to deploy finally translated files alongside with your app.

from i18n-node.

djungowski avatar djungowski commented on August 15, 2024

Point is, i didn't install it globally, otherwise the npm command would have had a "-g"

If the behavior is intended, maybe only the readme needs an update

from i18n-node.

mashpie avatar mashpie commented on August 15, 2024

i18n defaults to write into it's own node_modules/i18n/locales directory. if you want to store locales in a different location you have to tell so, by adding a directory config.

from i18n-node.

djungowski avatar djungowski commented on August 15, 2024

Ok, then obviously I just misunderstood the readme ;)

from i18n-node.

mashpie avatar mashpie commented on August 15, 2024

hm, I agree READM is not that clear. I'll point out - and leave this ticket open until done. Thanks for pointing out!

from i18n-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.