New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

detect-locale

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-locale

The essential job of this package is to detect the language of the browser.

  • 2.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

detect-locale

  • This application is ment to provide you the browser's language with minimal code with zero dependencies.Some packages uses accept-language header to detect language that cost XHR to server but here we use navigator to get the language.The main thing is that it supports all possible browsers.

How to Install ?

  • npm install detect-locale
  • yarn add detect-locale

How to use ?

  • ES6 way :
    import { getBrowserLocale,getShortBrowserLocale,getUserLanguages } from "detect-locale";
    console.log(` 5 character Browser Locale : String :$ {getBrowserLocale()}`);
    console.log(`2 Character Browser Locale : String 2 character: <b>{getShortBrowserLocale()}`);
    console.log(`User languages prefference : Array : <b>{getUserLanguages()}`);
    
  • Old way
    const locale = require("detect-locale");
    console.log(` 5 character Browser Locale : String :${locale.getBrowserLocale()}`);
    console.log(`2 Character Browser Locale : String 2 character: ${locale.getShortBrowserLocale()}`);
    console.log(`User languages prefference : Array : ${locale.getUserLanguages()}`);
    

Browser Suppoer

  • Chrome
  • Firefox
  • Opera
  • Edge
  • IE
  • chromium
  • UC
  • Safari

#ChangeLog

  • version 2
    • In Headless browser(cypress) now we are sending fallback language as english.

Keywords

FAQs

Package last updated on 15 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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