Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Propozycja wielojęzyczności na stronie
psbert
post
Post #1





Grupa: Zarejestrowani
Postów: 15
Pomógł: 0
Dołączył: 21.05.2007

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


Witam,
Ostatnio przerobiłem wielojęzyczność na stronie i działa poprawnie. W związku z tym proszę o ocenę na ile jest ona poprawna od strony technicznej.

Przełączanie menu np w pliku banner.inc.php

  1. <form action="" method="post">
  2. <p>
  3. <input class="flaga_pl" type="submit" name="lang" value="pl" />
  4. <input class="flaga_en" type="submit" name="lang" value="en" />
  5. <input class="flaga_es" type="submit" name="lang" value="es" />
  6. </p>
  7. </form>



plik index.php
  1. <?
  2. ini_set( 'arg_separator.output', '&' );
  3.  
  4. if ( !isset ($_SESSION['lang']))
  5. {
  6. if ( isset ($_POST['lang']))
  7. {
  8. $_SESSION['lang'] = $_POST['lang'];
  9. }
  10. else
  11. {
  12. $_SESSION['lang']= pl;
  13. }
  14. }
  15.  
  16. include('head.' . $_SESSION[lang] . '.inc.php');
  17.  
  18. include( './lang/'.$_SESSION[lang].'/menu.txt.php');
  19. include( './lang/'.$_SESSION[lang].'/text.txt.php');
  20.  
  21. ?>
  22.  
  23. <div id="container">
  24.  
  25.  <div id="banner"><? include("include/banner.inc.php");?></div>
  26.  <div id="window"><? include("include/window.inc.php");?></div>
  27.  <div id="footer"><? include("include/footer.inc.php");?></div>
  28.  
  29. </div>
  30.  
  31. </body>
  32. </html>




plik include/head.$_SESSION[lang].inc.php

w zależności od języka zmieniamy ustawienia nagłówka (temat, zawrtość, itd)

  1. <? echo '<?xml version="1.0" encoding="UTF-8"?>' ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5.  <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
  6.  <meta http-equiv="pragma" content="no-cache" />
  7.  <meta http-equiv="cache-control" content="no-cache" />
  8.  <meta name="author" content="abc" />
  9.  <meta name="description" content="abc" />
  10.  <title>:: abc ::</title>
  11. <!--[if IE 7]><link rel="stylesheet" type="text/css" href="css/ie7.css" /><![endif]-->
  12.  <link rel="stylesheet" type="text/css" href="css/common.css" />
  13.  <link rel="stylesheet" type="text/css" href="css/layout_1.css" title="Podstawowy" />
  14.  
  15.  </head>
  16. <body>


w pliku css

  1. input.flaga_es {
  2. background-image: url(../img/flagi/flaga_es.gif);
  3. background-repeat: no-repeat;
  4. width: 24px;
  5. height: 18px;
  6. background-color: transparent;
  7. float: left;
  8. font-size: 0;
  9. }
  10. input.flaga_en {
  11. background-image: url(../img/flagi/flaga_en.gif);
  12. background-repeat: no-repeat;
  13. width: 24px;
  14. height: 18px;
  15. background-color: transparent;
  16. float: left;
  17. font-size: 0;
  18. }
  19. input.flaga_pl {
  20. background-image: url(../img/flagi/flaga_pl.gif);
  21. background-repeat: no-repeat;
  22. width: 24px;
  23. height: 18px;
  24. background-color: transparent;
  25. float: left;
  26. font-size: 0;
  27. }



w plikach języków
  1. <?php
  2. // ustawiam zmienną jako tablice
  3. $lng = array();
  4.  
  5. // opisy menu - linki:
  6.  
  7. $lng['tekst'] = 'tekst w odpowiednim języku';
  8. ?>



w treści strony wstawiam

  1. <?
  2. tu pojawi si&#281; ".$lng['tekst']."dla danej wersji językowej";
  3. ?>




Pozdrawiam i czekam na ocenę.

Piotr

Ten post edytował psbert 31.10.2008, 13:54:56
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Wykrywacz
post
Post #2





Grupa: Zarejestrowani
Postów: 726
Pomógł: 20
Dołączył: 8.12.2005
Skąd: Wrocław

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


A zamiast na przedszkolu nie powinno być to w opiniach?
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 3.10.2025 - 17:30