apemanlocale

6.0.2 • Public • Published

apemanlocale

Build Status npm Version JS Standard

Message resource for apeman project.

Installation

$ npm install apemanlocale --save

Usage

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_ERROR
RESOURCE_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_ERROR
CAPTCHA照合エラー
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.

Links

Readme

Keywords

Package Sidebar

Install

npm i apemanlocale

Weekly Downloads

229

Version

6.0.2

License

MIT

Last publish

Collaborators

  • okunishinishi