Comments (9)
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.
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.
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.
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.
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.
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.
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.
Ok, then obviously I just misunderstood the readme ;)
from i18n-node.
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)
- how to pass a default translation if a phrase isnt existed in the en.json file HOT 3
- Locales are case sensitive HOT 3
- __h has strange behavior when he doesn't have the key HOT 1
- [Discussion] Contrast reports path traversal vulnerability HOT 4
- [Discussion] Allow a parser option to customize storage format HOT 2
- Maximum call stack size exceeded with some settings HOT 4
- Get string from locale file without substitution HOT 4
- passing a zero number value (0) incorrectly returns the full json string, brackets and all, without injecting the replacement value HOT 3
- When i18n is packaged into exe cannot be used, i18n directory cannot find the files under the directory path. HOT 3
- yml parser TypeScript and locale issues
- [Bug] translation API is returning `undefined` when provided locale is `undefined` or `null`
- There are no 0.15.1 release and tag.
- There are no 0.15.1 release and tag. HOT 1
- i18n ignores en.json language file HOT 1
- Error: Cannot find module Cyclic.sh sever HOT 1
- Problems with local files HOT 3
- ES Modules HOT 9
- feature request: support plurals with specific numbers HOT 5
- Readonly environment HOT 2
- `__n` not working as per documentation in the description
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from i18n-node.