eZ Publish  [4.0]
ezgeneratetranslationcache.php
Go to the documentation of this file.
00001 #!/usr/bin/env php
00002 <?php
00003 //
00004 // Created on: <6-Apr-2007 15:00:00 dl>
00005 //
00006 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00007 // SOFTWARE NAME: eZ Publish
00008 // SOFTWARE RELEASE: 4.0.x
00009 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00010 // SOFTWARE LICENSE: GNU General Public License v2.0
00011 // NOTICE: >
00012 //   This program is free software; you can redistribute it and/or
00013 //   modify it under the terms of version 2.0  of the GNU General
00014 //   Public License as published by the Free Software Foundation.
00015 //
00016 //   This program is distributed in the hope that it will be useful,
00017 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 //   GNU General Public License for more details.
00020 //
00021 //   You should have received a copy of version 2.0 of the GNU General
00022 //   Public License along with this program; if not, write to the Free
00023 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00024 //   MA 02110-1301, USA.
00025 //
00026 //
00027 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00028 //
00029 
00030 // Generate caches for translations
00031 // file  bin/php/ezgeneratetranslationcache.php
00032 
00033 
00034 /**************************************************************
00035 * script initializing                                         *
00036 ***************************************************************/
00037 
00038 //include_once( 'kernel/classes/ezscript.php' );
00039 
00040 require 'autoload.php';
00041 
00042 $cli = eZCLI::instance();
00043 $script = eZScript::instance( array( 'description' => ( "\n" .
00044                                                         "This script will generate caches for translations.\n" .
00045                                                         "Default usage: ./bin/php/ezgeneratetranslationcache -s setup\n" ),
00046                                      'use-session' => false,
00047                                      'use-modules' => true,
00048                                      'use-extensions' => true,
00049                                      'user' => true ) );
00050 $script->startup();
00051 
00052 $scriptOptions = $script->getOptions( "[ts-list:]",
00053                                       "",
00054                                       array( 'ts-list' => "A list of translations to generate caches for, for example 'rus-RU nor-NO'\n".
00055                                                           "By default caches for all translations will be generated" ),
00056                                       false,
00057                                       array( 'user' => true )
00058                                      );
00059 $script->initialize();
00060 
00061 //include_once( 'lib/ezi18n/classes/eztstranslator.php' );
00062 //include_once( 'lib/ezi18n/classes/eztranslatormanager.php' );
00063 
00064 /**************************************************************
00065 * process options                                             *
00066 ***************************************************************/
00067 
00068 //
00069 // 'ts-list' option
00070 //
00071 $translations = isset( $scriptOptions['ts-list'] ) ? split( ' ', $scriptOptions['ts-list'] ) : array();
00072 $translations = eZTSTranslator::fetchList( $translations );
00073 
00074 
00075 /**************************************************************
00076 * do the work
00077 ***************************************************************/
00078 
00079 $cli->output( $cli->stylize( 'blue', "Processing: " ), false );
00080 
00081 $ini = eZINI::instance();
00082 
00083 foreach( $translations as $translation )
00084 {
00085     $cli->output( "$translation->Locale ", false );
00086 
00087     $ini->setVariable( 'RegionalSettings', 'Locale', $translation->Locale );
00088     eZTranslationCache::resetGlobals();
00089 
00090     $translation->load( '' );
00091 }
00092 
00093 $cli->output( "", true );
00094 
00095 $script->shutdown( 0 );
00096 
00097 ?>