Undeaded Posted October 8, 2008 Report Share Posted October 8, 2008 (edited) Visiem sveiks! Man te ir mazinjs jautajums. Kapec man uzreiz kad spiedu mainit pogu valodu - uzreiz nemainas valoda, bet tikaj ja es spiedisu otru reizi uz pogu - tad sajt radis citu valodu. Es ka saprotu mans skript tais cookies, bet šie cookies bus speka tikaj kad es parladešu otru reizi sajtu. Man vajaga laj skript uzreiz taisija sajta header - izveleto valodu, bet ne pec otras sajta ielades. Paldies. Edited October 9, 2008 by Undeaded Link to comment Share on other sites More sharing options...
pilots Posted October 9, 2008 Report Share Posted October 9, 2008 Valodas maiņas pārbaudi (maiņu) ieliec pirms tā koda gabala, kad tiek ielādēts valodas fails attēlošanai. Link to comment Share on other sites More sharing options...
blackhalt Posted October 9, 2008 Report Share Posted October 9, 2008 Tapēc, ka Tavu kukiju nolasa tikai ar otro reizi. Nosūta datus -> Saņem datus. Saņem datus -> Nosūta datus. Link to comment Share on other sites More sharing options...
Java Posted October 9, 2008 Report Share Posted October 9, 2008 (edited) Pārraksti savu kodu uz sekojošu un vajadzētu strādāt: <?php if (!$_COOKIE["mufilebase_lang"] || $_REQUEST['set_lang']) { if ($_REQUEST['set_lang']) { if($_REQUEST['set_lang'] == "lv" OR $_REQUEST['set_lang'] == "en" OR $_REQUEST['set_lang'] == "ru"){ $_LANG = $_REQUEST['set_lang']; } else { $_LANG = "ru"; } } else { $_LANG = "ru"; } setcookie("mufilebase_lang",$_LANG); } else { $_LANG = $_COOKIE["mufilebase_lang"]; } switch($_LANG){ case 'en': include("lang/en.php"); break; case 'lv': include("lang/lv.php"); break; case 'ru': include("lang/ru.php"); break; default: include("lang/ru.php"); break; } ?> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?set_lang=ru">ru</a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?set_lang=lv">lv</a> <a href="<?php echo $_SERVER['PHP_SELF']; ?>?set_lang=en">en</a> Edited October 9, 2008 by Java Link to comment Share on other sites More sharing options...
Undeaded Posted October 9, 2008 Author Report Share Posted October 9, 2008 (edited) Pārraksti savu kodu uz sekojošu un vajadzētu strādāt LIELS PALDIES JUMS :) Edited October 9, 2008 by Undeaded Link to comment Share on other sites More sharing options...
Java Posted October 9, 2008 Report Share Posted October 9, 2008 Pag, es salaboju savu postu, ieliec tagad to kodu! Link to comment Share on other sites More sharing options...
Aleksejs Posted October 9, 2008 Report Share Posted October 9, 2008 (edited) es ieteiktu papildināt Java rakstīto ar: ... if($_REQUEST['set_lang']){ if($_REQUEST['set_lang'] == "lv" OR $_REQUEST['set_lang'] == "en" OR $_REQUEST['set_lang'] == "ru"){ setcookie("mufilebase_lang",$_REQUEST['set_lang']); $valoda = $_REQUEST['set_lang']; } } else { $valoda = $_COOKIE['mufilebase_lang']; } switch($valoda){ ... [edit] Ā, Java jau pats papildināja :) Edited October 9, 2008 by Aleksejs Link to comment Share on other sites More sharing options...
Java Posted October 9, 2008 Report Share Posted October 9, 2008 (edited) Aleksejs nedarbosies, ja nav nosetots gan cookijs, gan nav pieprasīts 'set_lang' - paskaties augstāk - esmu salabojis savu kodu! :) Tagad vajadzētu strādāt! Edited October 9, 2008 by Java Link to comment Share on other sites More sharing options...
Undeaded Posted October 9, 2008 Author Report Share Posted October 9, 2008 (edited) Man te vel viena kļuda paradas ar jauno skriptu. Skript strada ja ir viena lapaspuse piemeram index.php ja es iešu uz citu lapaspusi news.php tad valoda mainas uz galveno, bet neatstajas kura bija izveleta :( Pat ja index.php mainas - valoda mainas uz galveno, bet nepaliek kura bija izveleta. Piemera index.php iespiedu pogu - english valodu - viss ok, kad spiedu pogu piemeram Jaunumi (index.php?op=news) - valoda mainas uz galveno (latviešu), bet es izvelejos english valodu. Edited October 9, 2008 by Undeaded Link to comment Share on other sites More sharing options...
Java Posted October 9, 2008 Report Share Posted October 9, 2008 Iesaku tev vēl kodu optimizēt, piemēram, sākumā ielikt: define('LANGUAGE_DEFAULT', 'ru'); Un tad visur, kur vajag ielikt defaulto valodu, izmantot konstanti LANGUAGE_DEFAULT, savukārt pēc mana koda, Switch vietā vienkārši vari ievietot: if ($_LANG) { @include("lang/".$_LANG.".php"); } Link to comment Share on other sites More sharing options...
Undeaded Posted October 9, 2008 Author Report Share Posted October 9, 2008 Kļudu atrodu. Visiem paldies. Link to comment Share on other sites More sharing options...
Recommended Posts