Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

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