00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 include_once( "lib/ezi18n/classes/eztranslatorhandler.php" );
00053
00054 class eZ1337Translator extends eZTranslatorHandler
00055 {
00056
00057
00058
00059 function eZ1337Translator()
00060 {
00061 $this->eZTranslatorHandler( false );
00062
00063 $this->Messages = array();
00064 }
00065
00066
00067
00068
00069 function findMessage( $context, $source, $comment = null )
00070 {
00071 $man = eZTranslatorManager::instance();
00072 $key = $man->createKey( $context, $source, $comment );
00073
00074 if ( !isset( $this->Messages[$key] ) )
00075 {
00076 $translation = $this->leetify( $source );
00077 $this->Messages[$key] = $man->createMessage( $context, $source, $comment, $translation );
00078 }
00079
00080 return $this->Messages[$key];
00081 }
00082
00083
00084
00085
00086 function &leetify( $text )
00087 {
00088 $text = preg_replace( "/to/", "2", $text );
00089 $text = preg_replace( "/for/", "4", $text );
00090 $text = preg_replace( "/ate/", "8", $text );
00091 $text = preg_replace( "/you/", "u", $text );
00092 $text = preg_replace( array( "/l/",
00093 "/e/",
00094 "/o/",
00095 "/a/",
00096 "/t/" ),
00097 array( "1",
00098 "3",
00099 "0",
00100 "4",
00101 "7" ), $text );
00102 return $text;
00103 }
00104
00105
00106
00107
00108 function translate( $context, $source, $comment = null )
00109 {
00110 $msg = $this->findMessage( $context, $source, $comment );
00111 if ( $msg !== null )
00112 {
00113 return $msg["translation"];
00114 }
00115
00116 return null;
00117 }
00118
00119
00120
00121
00122
00123 function &initialize()
00124 {
00125 $translator =& $GLOBALS["eZ1337Translator"];
00126 if ( isset( $translator ) and get_class( $translator ) == "ez1337translator" )
00127 return $translator;
00128 $translator = new eZ1337Translator();
00129 $man =& eZTranslatorManager::instance();
00130 $man->registerHandler( $translator );
00131 return $translator;
00132 }
00133
00134
00135
00136 var $Messages;
00137 }
00138
00139 ?>