Permalink
Browse files

fixed multiple files

  • Loading branch information...
1 parent 83db2bd commit aa4b8218c4faa128f8056456ee0a630db109b8ac Guillaume Denis committed Sep 18, 2012
Showing with 9 additions and 7 deletions.
  1. +1 −1 README.md
  2. +7 −5 lib/node-i18n.js
  3. +1 −1 package.json
View
@@ -59,7 +59,7 @@ As `en` is set to be the default, when making a request to `/en/products` you wi
#### Translation files
Every translation file is JSON and must end with .json
-You can have as many file you want for each locale. This let you seperate content.
+You can have as many files as you want for each locale. This let you seperate content.
For example : `en.json` `header_en.json` `footer_en.json`
<br/>
Each file start with the `locale` key.
View
@@ -33,11 +33,13 @@ module.exports = function (options) {
this.files = fs.readdirSync(this.options.dir)
this.load = function(){
- _.each(this.files, function(file){
- this.words = _.extend(self.words, require(self.options.dir + '/' + file))
- })
- return this
- }
+ _.each(this.files, function(file){
+ fileContents = require(self.options.dir + '/' + file)
+ fileLocale = _.keys(fileContents)[0]
+ self.words[fileLocale] = _.extend(self.words[fileLocale] || {}, fileContents[fileLocale])
+ })
+ return this
+ }
this.translateHelper = function(locale){
return function(key, variables, forcedLocale) {
View
@@ -3,7 +3,7 @@
"description": "i18n for node with expressJS",
"main": "./index",
"author": "Larafale & silently",
- "version": "0.0.9",
+ "version": "0.0.10",
"repository": {
"type": "git",
"url": "http://github.com/larafale/node-i18n.git"

0 comments on commit aa4b821

Please sign in to comment.