Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ez1337translator.php
Go to the documentation of this file.
1 <?php
29 class eZ1337Translator extends eZTranslatorHandler
30 {
31 public function __construct()
32 {
33 parent::__construct( false );
34
35 $this->Messages = array();
36 }
37
38 function findMessage( $context, $source, $comment = null )
39 {
40 $man = eZTranslatorManager::instance();
41 $key = $man->createKey( $context, $source, $comment );
42
43 if ( !isset( $this->Messages[$key] ) )
44 {
45 $translation = $this->leetify( $source );
46 $this->Messages[$key] = $man->createMessage( $context, $source, $comment, $translation );
47 }
48
49 return $this->Messages[$key];
50 }
51
55 function leetify( $text )
56 {
57 $text = preg_replace( "/to/", "2", $text );
58 $text = preg_replace( "/for/", "4", $text );
59 $text = preg_replace( "/ate/", "8", $text );
60 $text = preg_replace( "/you/", "u", $text );
61 $text = preg_replace( array( "/l/",
62 "/e/",
63 "/o/",
64 "/a/",
65 "/t/" ),
66 array( "1",
67 "3",
68 "0",
69 "4",
70 "7" ), $text );
71 return $text;
72 }
73
74 function translate( $context, $source, $comment = null )
75 {
76 $msg = $this->findMessage( $context, $source, $comment );
77 if ( $msg !== null )
78 {
79 return $msg["translation"];
80 }
81
82 return null;
83 }
84
89 static function initialize()
90 {
91 if ( !isset( $GLOBALS['eZ1337Translator'] ) ||
92 !( $GLOBALS['eZ1337Translator'] instanceof eZ1337Translator ) )
93 {
94 $GLOBALS['eZ1337Translator'] = new eZ1337Translator();
95 }
96
97 $man = eZTranslatorManager::instance();
98 $man->registerHandler( $GLOBALS['eZ1337Translator'] );
99 return $GLOBALS['eZ1337Translator'];
100 }
101
104 public $Messages;
105 }
106
107 ?>
eZ1337Translator
Translates text into the leet (1337) language.
Definition: ez1337translator.php:30
eZ1337Translator\findMessage
findMessage( $context, $source, $comment=null)
Definition: ez1337translator.php:38
eZ1337Translator\__construct
__construct()
Definition: ez1337translator.php:31
eZ1337Translator\leetify
leetify( $text)
Definition: ez1337translator.php:55
eZ1337Translator\$Messages
$Messages
Definition: ez1337translator.php:104
eZ1337Translator\translate
translate( $context, $source, $comment=null)
Definition: ez1337translator.php:74
eZ1337Translator\initialize
static initialize()
Definition: ez1337translator.php:89
eZTranslatorHandler
Base class for translation handling.
Definition: eztranslatorhandler.php:19
eZTranslatorManager\instance
static instance()
Definition: eztranslatormanager.php:127
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.