Skip to content
Browse files

fixed scope problems

  • Loading branch information...
1 parent 3438b95 commit a292053bdeaefb5144cccc3eb421fedd623e1169 @larafale committed Oct 29, 2012
Showing with 12 additions and 13 deletions.
  1. +11 −12 lib/node-i18n.js
  2. +1 −1 package.json
View
23 lib/node-i18n.js
@@ -35,7 +35,6 @@ module.exports = function (options) {
var i18n = function(){
var self = this
-
this.options = options
this.words = {}
this.files = fs.readdirSync(this.options.dir)
@@ -44,23 +43,23 @@ module.exports = function (options) {
this.load = function(){
_.each(this.files, function(file){
- fileContents = require(self.options.dir + '/' + file)
- fileLocale = _.keys(fileContents)[0]
+ 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) {
- return self.translate(forcedLocale || locale, key, variables)
+ this.translateHelper = function(current){
+ return function(key, variables, force) {
+ return self.translate(force || current, key, variables)
}
}
- this.pathHelper = function(locale){
- return function(path, forcedLocale) {
- locale = forcedLocale || locale || self.options.default
- var reg = new RegExp("^\/("+self.options.enabled.join("|")+")\/?.*$")
+ this.pathHelper = function(current){
+ return function(path, force) {
+ var locale = force || current || self.options.default
+ , reg = new RegExp("^\/("+self.options.enabled.join("|")+")\/?.*$")
if(reg.test(path)) path = path.substring(3)
return (locale === self.options.default) ? path : '/' + locale + path
@@ -88,7 +87,7 @@ module.exports = function (options) {
this.translate = function(locale, key, variables){
if(typeof(variables) === 'string') {
- locale = variables
+ locale = variables
variables = {}
}
@@ -112,7 +111,7 @@ module.exports = function (options) {
})
//replace labels
- _.each(findLabels(word), function(label) { word = word.replace(new RegExp("{{" + label + "}}"), variables[label]) })
+ _.each(findLabels(word), function(label) { word = word.replace(new RegExp("{{" + label + "}}"), variables[label]) })
return word
View
2 package.json
@@ -5,7 +5,7 @@
"author": {
"name": "Larafale & silently"
},
- "version": "0.0.19",
+ "version": "0.0.2",
"repository": {
"type": "git",
"url": "http://github.com/larafale/node-i18n.git"

0 comments on commit a292053

Please sign in to comment.
Something went wrong with that request. Please try again.