Login   Register  
PHP Classes
elePHPant
Icontem

File: example_1.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Alan H. Lake  >  I18N class  >  example_1.php  >  Download  
File: example_1.php
Role: Example script
Content type: text/plain
Description: Test script for single translation file
Class: I18N class
Get translation texts from different containers
Author: By
Last change: Changed cookie code to eliminate error that might occur if a variable name that might appear in more than one script is used as a cookie name.
Date: 2005-09-21 15:08
Size: 1,632 bytes
 

Contents

Class file image Download
<?php
$LocaleMechanism 
'onefile';
$LocalePath './onefile/';
$nativeLocale 'en_US';

include_once 
'rfc1766.class.php';
$oRfc1766 = new rfc1766_class;
$_SESSION['oRfc1766'] = $oRfc1766;
include_once 
'i18n.class.php';
$oI18N = new I18N_class;
$_SESSION['oLang'] = $nativeLocale;

if(isset(
$_POST['locale'])){
  
setcookie('ex_1-locale',$_POST['locale'],time()+2592000); // This expiration time is 30 days.
  
$locale $_POST['locale'];
}elseif (isset(
$_COOKIE['ex_1-locale']))
  
$locale $_COOKIE['ex_1-locale'];
else
  
$locale $nativeLocale;

eval (
$oI18N->XL('Example1''$example'$locale));
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <title><?=$example?></title>
</head>

<body>
<?
  
eval ($oI18N->XL('SelectLang''$selectLang'$locale));
  eval (
$oI18N->XL('Submit''$submitCap'$locale));
  
$pwd 'ABcdE';
  eval (
$oI18N->XL('YourPwdIs''$yourPwdIs'$locale));
?>
  <h2><?=$example?></h2>
  <form name="example" method="post" enctype="multipart/form-data" action="example_1.php">
<?  $language $oI18N->GetLocales(); ?>
    <?=$yourPwdIs?><br /><br />
    <?=$selectLang?>
    <select name="locale" tabindex="1">
<?
      
foreach($language as $code => $name){
        if(
$code == $locale)
          print 
"<option selected=\"true\" value=\"$code\">$name</option>";
        else  
          print 
"<option value=\"$code\">$name</option>";
      } 
?>
    </select><br />
    <input name="submit" type="submit" value="<?=$submitCap?>" tabindex="2" />
  </form>
</body>
</html>