resource-bundle
resource-bundle is a locale-specific resource loader based on co.
NOTE:
Resource-bundle must be used in co enviroment,such as koa.
Installation
$ npm install resource-bundle
Examples
'use strict';var co = ;var loader = ;;
message_en_US.js
like this
moduleexports = key:"value" intro:"my name is %s,in class %d" mk:"%s%s%s"
API
loader
var loader = ;var bundle = ;
loader will return ResourceBundle object ,if no resource matched ,it will return null
.
locale
- the locale of the resource. eg. "en_US",'zh_CN'.dir
- specify the root dir of the resource file. It is best to use absolute path.baseName
- the baseName of the resource.
Resource name should to be baseName_en_US.js
or baseName_en_US.json
or baseName_en.js
or baseName_en.json
or baseName.js or baseName.json format.
if no locale resource matched,it will use baseName.js or baseName.json by default.
ResourceBundle Methods
get(key,[...])
Returns a corresponding format value. format method ref util.format.