browser-language-auto-detector
Advanced tools
Comparing version
@@ -447,2 +447,10 @@ 'use strict'; | ||
if (local.length) { | ||
local.forEach(v=>{ | ||
const pos = v.indexOf('-'); | ||
if(pos>-1){ | ||
const pre = v.substring(0,pos); | ||
local.indexOf(pre)>-1 || local.push(pre); | ||
} | ||
}); | ||
console.log(local); | ||
let ret; | ||
@@ -449,0 +457,0 @@ if(local.some(v=>{ |
@@ -445,2 +445,10 @@ const bcp47Map = new Map([ | ||
if (local.length) { | ||
local.forEach(v=>{ | ||
const pos = v.indexOf('-'); | ||
if(pos>-1){ | ||
const pre = v.substring(0,pos); | ||
local.indexOf(pre)>-1 || local.push(pre); | ||
} | ||
}); | ||
console.log(local); | ||
let ret; | ||
@@ -447,0 +455,0 @@ if(local.some(v=>{ |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["browser-language-detector"] = {})); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["browser-language-auto-detector"] = {})); | ||
})(this, (function (exports) { 'use strict'; | ||
@@ -451,2 +451,10 @@ | ||
if (local.length) { | ||
local.forEach(v=>{ | ||
const pos = v.indexOf('-'); | ||
if(pos>-1){ | ||
const pre = v.substring(0,pos); | ||
local.indexOf(pre)>-1 || local.push(pre); | ||
} | ||
}); | ||
console.log(local); | ||
let ret; | ||
@@ -453,0 +461,0 @@ if(local.some(v=>{ |
{ | ||
"name": "browser-language-auto-detector", | ||
"version": "0.0.1", | ||
"version": "1.0.1", | ||
"description": "detect browser's language and translate to common language name", | ||
@@ -5,0 +5,0 @@ "main": "dist/build.cjs.js", |
# browser-language-auto-detector | ||
## Auto-detect language name for browser , turn origin name to language name | ||
## Install | ||
```bash | ||
//use npm | ||
npm i browser-language-auto-detector | ||
//use yarn | ||
yarn add browser-language-auto-detector | ||
``` | ||
## Develop | ||
```bash | ||
$ yarn install | ||
@@ -7,0 +18,0 @@ ``` |
@@ -14,2 +14,12 @@ import { bcp47Map } from './bcp47Map' | ||
if (local.length) { | ||
//append prefix of local item to local | ||
//like zh-CN would calc zh again | ||
local.forEach(v=>{ | ||
const pos = v.indexOf('-') | ||
if(pos>-1){ | ||
const pre = v.substring(0,pos) | ||
local.indexOf(pre)>-1 || local.push(pre) | ||
} | ||
}) | ||
//find first matched language name | ||
let ret; | ||
@@ -16,0 +26,0 @@ if(local.some(v=>{ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
72930
1.81%1999
1.73%1
-50%53
26.19%