ilib
Version:
iLib is a cross-engine library of internationalization (i18n) classes written in pure JS
1 lines • 1.14 kB
JavaScript
importPackage(java.io);var ilib=require("./ilib.js"),path=require("./Path.js"),Loader=require("./Loader.js"),RhinoLoader=function(){this.parent.call(this,ilib),this.root=module.resolve("..")||environment["user.dir"],this.root=this.root.replace("file://",""),"/"===this.root[this.root.length-1]&&(this.root=this.root.substring(0,this.root.length-1)),this.includePath.push(path.join(this.root,"resources")),this._exists(path.join(this.root,"locale"),"localeinfo.json")};RhinoLoader.prototype=new Loader(),RhinoLoader.prototype.parent=Loader,(RhinoLoader.prototype.constructor=RhinoLoader).prototype._loadFile=function(pathname,sync,cb){var text="";try{for(var tmp,reader=new BufferedReader(new InputStreamReader(new FileInputStream(pathname),"utf-8"));null!==(tmp=reader.readLine());)text+=tmp+"\n"}catch(e){text=void 0}finally{if(reader)try{reader.close()}catch(e2){}cb&&"function"==typeof cb&&cb(text)}return text},RhinoLoader.prototype._exists=function(dir,file){file=path.normalize(path.join(dir,file));try{var f=new File(file);f.exists()&&f.canRead()&&this.includePath.push(dir)}catch(e){console.log(e)}},module.exports=RhinoLoader;