PHP Classes

File: secondExample

Recommend this page to a friend!
  Classes of Martin Lacroix   i18n_   secondExample   Download  
File: secondExample
Role: Example script
Content type: text/plain
Description: Complex architecture using derivated classes
Class: i18n_
Get application text from class constants
Author: By
Last change:
Date: 12 years ago
Size: 1,478 bytes
 

Contents

Class file image Download
<?php

# Class that pilots a set of texts
class i18nFormBase extends i18n {
 
   const
__SELF__ = __CLASS__;
 
   const
CREATE = 1;
   const
UPDATE = 2;
   const
DELETE = 3;
   const
SELECT = 4;
}
 
# French translation
final class i18nFormBase_fr {
 
   const
__SELF__ = __CLASS__;
 
   const
CREATE = 'créer';
   const
UPDATE = 'modifier';
   const
DELETE = 'supprimer';
   const
SELECT = 'sélectionner';
}
 
# English translation
final class i18nFormBase_en {
 
   const
__SELF__ = __CLASS__;
 
   const
CREATE = 'create';
   const
UPDATE = 'update';
   const
DELETE = 'delete';
   const
SELECT = 'select';
}
 
 
# Now we are going to add some new words to the base class
# Class that extends the base class and pilots new and old words
class i18nFormMail extends i18nFormBase {
 
   const
__SELF__ = __CLASS__;
  
   const
SEND = 1;
   const
SPAM = 2;
}
 
# French translation
class i18nFormMail_fr {
 
   const
__SELF__ = __CLASS__;
  
   const
SEND = 'expédier';
   const
SPAM = 'courrier indésirable';
}
 
# English translation
class i18nFormMail_en {
 
   const
__SELF__ = __CLASS__;
  
   const
SEND = 'send';
   const
SPAM = 'spam';
}

# HOW TO USE
define('GCT_LANG__USER', 'fr');
define('GCT_LANG__DEFAULT', 'en');
define('GCT_LANG__TRANSLATION_MISSING', 'notTranslated');
 
echo
i18nFormBase::CREATE(), '<br />';
echo
i18nFormMail::CREATE(), '<br />';
echo
i18nFormMail::SEND(), '<br />';
?>