language code to language name

Started on the old forum in February 2012 · view the original in the archive · old links redirect here

2 replies · 1,745 views · started 14 years ago · 1 min read

2 participants
GumSlone Administrator Principal · 1,690 posts #1

this function detects users language name from browsers language code

function gum_lc2ln()
{
	$lc = strtolower(substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2));
	$language_arr = array(
	"en"=>"English",
	"de"=>"German",
	"ru"=>"Russian",
	"ja"=>"Japanese",
	"es"=>"Spanish",
	"zh"=>"Chinese",
	"fr"=>"French",
	"it"=>"Italian",
	"pt"=>"Portuguese",
	"pl"=>"Polish",
	"ar"=>"Arabic",
	"nl"=>"Dutch",
	"tr"=>"Turkish",
	"sv"=>"Swedish",
	"fa"=>"Persian",
	"cs"=>"Czech",
	"ro"=>"Romanian",
	"ko"=>"Korean",
	"el"=>"Greek",
	"hu"=>"Hungarian",
	"th"=>"Thai",
	"vi"=>"Vietnamese",
	"da"=>"Danish",
	"hi"=>"Hindi",
	"id"=>"Indonesian",
	"fi"=>"Finnish",
	"no"=>"Norwegian",
	"bg"=>"Bulgarian",
	"sk"=>"Slovak",
	"he"=>"Hebrew",
	"hr"=>"Croatian",
	"lt"=>"Lithuanian",
	"sr"=>"Serbian",
	"ca"=>"Catalan",
	"sl"=>"Slovenian",
	"uk"=>"Ukrainian",
	"ms"=>"Malay",
	"ml"=>"Malayalam"
	);
	if(!empty($language_arr[$lc])) return $language_arr[$lc];
	else return 'Unknown';
}

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

just_m3. Developer · 199 posts #2

simple and easy to code 😊 but tnx , 😏 other users would find it usefull 🍻 cheers

This is ten percent luck, twenty percent skill Fifteen percent concentrated power of will Five percent pleasure, fifty percent pain 😂And a hundred percent reason to remember the name!

GumSlone Administrator Principal · 1,690 posts #3

just_m3. wrote: simple and easy to code 😊 but tnx , 😏 other users would find it usefull 🍻 cheers

sometimes its easier to copy and paste a ready simple code than to code it. 🙂

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close