apemanlocale
v6.0.2
Published
Message resource for apeman project.
Readme
apemanlocale
Message resource for apeman project.
Installation
$ npm install apemanlocale --saveUsage
Create a directory with name "loc" and put locale files like "en.json" there.
loc/en.json
{
"keys": {
"APP_NAME": "hello-world"
},
"titles": {
"WELCOME_TITLE": "Welcome to #{keys.APP_NAME}!"
}
}loc/index.js
'use strict'
const apemanlocale = require('apemanlocale')
// Exports locales as module.
let locales = apemanlocale(__dirname, {
// Options
})
// Print all locales
locales.print()
module.exports = locales
Then,
'use strict'
// Require defined locales
const loc = require('./loc/index.js')
let en = loc('en')
console.log(en.titles.WELCOME_TITLE) // -> "Welcome to hello-world!"
Signature
apemanlocale(dirname, options) -> object
Define locale message resource.
Args
| Name | Type | Default | Description | | --- | ---- | --- | --- | | dirname | string | locales | Directory path which contains locale messages. | | options | object | | Optional settings. | | options.default | object | en | Default lang. | | options.fallback | boolean | | Use default lang as fallback | | options.buildin | boolean | | Use buildin langs |
Build-in messages
| Key | Message | | --- | ------- | | errors.RESOURCE_DATA_CONFLICT_ERROR | RESOURCE_DATA_CONFLICT_ERRORリソースデータ競合エラー | | errors.RESOURCE_DATA_ERROR | RESOURCE_DATA_ERRORリソースデータエラー | | errors.RESOURCE_DATA_MISSING_ERROR | RESOURCE_DATA_MISSING_ERRORリソースデータ欠落エラー | | errors.RESOURCE_ERROR | RESOURCE_ERRORリソースエラー | | errors.RESOURCE_INCLUDE_ERROR | RESOURCE_INCLUDE_ERRORリソースインクルードエラー | | errors.RESOURCE_INCLUDE_INVALID_ERROR | RESOURCE_INCLUDE_INVALID_ERRORRESOURCE_INCLUDE_INVALID_ERROR | | errors.RESOURCE_NOT_FOUND_ERROR | RESOURCE_NOT_FOUND_ERROR未検出エラー | | errors.RESOURCE_TYPE_ERROR | RESOURCE_TYPE_ERRORリソース種別エラー | | errors.RESOURCE_TYPE_INVALID_ERROR | RESOURCE_TYPE_INVALID_ERRORリソース種別不正エラー | | errors.RESOURCE_TYPE_MISSING_ERROR | RESOURCE_TYPE_MISSING_ERRORリソース種別欠落エラー | | errors.RESOURCE_VR_ERROR | RESOURCE_VR_ERRORリソースバージョンエラー | | errors.RESOURCE_VR_TYPE_ERROR | RESOURCE_VR_TYPE_ERRORリソースバージョン種別エラー | | errors.SIGN_CAPTCHA_WRONG_ERROR | SIGN_CAPTCHA_WRONG_ERRORCAPTCHA照合エラー | | errors.SIGN_ERROR | SIGN_ERRORログインエラー | | errors.SIGN_FORM_WRONG_ERROR | SIGN_FORM_WRONG_ERRORログイン入力内容エラー | | errors.SOMETHING_WRONG_ERROR | SOMETHING_WRONG_ERROR不明なエラー | | errors.VALUE_DUPLICATE_ERROR | VALUE_DUPLICATE_ERROR文字列重複エラー | | errors.VALUE_ERROR | VALUE_ERROR値エラー | | errors.VALUE_INVALID_ERROR | VALUE_INVALID_ERROR値不正エラー | | errors.VALUE_MISSING_ERROR | VALUE_MISSING_ERROR値欠落エラー | | errors.VALUE_NUMBER_ERROR | VALUE_NUMBER_ERROR数値エラー | | errors.VALUE_NUMBER_INVALID_ERROR | VALUE_NUMBER_INVALID_ERROR数値不正エラー | | errors.VALUE_NUMBER_TOO_LARGE_ERROR | VALUE_NUMBER_TOO_LARGE_ERROR数値上限エラー | | errors.VALUE_NUMBER_TOO_SMALL_ERROR | VALUE_NUMBER_TOO_SMALL_ERROR数値下限エラー | | errors.VALUE_STRING_ERROR | VALUE_STRING_ERROR文字列エラー | | errors.VALUE_STRING_INVALID_ERROR | VALUE_STRING_INVALID_ERROR文字列不正エラー | | errors.VALUE_STRING_TOO_LONG_ERROR | VALUE_STRING_TOO_LONG_ERROR文字列長上限エラー | | errors.VALUE_STRING_TOO_SHORT_ERROR | VALUE_STRING_TOO_SHORT_ERROR文字列長下限エラー | | errors.VALUE_TYPE_ERROR | VALUE_TYPE_ERROR値種別エラー | | errors.VALUE_TYPE_INVALID_ERROR | VALUE_TYPE_INVALID_ERROR値種別不正エラー | | status.400 | Bad Request不正なリクエスト | | status.401 | Authentication is required認証が必要です | | status.403 | You don't have permissions権限がありません | | status.404 | Could not find resourceリソースが見つかりません | | status.500 | Something wrong with the serverサーバーでエラーが発生しました | | status.502 | Bad gateway errorゲートウェイエラー | | status.503 | Server not available混雑中 |
License
This software is released under the MIT License.
