1: <?php
 2: class QSampleTranslation implements QTranslationBase {
 3:     protected $strTranslationArray = array();
 4:     protected $strCode;
 5:     public static function Initialize() {
 6:         return self::Load(QApplication::$LanguageCode, QApplication::$CountryCode);
 7:     }
 8:     
 9:     public static function Load($strLanguageCode = null, $strCountryCode = null) {
10:         return new QSampleTranslation($strLanguageCode, $strCountryCode);
11:     }
12:     
13:     public function __construct($strLanguageCode = null, $strCountryCode = null) {
14:         $strCode = '';
15:         if ($strLanguageCode) {
16:             if ($strCountryCode) {
17:                 $strCode = sprintf('%s_%s', $strLanguageCode, $strCountryCode);
18:             } else {
19:                 $strCode = $strLanguageCode;
20:             }
21:         }
22:         $this->strCode = $strCode;
23:         
24:         
25:         $this->strTranslationArray = array(
26:             
27:             'fr' => array(
28:                 'Required' => 'Requis', 
29:                 'Optional' => 'Facultatif',
30:                 'Hello' => 'Bonjour'
31:             ),
32:             
33:             'es' => array(
34:                 'Required' => 'Obligatorio', 
35:                 'Optional' => 'Opcional'
36:             )
37:         );
38:     }
39:     
40:     public function TranslateToken($strToken) {
41:         if (isset($this->strTranslationArray[$this->strCode]) &&
42:                 isset($this->strTranslationArray[$this->strCode][$strToken])) {
43:              return $this->strTranslationArray[$this->strCode][$strToken];
44:         } else {
45:             
46:             return $strToken;
47:         }
48:     }
49: }
50: 
51: 
52: ?>
53: