Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

merged

  • Loading branch information...
commit 90f98887ade6795ff915188d2442032e7eae2404 2 parents 3fcece0 + aa4b821
louis authored
Showing with 8 additions and 6 deletions.
  1. +1 −1  README.md
  2. +7 −5 lib/node-i18n.js
2  README.md
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.
12 lib/node-i18n.js
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) {
Please sign in to comment.
Something went wrong with that request. Please try again.