Socket
Socket
Sign inDemoInstall

os-lang

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

os-lang

Get the system lang


Version published
Weekly downloads
24
decreased by-31.43%
Maintainers
1
Weekly downloads
 
Created
Source

os-lang

Get the system lang

NPM version Codacy Badge Test coverage npm download License

Sonar

Install

# use pnpm
$ pnpm install -D os-lang

# use yarn
$ yarn add -D os-lang

# use npm
$ npm install -D os-lang

Usage

use import

import {
  // getWinLang, // get windows lang
  // getWinLangSync,// get windows lang sync
  // getMacLang, // get mac os lang
  // getMacLangSync, // get mac os lang sync
  // getUnixLang, // get unix lang
  // getUnixLangSync, // get unix lang sync
  getEnvLang,
  osLang,
  osLangSync
} from 'os-lang'

osLang()
// or
osLangSync()

use require

const { osLang, osLangSync } = require('os-lang')

osLang()
// or
osLangSync()

API reference

  • Usage: osLang(options) & osLangSync(options)

  • Parameters: none

  • Types:

declare function getEnvLang(env?: NodeJS.ProcessEnv): string | undefined

declare function getMacLang(): Promise<string>

declare function getMacLangSync(): string

declare function getUnixLang(): Promise<string | undefined>

declare function getUnixLangSync(): string | undefined

declare function getWinLang(): Promise<string | undefined>

declare function getWinLangSync(): string | undefined

declare type Lang = 'en-US' | 'zh-CN' | string

declare function osLang(options?: OsLangOptions): Promise<any>

declare function osLangSync(options?: OsLangOptions): any
  • Demos:
  1. simple use
import { osLang, osLangSync } from 'os-lang'

const lang = osLangSync()
// lang => zh-CN
  1. Only resolve the locale from environment variables.
import { getEnvLang } from 'os-lang'

const lang = getEnvLang()
// lang => zh-CN

Issues & Support

Please open an issue here.

License

MIT

Keywords

FAQs

Package last updated on 02 Jul 2023

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