Coder Social home page Coder Social logo

jquery-browser-language's Introduction

This is a jQuery plugin to obtain the browser language setting 

Note, the browser language can not (generally) be obtained via navigator.language (which is silly but there you go)

The browser language is available in "Accept-language" HTTP header, but this is not directly accessible via javascript.

The plugin utilises a service at http://ajaxhttpheaders.appspot.com which echos back the HTTP request headers in JSONP.

I made that as well, and intend to leave it running there in perpetuity (or as long as Google continue to host App Engine for free)

The Accept-Language header as defined by http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.10 uses an ISO 639-1 language code. The plugin converts this to an English Language description of the Language (e.g. 'Norwegian'), but also returns the complete value of the header if you need to do further processing.

Example usage:

<script>
    $.browserLanguage(function( language , acceptHeader ){
      alert("You have your browser language set to " + language + " and the complete value of the 'Accept-Language' header is " + acceptHeader);
    });
</script>

jquery-browser-language's People

Contributors

dansingerman avatar

Watchers

James Cloos avatar Eihab Shadeed avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.