πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

mlstring

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mlstring

Multi-language string impl

2.0.2
latest
Source
npm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
Β 
Created
Source

mlstring module

Multi-language string implementation

MLString can be used as simple string or string with any values. Language ID is similar language in browsers f.e. en, en-us, en-gb, fr, it, ge, ru MLString's main method is toString. It gets one optional parameter: language as string. Default value is default language of browser

How to install

npm install --save mlstring 

How to use

Creation MLString object

// importing module
import MLString from 'mlstring';

// u can use default language as u want. English is default in fragment below
// 
const strEst = new MLString({
        default: "estimated", 
        values: new Map([
            ["en-US", "expected"],
            ["de", "vermutet"],
            ["fr", "censΓ©"],
            ["es", "supuesto"],
            ["uk", "ΠΎΡ‡Ρ–ΠΊΡƒΠ²Π°Π½ΠΈΠΉ"],
            ["ru", "ΠΎΠΆΠΈΠ΄Π°Π΅ΠΌΡ‹ΠΉ"]])
    });
const strEstOneLang = new MLString("estimated");

Use with default language in browser

console.log(String(strEst)); // anywhere default casting to string

or

console.log(strEst.toString());

Static function getting default language ID string from browser

First, searching the 'lang' parameter in url (GET parameter, for exmpl: https://domain.com/chapter?lang=fr). If 'lang' parameter is absent, then returned variable of language is assigned by the first preffered language from browser

Keywords

multi-language

FAQs

Package last updated on 28 Nov 2022

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