How to use os-locale - 10 common examples

To help you get started, we’ve selected a few os-locale examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github beakerbrowser / beaker / app / bg / lib / spell-checker.js View on Github external
'doesn',
    'hadn',
    'hasn',
    'mightn',
    'mustn',
    'needn',
    'oughtn',
    'shan',
    'shouldn',
    'wasn',
    'weren',
    'wouldn'
]

// Hunspell requires a fully-qualified locale
export const locale = osLocale.sync().replace('-', '_')

export const setup = function () {
    // Need to set LANG env variable so node spellcheck can find its default language
    if (!process.env.LANG) {
        process.env.LANG = locale
    }

    if (process.platform === 'linux') {
        setupLinux(locale)
    } else if (process.platform === 'win32' && semver.lt(os.release(), '8.0.0')) {
        setupWin7AndEarlier(locale)
    } else {
        // OSX and Windows 8+ have OS-level spellcheck APIs
        console.info('Using OS spell check API')
    }
}
github RyanFleck / Projects / js / React / server-frontend / node_modules / yargs / yargs.js View on Github external
function guessLocale () {
    if (!detectLocale) return

    try {
      const osLocale = require('os-locale')
      self.locale(osLocale.sync({ spawn: false }))
    } catch (err) {
      // if we explode looking up locale just noop
      // we'll keep using the default language 'en'.
    }
  }
github fengjundev / DoubanMovie-React-Native / node_modules / react-native / node_modules / yargs / index.js View on Github external
function guessLocale () {
    if (!detectLocale) return

    try {
      var osLocale = require('os-locale')
      self.locale(osLocale.sync({ spawn: false }))
    } catch (err) {
      // if we explode looking up locale just noop
      // we'll keep using the default language 'en'.
    }
  }
github publiclab / Leaflet.DistortableImage / node_modules / yargs / yargs.js View on Github external
function guessLocale () {
    if (!detectLocale) return

    try {
      const osLocale = require('os-locale')
      self.locale(osLocale.sync({ spawn: false }))
    } catch (err) {
      // if we explode looking up locale just noop
      // we'll keep using the default language 'en'.
    }
  }
github EightShapes / contrast-grid / node_modules / yargs / yargs.js View on Github external
function guessLocale () {
    if (!detectLocale) return

    try {
      const osLocale = require('os-locale')
      self.locale(osLocale.sync({ spawn: false }))
    } catch (err) {
      // if we explode looking up locale just noop
      // we'll keep using the default language 'en'.
    }
  }
github Andyliwr / FE-learning-load / task08 / lidikang / styles / node_modules / yargs / yargs.js View on Github external
function guessLocale () {
    if (!detectLocale) return

    try {
      const osLocale = require('os-locale')
      self.locale(osLocale.sync({ spawn: false }))
    } catch (err) {
      // if we explode looking up locale just noop
      // we'll keep using the default language 'en'.
    }
  }
github z------------- / CPod / lib / i18n.js View on Github external
i18n.getLocale = function() {
  if (!cache.locale) {
    let systemLocale = osLocale.sync();
    let availableLocales = i18n.getAvailableLocales();
    if (availableLocales.indexOf(systemLocale) !== -1) {
      cache.locale = systemLocale;
    } else if (availableLocales.indexOf(systemLocale.split("_")[0]) !== -1) {
      cache.locale = systemLocale.split("_")[0];
    } else {
      var looseLocaleMatch;
      for (let i = 0, l = availableLocales.length; i < l; i++) {
        if (availableLocales[i].split("_")[0] === systemLocale.split("_")[0]) {
          looseLocaleMatch = availableLocales[i];
          break;
        }
      }
      if (looseLocaleMatch) {
        cache.locale = looseLocaleMatch;
      } else {
github unfoldingWord / translationCore / src / js / actions / LocaleActions.js View on Github external
const setSystemLocale = (dispatch, languages, translations) => {
  return osLocale().then(locale => {
    console.log(`System Locale: ${locale}`);
    setActiveLanguageSafely(dispatch, locale, languages, translations);
  });
};
github mozilla / addons-linter / src / utils.js View on Github external
export function getLocale() {
  return osLocale.sync();
}
github alibaba / serverless-vscode / src / hovers / ROSTemplateHoverProvider.ts View on Github external
function getLocalDoc(schema: JSONSchema): string {
  const language = osLocale.sync();
  if (schema.document) {
    return (language && schema.document[language]) || schema.document['default'];
  }
  return ''
}

os-locale

Get the system locale

MIT
Latest version published 2 years ago

Package Health Score

77 / 100
Full package analysis

Popular os-locale functions