PHP Classes
elePHPant
Icontem

File: firstExample

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Martin Lacroix  >  i18n_  >  firstExample  >  Download  
File: firstExample
Role: Example script
Content type: text/plain
Description: simple example
Class: i18n_
Get application text from class constants
Author: By
Last change: added how to use block
Date: 3 years ago
Size: 4,675 bytes
 

Contents

Class file image Download
<?php
include 'i18n';

/**
 * Class that pilots a set of messages
 */
class i18nData extends i18n {
 
   const
__SELF__ = __CLASS__;
  
  
# simple messages
  
const UNAVAILABLE_CONNEXION = 0;
   const
UNABLE_TO_GET_A_STATEMENT = 1;
   const
UNABLE_TO_LINK_A_VALUE_TO_A_TAG = 2;
   const
EXECUTION_ERROR = 3;
   const
INTEGRITY_VIOLATION = 4;
   const
UNABLE_TO_EXTRACT_THE_DATA = 5;
   const
DATA_NOT_FOUND = 6;
   const
EMPTY_RECORD = 7;
   const
UNABLE_TO_RETRIEVE_THE_NEW_ID = 8;
   const
UNABLE_TO_BUILD_THE_SELECT_CLAUSE = 9;
   const
UNABLE_TO_BUILD_THE_FROM_CLAUSE = 10;
   const
UNABLE_TO_BUILD_THE_ORDER_BY_CLAUSE = 11;
   const
UNABLE_TO_BUILD_THE_GROUP_BY_CLAUSE = 12;
   const
UNABLE_TO_BUILD_THE_WHERE_CLAUSE = 13;
   const
UNABLE_TO_BUILD_THE_HAVING_CLAUSE = 14;
 
  
# parametred message
   # ALL PARAMETRED MESSAGES IN THE PILOT CLASS WILL ALWAYS BE WRITTEN LIKE THAT
  
static function unableToLinkAValueToTheTag($tag, $lang = GCT_LANG__USER) {
      return
parent::translate(__FUNCTION__, array($tag), $lang);
   }
}

/**
 * French translation of i18nData
 */
final class i18nData_fr {
 
   const
__SELF__ = __CLASS__;
 
   const
UNAVAILABLE_CONNEXION = 'connexion indisponible';
   const
UNABLE_TO_GET_A_STATEMENT = 'impossible de récupérer un statement';
   const
UNABLE_TO_LINK_A_VALUE_TO_A_TAG = 'impossible de rattacher une valeur à son tag';
   const
EXECUTION_ERROR = "erreur à l'exécution";
   const
INTEGRITY_VIOLATION = "erreur d'intégrité référentielle";
   const
UNABLE_TO_EXTRACT_THE_DATA = "impossible d'extraire les données";
   const
DATA_NOT_FOUND = 'données non trouvées';
   const
EMPTY_RECORD = 'enregistrement vide';
   const
UNABLE_TO_RETRIEVE_THE_NEW_ID = 'impossible de récupérer le nouvel id';
   const
UNABLE_TO_BUILD_THE_SELECT_CLAUSE = 'impossible de générer la clause select';
   const
UNABLE_TO_BUILD_THE_FROM_CLAUSE = 'impossible de générer la clause from';
   const
UNABLE_TO_BUILD_THE_ORDER_BY_CLAUSE = 'impossible de générer la clause order by';
   const
UNABLE_TO_BUILD_THE_GROUP_BY_CLAUSE = 'impossible de générer la clause group by';
   const
UNABLE_TO_BUILD_THE_WHERE_CLAUSE = 'impossible de générer la clause where';
   const
UNABLE_TO_BUILD_THE_HAVING_CLAUSE = 'impossible de générer la clause having';
 
   static function
unableToLinkAValueToTheTag($tag) {
      return
'impossible de rattacher une valeur au tag : ' . $tag;
   }
}

/**
 * English translation of i18nData
 */
final class i18nData_en {
 
   const
__SELF__ = __CLASS__;
 
   const
UNAVAILABLE_CONNEXION = 'unavailable connexion';
   const
UNABLE_TO_GET_A_STATEMENT = 'unable to get a statement';
   const
UNABLE_TO_LINK_A_VALUE_TO_A_TAG = 'unable to link a value to a tag';
   const
EXECUTION_ERROR = 'execution error';
   const
INTEGRITY_VIOLATION = 'integrity violation';
   const
UNABLE_TO_EXTRACT_THE_DATA = 'unable to extract the data';
   const
DATA_NOT_FOUND = 'data not found';
   const
EMPTY_RECORD = 'empty record';
   const
UNABLE_TO_RETRIEVE_THE_NEW_ID = 'unable to retrieve the new id';
   const
UNABLE_TO_BUILD_THE_SELECT_CLAUSE = 'unable to build the select clause';
   const
UNABLE_TO_BUILD_THE_FROM_CLAUSE = 'unable to build the from clause';
   const
UNABLE_TO_BUILD_THE_ORDER_BY_CLAUSE = 'unable to build the order by clause';
   const
UNABLE_TO_BUILD_THE_GROUP_BY_CLAUSE = 'unable to build the group clause';
   const
UNABLE_TO_BUILD_THE_WHERE_CLAUSE = 'unable to build the where clause';
   const
UNABLE_TO_BUILD_THE_HAVING_CLAUSE = 'unable to build the having clause';
 
   static function
unableToLinkAValueToTheTag($tag) {
      return
'unable to link a value to the tag: ' . $tag;
   }
}

# HOW TO USE
define('GCT_LANG__USER', 'fr');
define('GCT_LANG__DEFAULT', 'en');
define('GCT_LANG__TRANSLATION_MISSING', 'notTranslated');
 
echo
i18nData::UNABLE_TO_BUILD_THE_FROM_CLAUSE(), '<br />';
echo
i18nData::UNABLE_TO_BUILD_THE_FROM_CLAUSE('en'), '<br />';
echo
i18nData::UNABLE_TO_BUILD_THE_FROM_CLAUSE('de'), '<br />';
echo
i18nData::unableToLinkAValueToTheTag('monTag'), '<br />';
echo
i18nData::unableToLinkAValueToTheTag('monTag', 'en'), '<br />';
echo
i18nData::unableToLinkAValueToTheTag('monTag', 'de'), '<br />';
?>