Jump to content
php.lv forumi

daudz valodu title nestrada


TheQn

Recommended Posts

Nezunu kapec negrib valodu no lang faila uz <title> <?php echo $title; ?></title>

 

bet uz

 

<body>

<?php echo $lang['home']; ?>

</body>

 

vis izvada, a bet title negrib.

 

Index.php

<?php
@session_start();
define('ROOT_DIR', dirname(__FILE__));
define('ENGINE_DIR', ROOT_DIR . "/engine");

require_once ROOT_DIR . '/config.php';
require_once ROOT_DIR . '/main_things.php';

$title = title($_GET['go']);
?>
<title> <?php echo $title; ?></title>

main_things.php

<?php

function title($arg)
{
   switch($arg)
   {
       case "":
           $title = $lang['home'];
       break;
       case "forum":
           $title = $lang['forum'];
       break;
   }
   return $title;
}

?>
<?php

require_once ENGINE_DIR . '/modules/language.php';

?>

 

modules/language.php

 

<?php

$referer = $_SERVER['HTTP_REFERER'];

$languages = array('english' => 'english','latvian' => 'latvian','russian' => 'russian');

if(isset($_GET['lang']))
{
   $language = $_GET['lang'];
   setcookie('lang', $language, time()+(3600*24*365), "/");
   header("Location: $referer");
}

elseif(isset($_COOKIE['lang']))
{
   $language = $_COOKIE['lang'];
}
else
{
   $language = "russian";
}
if(!(in_array($language,array_keys($languages))))
{
   die("Sorry, but this language does not exists!");
}

require_once ENGINE_DIR . "/languages/{$language}.php";

?>

 

russian.php

<?php

$lang = array(
'home' => 'Главная',
'forum' => 'Форум'
);

?>

Link to comment
Share on other sites

Es pārtaisītu:

function title($arg)
{
   switch($arg)
   {
       case "":
           $title = $lang['home'];
       break;
       case "forum":
           $title = $lang['forum'];
       break;
   }
   return $title;
}

par

function title($arg)
{
   switch($arg)
   {
       case "forum":
           $title = $lang['forum'];
       break;
      default:
           $title = $lang['home'];

  }
   return $title;
}

Link to comment
Share on other sites

Vis strada nepamaniju ka tur ir global $lang; :D

 

un vel viens jautajums ne par temu

 

kak ar rewrite taisit

 

/?go=bans&details=1 uz so /bans/details/1 un so

/?go=bans&page=1 uz so /bans/page/1

 

es taisiju ta RewriteRule ^bans/details/([0-9]*)$ ?go=bans&details=$1 [L]

un RewriteRule ^bans/page/([0-9]*)$ ?go=bans&page=$1 [L] un nestrada..

 

Un tad var Topic Close!

Edited by TheQn
Link to comment
Share on other sites

Val ne nestrada.

man visi fails bans.php atrodas

engine/includes/bans.php

 

izvadu uz main lapu ar so scriptu

<?php
if($go == '')
{
include ENGINE_DIR . '/includes/news.php';
}
else
{
include ENGINE_DIR . '/includes/'.$go.'.php';
}
echo "\n";
?>

Edited by TheQn
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...