Skip to content

A cross platform alternative to get locales used on the platform. Works on Node, Electron, NW.js and Browsers

Notifications You must be signed in to change notification settings

skymen/getOsLocalesCrossPlatform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

getOsLocalesCrossPlatform

A cross platform alternative to get locales used on the platform. Works on Node, Electron, NW.js and Browsers

This script is largely based on https://github.com/sindresorhus/os-locale

What I did is compile everything on a single script and add browser compatibility.

The scripts exports only one function to the global scope

getOsLocales([options])

options - Object with two parameters

spawn - Boolean . Set to false if you want the function to try and get the locale without spawning any child processes. Doesn't do anything on browser.

defaultLocale - String . The default locale to fallback to if nothing else works.

You can import this module using these:

const getOsLocales = require("getoslocalescrossplatform");
import getOsLocales from "getoslocalescrossplatform";

Or by integrating the file directly

import getOsLocales from "./getOsLocalesCrossPlatform.js";
<script src="./getOsLocalesCrossPlatform.js"/>

Or by executing the content of the file and using the global function getOsLocales() it creates on the global scope.

Look at examples in the examples folder for common use cases

About

A cross platform alternative to get locales used on the platform. Works on Node, Electron, NW.js and Browsers

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published