Thursday, April 15, 2010

Wordpress wp-config.php Multi Language Hack

I am always looking for this code I wrote from past projects. Now I will know exactly where I can go to find it--namely here!

This is a little bit of php for a wordpress wp-config.php file that will switch language of the the admin interface based on user's browser language. Note: the required .mo file(s) will need to be uploaded to the /wp-content/languages folder.


$lang = substr(strtoupper(getenv("HTTP_ACCEPT_LANGUAGE")), 0, 2);
//echo "Language is: ".$lang;
if($lang == "DE"){
define ('WPLANG', 'de_DE');
}
else{
define ('WPLANG', '');
}