aboutsummaryrefslogtreecommitdiff
path: root/node_modules/os-locale
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
committerDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
commit3c51c3be85bb0d1bdb87ea0d6632f1c256912f27 (patch)
treec7ccc8279b12c4f7bdbbb4270d617e48f51722e4 /node_modules/os-locale
parent412c104bebc507bea9c94fd53b5bdc4b64cbfe31 (diff)
downloadwebsite-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.tar.gz
website-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.zip
build: Add some required modules for node
Diffstat (limited to 'node_modules/os-locale')
-rw-r--r--node_modules/os-locale/index.js101
-rw-r--r--node_modules/os-locale/license21
-rw-r--r--node_modules/os-locale/package.json81
-rw-r--r--node_modules/os-locale/readme.md53
4 files changed, 256 insertions, 0 deletions
diff --git a/node_modules/os-locale/index.js b/node_modules/os-locale/index.js
new file mode 100644
index 0000000..1ada7a4
--- /dev/null
+++ b/node_modules/os-locale/index.js
@@ -0,0 +1,101 @@
+'use strict';
+const execa = require('execa');
+const lcid = require('lcid');
+const mem = require('mem');
+
+const defaultOpts = {spawn: true};
+const defaultLocale = 'en_US';
+
+function getEnvLocale(env) {
+ env = env || process.env;
+ return env.LC_ALL || env.LC_MESSAGES || env.LANG || env.LANGUAGE;
+}
+
+function parseLocale(x) {
+ const env = x.split('\n').reduce((env, def) => {
+ def = def.split('=');
+ env[def[0]] = def[1].replace(/^"|"$/g, '');
+ return env;
+ }, {});
+ return getEnvLocale(env);
+}
+
+function getLocale(str) {
+ return (str && str.replace(/[.:].*/, ''));
+}
+
+function getAppleLocale() {
+ return execa.stdout('defaults', ['read', '-g', 'AppleLocale']);
+}
+
+function getAppleLocaleSync() {
+ return execa.sync('defaults', ['read', '-g', 'AppleLocale']).stdout;
+}
+
+function getUnixLocale() {
+ if (process.platform === 'darwin') {
+ return getAppleLocale();
+ }
+
+ return execa.stdout('locale')
+ .then(stdout => getLocale(parseLocale(stdout)));
+}
+
+function getUnixLocaleSync() {
+ if (process.platform === 'darwin') {
+ return getAppleLocaleSync();
+ }
+
+ return getLocale(parseLocale(execa.sync('locale').stdout));
+}
+
+function getWinLocale() {
+ return execa.stdout('wmic', ['os', 'get', 'locale'])
+ .then(stdout => {
+ const lcidCode = parseInt(stdout.replace('Locale', ''), 16);
+ return lcid.from(lcidCode);
+ });
+}
+
+function getWinLocaleSync() {
+ const stdout = execa.sync('wmic', ['os', 'get', 'locale']).stdout;
+ const lcidCode = parseInt(stdout.replace('Locale', ''), 16);
+ return lcid.from(lcidCode);
+}
+
+module.exports = mem(opts => {
+ opts = opts || defaultOpts;
+ const envLocale = getEnvLocale();
+ let thenable;
+
+ if (envLocale || opts.spawn === false) {
+ thenable = Promise.resolve(getLocale(envLocale));
+ } else if (process.platform === 'win32') {
+ thenable = getWinLocale();
+ } else {
+ thenable = getUnixLocale();
+ }
+
+ return thenable.then(locale => locale || defaultLocale)
+ .catch(() => defaultLocale);
+});
+
+module.exports.sync = mem(opts => {
+ opts = opts || defaultOpts;
+ const envLocale = getEnvLocale();
+ let res;
+
+ if (envLocale || opts.spawn === false) {
+ res = getLocale(envLocale);
+ } else {
+ try {
+ if (process.platform === 'win32') {
+ res = getWinLocaleSync();
+ } else {
+ res = getUnixLocaleSync();
+ }
+ } catch (err) {}
+ }
+
+ return res || defaultLocale;
+});
diff --git a/node_modules/os-locale/license b/node_modules/os-locale/license
new file mode 100644
index 0000000..654d0bf
--- /dev/null
+++ b/node_modules/os-locale/license
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/node_modules/os-locale/package.json b/node_modules/os-locale/package.json
new file mode 100644
index 0000000..2c05663
--- /dev/null
+++ b/node_modules/os-locale/package.json
@@ -0,0 +1,81 @@
+{
+ "_args": [
+ [
+ "os-locale@2.1.0",
+ "/home/dstaesse/git/website"
+ ]
+ ],
+ "_development": true,
+ "_from": "os-locale@2.1.0",
+ "_id": "os-locale@2.1.0",
+ "_inBundle": false,
+ "_integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==",
+ "_location": "/os-locale",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "version",
+ "registry": true,
+ "raw": "os-locale@2.1.0",
+ "name": "os-locale",
+ "escapedName": "os-locale",
+ "rawSpec": "2.1.0",
+ "saveSpec": null,
+ "fetchSpec": "2.1.0"
+ },
+ "_requiredBy": [
+ "/yargs"
+ ],
+ "_resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz",
+ "_spec": "2.1.0",
+ "_where": "/home/dstaesse/git/website",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "bugs": {
+ "url": "https://github.com/sindresorhus/os-locale/issues"
+ },
+ "dependencies": {
+ "execa": "^0.7.0",
+ "lcid": "^1.0.0",
+ "mem": "^1.1.0"
+ },
+ "description": "Get the system locale",
+ "devDependencies": {
+ "ava": "*",
+ "import-fresh": "^2.0.0",
+ "xo": "*"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/sindresorhus/os-locale#readme",
+ "keywords": [
+ "locale",
+ "lang",
+ "language",
+ "system",
+ "os",
+ "string",
+ "str",
+ "user",
+ "country",
+ "id",
+ "identifier",
+ "region"
+ ],
+ "license": "MIT",
+ "name": "os-locale",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/sindresorhus/os-locale.git"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "version": "2.1.0"
+}
diff --git a/node_modules/os-locale/readme.md b/node_modules/os-locale/readme.md
new file mode 100644
index 0000000..7c80d33
--- /dev/null
+++ b/node_modules/os-locale/readme.md
@@ -0,0 +1,53 @@
+# os-locale [![Build Status](https://travis-ci.org/sindresorhus/os-locale.svg?branch=master)](https://travis-ci.org/sindresorhus/os-locale)
+
+> Get the system [locale](https://en.wikipedia.org/wiki/Locale_(computer_software))
+
+Useful for localizing your module or app.
+
+POSIX systems: The returned locale refers to the [`LC_MESSAGE`](http://www.gnu.org/software/libc/manual/html_node/Locale-Categories.html#Locale-Categories) category, suitable for selecting the language used in the user interface for message translation.
+
+
+## Install
+
+```
+$ npm install --save os-locale
+```
+
+
+## Usage
+
+```js
+const osLocale = require('os-locale');
+
+osLocale().then(locale => {
+ console.log(locale);
+ //=> 'en_US'
+});
+```
+
+
+## API
+
+### osLocale([options])
+
+Returns a `Promise` for the locale.
+
+### osLocale.sync([options])
+
+Returns the locale.
+
+#### options
+
+Type: `Object`
+
+##### spawn
+
+Type: `boolean`<br>
+Default: `true`
+
+Set to `false` to avoid spawning subprocesses and instead only resolve the locale from environment variables.
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)