Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> wykrywanie jezyka poprzez ip
Barnaba
post
Post #1





Grupa: Zarejestrowani
Postów: 7
Pomógł: 0
Dołączył: 23.07.2003
Skąd: Zabrze

Ostrzeżenie: (0%)
-----


no wlasnie wpadlem sobie na pomysl ze podczas ladowania strony bedzie automatycznie wzucal dany jezyk po poprzednim zweryfikowaniu adresu ip a dokladnie z jakiego kraju pochodzi.
Czy da sie cos takiego zrobic?
prosze o mala podpowiedz jesli tak...
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Wankster
post
Post #2





Grupa: Zarejestrowani
Postów: 208
Pomógł: 0
Dołączył: 19.04.2003

Ostrzeżenie: (0%)
-----


Znalazłem taką funkcję w phpBB2/install/install.php:[php:1:6388102afd]<?php

// Guess an initial language ... borrowed from phpBB 2.2 it's not perfect,
// really it should do a straight match first pass and then try a "fuzzy"
// match on a second pass instead of a straight "fuzzy" match.
function guess_lang()
{
global $phpbb_root_path, $HTTP_SERVER_VARS;

// The order here _is_ important, at least for major_minor
// matches. Don't go moving these around without checking with
// me first - psoTFX
$match_lang = array(
'arabic' => 'ar([_-][a-z]+)?',
'bulgarian' => 'bg',
'catalan' => 'ca',
'czech' => 'cs',
'danish' => 'da',
'german' => 'de([_-][a-z]+)?',
'english' => 'en([_-][a-z]+)?',
'estonian' => 'et',
'finnish' => 'fi',
'french' => 'fr([_-][a-z]+)?',
'greek' => 'el',
'spanish_argentina' => 'es[_-]ar',
'spanish' => 'es([_-][a-z]+)?',
'gaelic' => 'gd',
'galego' => 'gl',
'gujarati' => 'gu',
'hebrew' => 'he',
'hindi' => 'hi',
'croatian' => 'hr',
'hungarian' => 'hu',
'icelandic' => 'is',
'indonesian' => 'id([_-][a-z]+)?',
'italian' => 'it([_-][a-z]+)?',
'japanese' => 'ja([_-][a-z]+)?',
'korean' => 'ko([_-][a-z]+)?',
'latvian' => 'lv',
'lithuanian' => 'lt',
'macedonian' => 'mk',
'dutch' => 'nl([_-][a-z]+)?',
'norwegian' => 'no',
'punjabi' => 'pa',
'polish' => 'pl',
'portuguese_brazil' => 'pt[_-]br',
'portuguese' => 'pt([_-][a-z]+)?',
'romanian' => 'ro([_-][a-z]+)?',
'russian' => 'ru([_-][a-z]+)?',
'slovenian' => 'sl([_-][a-z]+)?',
'albanian' => 'sq',
'serbian' => 'sr([_-][a-z]+)?',
'slovak' => 'sv([_-][a-z]+)?',
'swedish' => 'sv([_-][a-z]+)?',
'thai' => 'th([_-][a-z]+)?',
'turkish' => 'tr([_-][a-z]+)?',
'ukranian' => 'uk([_-][a-z]+)?',
'urdu' => 'ur',
'viatnamese' => 'vi',
'chinese_traditional_taiwan'=> 'zh[_-]tw',
'chinese_simplified' => 'zh',
);

if (isset($HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE']))
{
$accept_lang_ary = explode(',', $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE']);
for ($i = 0; $i < sizeof($accept_lang_ary); $i++)
{
@reset($match_lang);
while (list($lang, $match) = each($match_lang))
{
if (preg_match('#' . $match . '#i', trim($accept_lang_ary[$i])))
{
if (file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $lang)))
{
return $lang;
}
}
}
}
}

return 'english';

}

?>[/php:1:6388102afd]
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 12.10.2025 - 17:13