Return to Snippet

Revision: 38284
at December 30, 2010 02:38 by itreptil


Updated Code
(function($){
	//
	// DIV must be style="display:none;"	
	//
	$.fn.chk_userlanguage = function() {
		/* check if <style=display:none;> not set to that element */
		if (!this.is(":hidden")) { this.hide(); };
	
		/* get browser default lang */ 
		if (navigator.userLanguage) {
			baseLang = navigator.userLanguage.substring(0,2).toLowerCase();
		} else {
			baseLang = navigator.language.substring(0,2).toLowerCase();
		}
		
		/* language match */
		switch(baseLang)
		{
			case "de":
				/* german */
				this.slideDown("slow");
				break;
			case "en":
				/* english */
				break;
			case "ja":
				/* japanese */
				break;
			case "ru":
				/* russian */
				break;
			default:
				/* default no match */
		}
	};	
})(jQuery);

Revision: 38283
at December 30, 2010 02:35 by itreptil


Initial Code
(function($){
	//
	// DIV must be style="display:none;"	
	//
	$.fn.userlanguage = function() {
		/* check if <style=display:none;> not set to that element */
		if (!this.is(":hidden")) { this.hide(); };
	
		/* get browser default lang */ 
		if (navigator.userLanguage) {
			baseLang = navigator.userLanguage.substring(0,2).toLowerCase();
		} else {
			baseLang = navigator.language.substring(0,2).toLowerCase();
		}
		
		/* language match */
		switch(baseLang)
		{
			case "de":
				/* german */
				this.slideDown("slow");
				break;
			case "en":
				/* english */
				break;
			case "ja":
				/* japanese */
				break;
			case "ru":
				/* russian */
				break;
			default:
				/* default no match */
		}
	};	
})(jQuery);

Initial URL
http://www.itreptil.at

Initial Description
this snippet allows you to receive the browser default language (IE & other).

- change content based on the lang
- German
- Russian
- English
- Japanese
- and default

have fun http://itreptil.at

Initial Title
Localize user language

Initial Tags

                                

Initial Language
jQuery