nav tabs on admin dashboard

This commit is contained in:
2019-03-07 00:20:34 -06:00
parent f73d6ae228
commit e4f473f376
11661 changed files with 216240 additions and 1544253 deletions
+94 -107
View File
@@ -1,127 +1,114 @@
'use strict';
var childProcess = require('child_process');
var execFileSync = childProcess.execFileSync;
var lcid = require('lcid');
var defaultOpts = {spawn: true};
var cache;
const execa = require('execa');
const lcid = require('lcid');
const mem = require('mem');
function fallback() {
cache = 'en_US';
return cache;
const defaultOptions = {spawn: true};
const defaultLocale = 'en_US';
function getEnvLocale(env = process.env) {
return env.LC_ALL || env.LC_MESSAGES || env.LANG || env.LANGUAGE;
}
function getEnvLocale(env) {
env = env || process.env;
var ret = env.LC_ALL || env.LC_MESSAGES || env.LANG || env.LANGUAGE;
cache = getLocale(ret);
return ret;
}
function parseLocale(x) {
var env = x.split('\n').reduce(function (env, def) {
def = def.split('=');
env[def[0]] = def[1];
function parseLocale(string) {
const env = string.split('\n').reduce((env, def) => {
const [key, value] = def.split('=');
env[key] = value.replace(/^"|"$/g, '');
return env;
}, {});
return getEnvLocale(env);
}
function getLocale(str) {
return (str && str.replace(/[.:].*/, '')) || fallback();
function getLocale(string) {
return (string && string.replace(/[.:].*/, ''));
}
module.exports = function (opts, cb) {
if (typeof opts === 'function') {
cb = opts;
opts = defaultOpts;
function getLocales() {
return execa.stdout('locale', ['-a']);
}
function getLocalesSync() {
return execa.sync('locale', ['-a']).stdout;
}
function getSupportedLocale(locale, locales = '') {
return locales.includes(locale) ? locale : defaultLocale;
}
function getAppleLocale() {
return Promise.all([
execa.stdout('defaults', ['read', '-globalDomain', 'AppleLocale']),
getLocales()
]).then(results => getSupportedLocale(results[0], results[1]));
}
function getAppleLocaleSync() {
return getSupportedLocale(
execa.sync('defaults', ['read', '-globalDomain', 'AppleLocale']).stdout,
getLocalesSync()
);
}
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']);
const lcidCode = parseInt(stdout.replace('Locale', ''), 16);
return lcid.from(lcidCode);
}
module.exports = mem((options = defaultOptions) => {
const envLocale = getEnvLocale();
let thenable;
if (envLocale || options.spawn === false) {
thenable = Promise.resolve(getLocale(envLocale));
} else if (process.platform === 'win32') {
thenable = getWinLocale();
} else {
opts = opts || defaultOpts;
thenable = getUnixLocale();
}
if (cache || getEnvLocale() || opts.spawn === false) {
setImmediate(cb, null, cache);
return;
}
return thenable
.then(locale => locale || defaultLocale)
.catch(() => defaultLocale);
});
var getAppleLocale = function () {
childProcess.execFile('defaults', ['read', '-g', 'AppleLocale'], function (err, stdout) {
if (err) {
fallback();
return;
}
module.exports.sync = mem((options = defaultOptions) => {
const envLocale = getEnvLocale();
cache = stdout.trim() || fallback();
cb(null, cache);
});
};
if (process.platform === 'win32') {
childProcess.execFile('wmic', ['os', 'get', 'locale'], function (err, stdout) {
if (err) {
fallback();
return;
}
var lcidCode = parseInt(stdout.replace('Locale', ''), 16);
cache = lcid.from(lcidCode) || fallback();
cb(null, cache);
});
let res;
if (envLocale || options.spawn === false) {
res = getLocale(envLocale);
} else {
childProcess.execFile('locale', function (err, stdout) {
if (err) {
fallback();
return;
}
var res = parseLocale(stdout);
if (!res && process.platform === 'darwin') {
getAppleLocale();
return;
}
cache = getLocale(res);
cb(null, cache);
});
}
};
module.exports.sync = function (opts) {
opts = opts || defaultOpts;
if (cache || getEnvLocale() || !execFileSync || opts.spawn === false) {
return cache;
}
if (process.platform === 'win32') {
var stdout;
try {
stdout = execFileSync('wmic', ['os', 'get', 'locale'], {encoding: 'utf8'});
} catch (err) {
return fallback();
}
var lcidCode = parseInt(stdout.replace('Locale', ''), 16);
cache = lcid.from(lcidCode) || fallback();
return cache;
res = process.platform === 'win32' ? getWinLocaleSync() : getUnixLocaleSync();
} catch (_) {}
}
var res;
try {
res = parseLocale(execFileSync('locale', {encoding: 'utf8'}));
} catch (err) {}
if (!res && process.platform === 'darwin') {
try {
cache = execFileSync('defaults', ['read', '-g', 'AppleLocale'], {encoding: 'utf8'}).trim() || fallback();
return cache;
} catch (err) {
return fallback();
}
}
cache = getLocale(res);
return cache;
};
return res || defaultLocale;
});
+4 -16
View File
@@ -1,21 +1,9 @@
The MIT License (MIT)
MIT License
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:
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 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.
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.
+20 -18
View File
@@ -1,28 +1,28 @@
{
"_from": "os-locale@^1.4.0",
"_id": "os-locale@1.4.0",
"_from": "os-locale@^3.0.0",
"_id": "os-locale@3.1.0",
"_inBundle": false,
"_integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=",
"_integrity": "sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==",
"_location": "/os-locale",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "os-locale@^1.4.0",
"raw": "os-locale@^3.0.0",
"name": "os-locale",
"escapedName": "os-locale",
"rawSpec": "^1.4.0",
"rawSpec": "^3.0.0",
"saveSpec": null,
"fetchSpec": "^1.4.0"
"fetchSpec": "^3.0.0"
},
"_requiredBy": [
"/sass-graph/yargs",
"/webpack-dev-server/yargs"
"/webpack-dev-server/yargs",
"/yargs"
],
"_resolved": "http://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz",
"_shasum": "20f9f17ae29ed345e8bde583b13d2009803c14d9",
"_spec": "os-locale@^1.4.0",
"_where": "C:\\xampp\\htdocs\\w4rpservices\\node_modules\\sass-graph\\node_modules\\yargs",
"_resolved": "https://registry.npmjs.org/os-locale/-/os-locale-3.1.0.tgz",
"_shasum": "a802a6ee17f24c10483ab9935719cef4ed16bf1a",
"_spec": "os-locale@^3.0.0",
"_where": "C:\\xampp\\htdocs\\w4rpservices\\node_modules\\yargs",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
@@ -33,17 +33,19 @@
},
"bundleDependencies": false,
"dependencies": {
"lcid": "^1.0.0"
"execa": "^1.0.0",
"lcid": "^2.0.0",
"mem": "^4.0.0"
},
"deprecated": false,
"description": "Get the system locale",
"devDependencies": {
"ava": "*",
"require-uncached": "^1.0.2",
"xo": "*"
"ava": "^1.0.1",
"import-fresh": "^3.0.0",
"xo": "^0.23.0"
},
"engines": {
"node": ">=0.10.0"
"node": ">=6"
},
"files": [
"index.js"
@@ -72,5 +74,5 @@
"scripts": {
"test": "xo && ava"
},
"version": "1.4.0"
"version": "3.1.0"
}
+34 -10
View File
@@ -1,47 +1,71 @@
# 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](http://en.wikipedia.org/wiki/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.
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-os-locale?utm_source=npm-os-locale&utm_medium=referral&utm_campaign=readme">Get professional support for 'os-locale' with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
---
## Install
```
$ npm install --save os-locale
$ npm install os-locale
```
## Usage
```js
var osLocale = require('os-locale');
const osLocale = require('os-locale');
osLocale(function (err, locale) {
console.log(locale);
(async () => {
console.log(await osLocale());
//=> 'en_US'
});
})();
```
## API
### osLocale([options], callback(error, locale))
### osLocale([options])
Returns a `Promise` for the locale.
### osLocale.sync([options])
Returns the locale.
#### options.spawn
#### options
Type: `boolean`
Type: `Object`
##### spawn
Type: `boolean`<br>
Default: `true`
Set to `false` to avoid spawning subprocesses and instead only resolve the locale from environment variables.
## Security
To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure.
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)