FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


HOWTO?$lang files!





digibluez
how do i load my language pages.I got 2 but it dont work

eng/main.php

Code:
<? defined('_VALID_INCLUDE') or die('Direct access not allowed.');
error_reporting (E_ALL ^ E_NOTICE);

$lang_title = 'DIGIBLUEZ DESIGNS 2005';
$lang_keywords = 'digibluez,portoflio,templates,scripts,digibluez network,graphics,art ';
$lang_description = 'Digibluez Designs Network-We make whats important to us ';
$lang_charset = 'text/html; charset=utf-8 ';
$lang_author = ',http:/digibluez.no-ip.org/,digibluez@gmail.com ';
$lang_copyright = ' 2005,digibluez.no-ip.org ';
$lang_Page_loaded_in = 'Page loaded in';
$lang_Hosted_by = 'Hosted by';
$lang_visits = 'visits';
?>


est/main.php
Code:
<? defined('_VALID_INCLUDE') or die('Direct access not allowed.');
error_reporting (E_ALL ^ E_NOTICE);

$lang_title = 'test5';
$lang_keywords = 'test';
$lang_description = 'test ';
$lang_charset = 'text/html; charset=utf-8 ';
$lang_author = 'test ';
$lang_copyright = 'test ';
$lang_Page_loaded_in = 'test';
$lang_Hosted_by = 'test';
$lang_visits = 'test';
?>


index file

Code:
if($lang=='est') include("$root/lanugage/est/main.php");
if($lang2=='eng') include("$root/lanugage/eng/main.php"); ?>
<div class="lang">
<a href="?lang=est">est</a>
<a href="?lang2=eng">eng</a>
</div>
<title><? print $lang_title ?></title>
.....more code here


how do i make it work,anyone has experience with that.You would save me lot of learning time and googleing.
eluder
Tip 1: keep all the language-specific data in hashes, not in separate variables:
Code:

lang/en.php

<?php
$charset = 'utf-8';
$lang = array(
  'msg1' => 'message 1',
  'msg2' => 'message 2',
  'msg3' => 'message 3',
// ...
  'msgN' => 'message N'
);
?>


Tip 2: use default language.

Code:

<?php
  $langcode = $_REQUEST['lang']; // language code is passed via 'lang' var
  if (!preg_match("/^[a-z][a-z]\$/i", $langcode)) {
    $langcode = 'en'; // should be two-letters code; use 'en' by default
  }
  if (!file_exists(LANGUAGE_ROOT . "lang/$langcode.php")) {
    $langcode = 'en'; // no such file
  }
  require_once(LANGUAGE_ROOT . "lang/$langcode.php");
?>


Tip 3: store language code in sessions/cookies.

Tip 4: select language code, if several available, by investigating, for example
- the languages accepted by browser
- by IP-to-country mapping and guessing the best language
- language code stored in session
- language code passed as GET/POST parameter

You choose the best priority of each step.
digibluez
great,got it now.
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.