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.11
  • latest
  • 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

You must first set up nodejs from https://nodejs.org

$ 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

main.js

/// 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}`)

Try


$ node main

en-us : Language Manager

Change Language

.
..
...

/// 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

> node tests

Simple Test Tool
==================================================
Is the instance initialized?
Success
--------------------------------------------------
Get resource item with name. Simple Zero Configure?
Success
--------------------------------------------------
Get resource item with name. Zero Configure?
Success
--------------------------------------------------
Get resource item with name. Full Configure?
Success
--------------------------------------------------
Get resource item with name. Full Configure TR?
Success
--------------------------------------------------

Pipelines

Build Status

NPM

Keywords

FAQs

Package last updated on 03 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