Install
$ pnpm install -D os-lang
$ yarn add -D os-lang
$ npm install -D os-lang
Usage
use import
import {
getEnvLang,
osLang,
osLangSync
} from 'os-lang'
osLang()
osLangSync()
use require
const { osLang, osLangSync } = require('os-lang')
osLang()
osLangSync()
API reference
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
- simple use
import { osLang, osLangSync } from 'os-lang'
const lang = osLangSync()
- Only resolve the locale from environment variables.
import { getEnvLang } from 'os-lang'
const lang = getEnvLang()
Issues & Support
Please open an issue here.
License
MIT