📚 Looking for current Exponential documentation? This site contains legacy SDK & API reference docs (eZ Publish era). For up-to-date 2026 product documentation, visit doc.exponential.earth.

  source / eztranslatormanager  

eztranslatormanager.php

Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZTranslatorManager class
00004 //
00005 // Created on: <10-Jun-2002 11:16:48 amos>
00006 //
00007 // Copyright (C) 1999-2003 Exponential. All rights reserved.
00008 //
00009 // This source file is part of the Exponential (tm) Open Source Content
00010 // Management System.
00011 //
00012 // This file may be distributed and/or modified under the terms of the
00013 // "GNU General Public License" version 2 as published by the Free
00014 // Software Foundation and appearing in the file LICENSE.GPL included in
00015 // the packaging of this file.
00016 //
00017 // Licencees holding valid "Exponential professional licences" may use this
00018 // file in accordance with the "Exponential professional licence" Agreement
00019 // provided with the Software.
00020 //
00021 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
00022 // THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00023 // PURPOSE.
00024 //
00025 // The "Exponential professional licence" is available at
00026 // https://exponential.earth/products/licences/professional/. For pricing of this licence
00027 // please contact us via e-mail to licence@exponential.earth. Further contact
00028 // information is available at https://exponential.earth/home/contact/.
00029 //
00030 // The "GNU General Public License" (GPL) is available at
00031 // http://www.gnu.org/copyleft/gpl.html.
00032 //
00033 // Contact licence@exponential.earth if any conditions of this licencing isn't clear to
00034 // you.
00035 //
00036 
00059 include_once( "lib/ezi18n/classes/eztranslatorhandler.php" );
00060 
eZTranslatorManager
00062 {
00065     function eZTranslatorManager()
00066     {
00067         $this->Handlers = array();
00068     }
00069 
findKey( $key )
00082     {
00083         $msg = null;
00084         for ( $i = 0; $i < count( $this->Handlers ) and $msg === null; ++$i )
00085         {
00086             $handler =& $this->Handlers[$i];
00087             if ( $handler->isKeyBased() )
00088                 $msg =& $handler->findKey( $key );
00089         }
00090         return $msg;
00091     }
00092 
findMessage( $context, $source, $comment = null )
00103     {
00104         if ( !is_string( $context ) or $context == "" )
00105             $context = "default";
00106         $msg = null;
00107         for ( $i = 0; $i < count( $this->Handlers ) and $msg === null; ++$i )
00108         {
00109             $handler =& $this->Handlers[$i];
00110             $msg =& $handler->findMessage( $context, $source, $comment );
00111         }
00112         return $msg;
00113     }
00114 
keyTranslate( $key )
00124     {
00125         $trans = null;
00126         for ( $i = 0; $i < count( $this->Handlers ) and $trans === null; ++$i )
00127         {
00128             $handler =& $this->Handlers[$i];
00129             if ( $handler->isKeyBased() )
00130                 $trans =& $handler->keyTranslate( $key );
00131         }
00132         return $trans;
00133     }
00134 
translate( $context, $source, $comment = null )
00141     {
00142         if ( !is_string( $context ) or $context == "" )
00143             $context = "default";
00144 //         if ( !isset( $this ) or get_class( $this ) != "eztranslatormanager" )
00145 //             $this =& eZTranslatorManager::instance();
00146         $trans = null;
00147         for ( $i = 0; $i < count( $this->Handlers ) and $trans === null; ++$i )
00148         {
00149             $handler =& $this->Handlers[$i];
00150             $trans =& $handler->translate( $context, $source, $comment );
00151         }
00152         return $trans;
00153     }
00154 
instance()
00160     {
00161         $instance =& $GLOBALS["eZTranslatorManagerInstance"];
00162         if ( get_class( $instance ) != "eztranslatormanager" )
00163         {
00164             $eZTranslatorManager();
00165         }
00166         return $instance;
00167     }
00168 
registerHandler( &$handler )
00174     {
00175         if ( !isset( $this ) or get_class( $this ) != "eztranslatormanager" )
00176             $this =& eZTranslatorManager::instance();
00177         $this->Handlers[] =& $handler;
00178     }
00179 
createKey( $context, $source, $comment = null )
00185     {
00186         if ( $comment === null )
00187             $comment = "";
00188         return md5( "$context\n$source\n$comment" );
00189     }
00190 
createMessage( $context, $source, $comment = null, $translation = null )
00197     {
00198         $msg = array( "context" => $context,
00199                       "source" => $source,
00200                       "comment" => $comment,
00201                       "translation" => $translation );
00202         return $msg;
00203     }
00204 
Handlers;
00208 }
00209 
00210 ?>
 

Exponential Copyright © 1998 - 2026 7x