PHP Classes
elePHPant
Icontem

File: example_several.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_several.php  >  Download  
File: example_several.php
Role: Example script
Content type: text/plain
Description: Example of usage with several files
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: 9 years ago
Size: 1,672 bytes
 

Contents

Class file image Download
<?php
$LocaleMechanism
= 'severalfiles';
$LocalePath = './severalfiles/';
$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_several-locale',$_POST['locale'],time()+2592000); // This expiration time is 30 days.
 
$locale = $_POST['locale'];
}elseif (isset(
$_COOKIE['ex_several-locale']))
 
$locale = $_COOKIE['ex_several-locale'];
else
 
$locale = $nativeLocale;

eval (
$oI18N->XL('ExampleSeveral', '$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_several.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>