Location: PHPKode > projects > Sourdough > sourdough/Sd_FileConvert/Sd_FileConvert_i18n.class.php
<?php
//
// +--------------------------------------------------------------------+
// | Sourdough PHP Application Framework                                |
// +--------------------------------------------------------------------+
// | Copyright (c) 2001-2007 Philip Iezzi, phpee.com                    |
// | Web           http://sourdough.phpee.com/                          |
// | License       GNU Lesser General Public License (LGPL)             |
// +--------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or      |
// | modify it under the terms of the GNU Lesser General Public         |
// | License as published by the Free Software Foundation; either       |
// | version 2.1 of the License, or (at your option) any later version. |
// +--------------------------------------------------------------------+
//

/**
* Sourdough PHP Application Framework
* @package      sourdough
* @subpackage   fileconvert
*/
/**
* SOURDOUGH Shared Library
*
* This is a demonstration file filter for conversion of old language files
* to the new $__['I18N_*'] format.
*
* @package      sourdough
* @subpackage   fileconvert
* @author       Philip Iezzi <hide@address.com>
* @copyright    Copyright (c) 2001-2007 PHPEE.COM
* @license      http://opensource.org/licenses/lgpl-license.php GNU Lesser General Public License
* @version      $Id: Sd_FileConvert_i18n.class.php 3003 2007-12-08 11:05:17Z piezzi $
*/
class Sd_FileConvert_i18n extends Sd_FileConvert {
	/**
	* Run I18N syntax conversion.
	*
	* @return  string   target content
	*/
	public function convert()
	{
		$str = preg_replace('/\$loca\[\'(\w+)\'\]/', "I18N_\\1", $this->contSource);
		$str = preg_replace('/(I18N_\w*)\[\'(\w+)\'\]/', "\\1_\\2", $str);
		$str = preg_replace('/(I18N_\w*)\[\'(\w+)\'\]/', "\\1_\\2", $str);
		$str = preg_replace('/(I18N_\w*)\[\'(\w+)\'\]/', "\\1_\\2", $str);
		$this->contTarget = preg_replace('/(I18N_\w*)/e', "'__(\''.strtoupper('\\1').'\')'", $str);
		
		return $this->contTarget;
	}
	/**
	* Run I18N syntax conversion of localization calls.
	*
	* @return  string   target content
	*/
	public function convertCall()
	{
		$str = preg_replace('/Sd_Lang::getLoca\(\'([\w|:]*)/e',
		                   "'__(\'I18N_'.str_replace(':', '_', strtoupper('\\1'))",
						   $this->contSource);
		$this->contTarget = $str;
		return $this->contTarget;
	}
}
?>
Return current item: Sourdough