Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Maintainers
1
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

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

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