Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

language-manager

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

language-manager

The most flexible version of multi-language management. Manages language resources. Makes it easy to switch between different language sources.

  • 0.0.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-93.75%
Maintainers
1
Weekly downloads
 
Created
Source

language-manager

The most flexible version of multi-language management. Manages language resources. Makes it easy to switch between different language sources.

Install

$ npm i -g npm
$ npm i --save language-manager

Add Resource

Place the file containing the source language definitions in a folder. For example, "tests/resource".

example.com/                # → Root folder for the project
└── tests/                  # → Tests folder
    └── resource/           # → Resource Folder       .setPath('tests/resource') 
        └── json/           # → Resource Type Folder  .setType(LanguageManager.ResourceType.Json)
            ├── en-us.json  # → Resource              language.extention English United States
            └── tr-tr.json  # → Resource              language.extention Turkish Turkey

Sample Resource File

en-us.json

{
  "root": {
    "data": [
      {
        "type": "string",
        "name": "app.name",
        "value": "Language Manager"
      },
      {
        "type": "string",
        "name": "words.ok",
        "value": "Okay"
      }
    ]
  }
}

tr-tr.json

{
  "root": {
    "data": [
      {
        "type": "string",
        "name": "app.name",
        "value": "Dil Yöneticisi"
      },
      {
        "type": "string",
        "name": "words.ok",
        "value": "Tamam"
      }
    ]
  }
}

Usage

/// Language Manager Reference
var LanguageManager = require('language-manager')

/// Test object
var l = new LanguageManager()
  // Resource Type format
  .setType(LanguageManager.ResourceType.Json)
  // Resource file folder
  .setPath('tests/resource')
  // Resource language code
  .setLang('en-us')

/// Expected test result
var expected = 'Language Manager'
/// Actual test result
var actual = l
  // Get resource item value string
  .Val('app.name')

// Test output
console.log(`${l.Lang} : ${actual}`)

en-us : Language Manager

/// Change language
l.setLang('tr-tr')

/// Expected test result
expected = 'Dil Yöneticisi'
/// Actual test result
actual = l
  // Get resource item value string
  .Val('app.name')

// Test output
console.log(`${l.Lang} : ${actual}`)

tr-tr : Dil Yöneticisi

Test

$ npm run test

Pipelines

Build Status

NPM

Keywords

FAQs

Package last updated on 01 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc