os-lang
v3.3.1
Published
Get the system lang
Downloads
171
Maintainers
Readme
os-lang
Get the system lang
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:
- simple use
import { osLang, osLangSync } from 'os-lang'
const lang = osLangSync()
// lang => zh-CN
- 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.