Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

get-user-locale

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-user-locale - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

28

dist/entry.js

@@ -6,23 +6,15 @@ "use strict";

});
exports.default = exports.getUserLocale = exports.getUserLocales = void 0;
exports["default"] = exports.getUserLocale = exports.getUserLocales = void 0;
var _lodash = _interopRequireDefault(require("lodash.once"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
var filterDuplicates = function filterDuplicates(arr) {
function filterDuplicates(arr) {
return arr.filter(function (el, index, self) {
return self.indexOf(el) === index;
});
};
}
var fixLowercaseProperties = function fixLowercaseProperties(arr) {
function fixLowercaseProperties(arr) {
return arr.map(function (el) {

@@ -36,5 +28,5 @@ if (!el || el.indexOf('-') === -1 || el.toLowerCase() !== el) {

});
};
}
var getUserLocales = (0, _lodash.default)(function () {
var getUserLocales = (0, _lodash["default"])(function () {
var languageList = [];

@@ -44,3 +36,3 @@

if (window.navigator.languages) {
languageList.push.apply(languageList, _toConsumableArray(window.navigator.languages));
languageList = languageList.concat(window.navigator.languages);
}

@@ -70,3 +62,3 @@

exports.getUserLocales = getUserLocales;
var getUserLocale = (0, _lodash.default)(function () {
var getUserLocale = (0, _lodash["default"])(function () {
return getUserLocales()[0];

@@ -76,2 +68,2 @@ });

var _default = getUserLocale;
exports.default = _default;
exports["default"] = _default;
{
"name": "get-user-locale",
"version": "1.1.1",
"description": "Returns a list of strings representing the user's preferred languages.",
"main": "dist/entry.js",
"es6": "src/entry.js",
"scripts": {
"build": "babel src -d dist --ignore **/__tests__",
"prepublishOnly": "yarn run build",
"test": "yarn run test-eslint && yarn run test-jest",
"test-eslint": "eslint src/ --ext .jsx,.js",
"test-jest": "jest",
"test-jest-coverage": "jest --coverage"
},
"jest": {
"moduleNameMapper": {
"lodash.once": "<rootDir>/__mocks__/lodashOnceMock.js"
}
},
"keywords": [
"locale",
"language",
"language-detection"
],
"author": {
"name": "Wojciech Maj",
"email": "kontakt@wojtekmaj.pl"
},
"license": "MIT",
"dependencies": {
"lodash.once": "^4.1.1"
},
"devDependencies": {
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^9.0.0",
"babel-jest": "23.4.2",
"eslint": "^5.4.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"jest": "^23.5.0"
},
"files": [
"LICENSE",
"README.md",
"dist/",
"src/"
],
"repository": {
"type": "git",
"url": "https://github.com/wojtekmaj/get-user-locale.git"
"name": "get-user-locale",
"version": "1.2.0",
"description": "Returns a list of strings representing the user's preferred languages.",
"main": "dist/entry.js",
"source": "src/entry.js",
"scripts": {
"build": "babel src -d dist --ignore **/__tests__",
"jest": "jest",
"jest-coverage": "jest --coverage",
"lint": "eslint src/ --ext .jsx,.js",
"prepublishOnly": "yarn build",
"test": "yarn lint && yarn jest"
},
"jest": {
"moduleNameMapper": {
"lodash.once": "<rootDir>/__mocks__/lodashOnceMock.js"
}
},
"keywords": [
"locale",
"language",
"language-detection"
],
"author": {
"name": "Wojciech Maj",
"email": "kontakt@wojtekmaj.pl"
},
"license": "MIT",
"dependencies": {
"lodash.once": "^4.1.1"
},
"devDependencies": {
"@babel/cli": "^7.5.0",
"@babel/core": "^7.5.0",
"@babel/preset-env": "^7.5.0",
"babel-jest": "^24.0.0",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.18.0",
"jest": "^24.8.0"
},
"files": [
"LICENSE",
"README.md",
"dist/",
"src/"
],
"repository": {
"type": "git",
"url": "https://github.com/wojtekmaj/get-user-locale.git"
}
}

@@ -0,3 +1,5 @@

![downloads](https://img.shields.io/npm/dt/get-user-locale.svg) ![build](https://img.shields.io/travis/wojtekmaj/get-user-locale/master.svg)
# Get-User-Locale
A function that returns a [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag), based on all available sources.
A function that returns user's locale as an [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag), based on all available sources.

@@ -16,3 +18,3 @@ ## tl;dr

A function that returns a [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag), based on all available sources.
A function that returns user's preferred locale as an [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag), based on all available sources.

@@ -39,3 +41,3 @@ #### Sample result

A function that returns an array of [IETF language tag](https://en.wikipedia.org/wiki/IETF_language_tag)s, based on all available sources.
A function that returns an array of user's preferred locales as an [IETF language tags](https://en.wikipedia.org/wiki/IETF_language_tag), based on all available sources.

@@ -42,0 +44,0 @@ #### Sample result

import once from 'lodash.once';
const filterDuplicates = arr => arr.filter((el, index, self) => self.indexOf(el) === index);
function filterDuplicates(arr) {
return arr.filter((el, index, self) => self.indexOf(el) === index);
}
const fixLowercaseProperties = arr => arr.map((el) => {
if (
!el
|| el.indexOf('-') === -1
|| el.toLowerCase() !== el
) {
return el;
}
function fixLowercaseProperties(arr) {
return arr.map((el) => {
if (
!el
|| el.indexOf('-') === -1
|| el.toLowerCase() !== el
) {
return el;
}
const splitEl = el.split('-');
return `${splitEl[0]}-${splitEl[1].toUpperCase()}`;
});
const splitEl = el.split('-');
return `${splitEl[0]}-${splitEl[1].toUpperCase()}`;
});
}
export const getUserLocales = once(() => {
const languageList = [];
let languageList = [];
if (typeof window !== 'undefined') {
if (window.navigator.languages) {
languageList.push(...window.navigator.languages);
languageList = languageList.concat(window.navigator.languages);
}

@@ -25,0 +29,0 @@ if (window.navigator.language) {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc