Thursday, September 6, 2012

How to detect and save browser language preference into cookie?

    <script type="text/javascript">
        $(document).ready(function () {
            var c = $.cookie('userlanguage');
            var userLanguage = null;
            if (!c) {
                var language = window.navigator.userLanguage || window.navigator.language;
                $.cookie('userlanguage', userLanguage, { path: '/'});
            }
        });
    </script>