Nihilistic Party Mantra

    sg-localization-selector

    1.0.0 • Public • Published

    sg-localization-selector

    sg-accept-language-parser 이후에 지정된 스키마를 넣으면 로컬라이제이션이 설정됩니다. express.js 전용 미들웨어입니다.

    Installation

    npm install --save sg-localization-selector

    Examples

    const selector = require('sg-localization-selector')
    const parser = require('sg-accept-language-parser')
    const express = require('express');
    const app = express();
     
    // 반드시 selector는 parser 이후에 사용해야 합니다.
    app.use(parser())
     
    let local = {
        "defaultLocale": "KR",
        "defaultLanguage": "ko",
        "locales": {
            "KR": {
                "name": "대한민국",
                "enName": "Korea",
                "code": "+82",
                "timeGap": 9
            }
        },
        "languages" : {
            "ko" : {
                "name" : "한국어",
                "enName" : "KOREAN",
                "countries" : ["KR"]
            }
        }
    };
     
    app.use(selector(local))

    Usage

    (req, res, next) => {
        console.log(req.language)
        console.log(req.defaultLanguage)
        console.log(req.locale)
        console.log(req.defaultLocale)
    }

    Install

    npm i sg-localization-selector

    DownloadsWeekly Downloads

    2

    Version

    1.0.0

    License

    ISC

    Unpacked Size

    5.13 kB

    Total Files

    5

    Last publish

    Collaborators

    • hwaranglee
    • sngsng
    • piorio0919
    • kspark