ilib
Version:
iLib is a cross-engine library of internationalization (i18n) classes written in pure JS
1 lines • 1.06 kB
JavaScript
module.exports=function(ilib){function NodeLoader(ilib){this.parent.call(this,ilib),this.root=process.cwd(),this.base="undefined"!=typeof module&&module.filename?path.join(path.dirname(module.filename),".."):this.root,this._exists(this.root,"resources"),this._exists(path.join(this.root,"locale"),"localeinfo.json"),this._exists(path.join(this.base,"locale"),"localeinfo.json"),this._exists("/usr/share/javascript/ilib/locale","localeinfo.json")}var path=require("./Path.js"),fs=require("fs"),Loader=(require("util"),require("./Loader.js"));return(NodeLoader.prototype=new Loader).parent=Loader,(NodeLoader.prototype.constructor=NodeLoader).prototype.name="NodeLoader",NodeLoader.prototype._loadFile=function(pathname,sync,cb){var text;try{text=fs.readFileSync(pathname,"utf-8"),"function"==typeof cb&&cb(text)}catch(e){"function"==typeof cb&&cb()}return text},NodeLoader.prototype._exists=function(dir,file){file=path.normalize(path.join(dir,file));-1===this.includePath.indexOf(file)&&fs.existsSync(file)&&this.includePath.push(dir)},new NodeLoader(ilib)};