tag:blogger.com,1999:blog-8361942945221983453.post704106305362217131..comments2024-03-24T13:09:14.304+00:00Comments on Pete's Blog: Using PHP-Gettext to localize your web pagesPetehttp://www.blogger.com/profile/00656449482260202625noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-8361942945221983453.post-5786938691269584252015-02-15T10:49:54.984+00:002015-02-15T10:49:54.984+00:00Yeah I'm not using the part where you retrieve...Yeah I'm not using the part where you retrieve GET variables but that's easy to add.Neptilohttps://www.blogger.com/profile/16389025853239808972noreply@blogger.comtag:blogger.com,1999:blog-8361942945221983453.post-18252104417123565882015-02-15T10:47:25.854+00:002015-02-15T10:47:25.854+00:00Thanks, this helped a lot!
Sometimes I had `local...Thanks, this helped a lot!<br /><br />Sometimes I had `locale_accept_from_http` accepting languages like 'de' that were not part of my $lang array. So I modified your code and did this instead:<br /><br />$locale = locale_accept_from_http($_SERVER['HTTP_ACCEPT_LANGUAGE']);<br />$lang_accepted = false;<br />foreach ($langs as $code => $lang) {<br /> if ($locale == $code || $locale == $lang[0]) {<br /> $locale = $code;<br /> $lang_accepted = true;<br /> break;<br /> }<br />}<br />if (!$lang_accepted)<br /> $locale = 'en_US';<br /><br />I think that's slightly more general than what you propose. Hope it helps!Neptilohttps://www.blogger.com/profile/16389025853239808972noreply@blogger.com