Re: Configure flag for turning on/off the function alias"_()" for "gettext()"

Moriyoshi Koizumi <[email protected]>
Newsgroups gmane.comp.php.internationalization
Message-ID <20031005093513HR7NJ#@at.wakwak.com>
Hi,

Perhaps it'd be better to write a feature request at http://bugs.php.net/ .
I like your idea, but could it be that simple by preparing a function like 
__() and using it everywhere instead.

<?php // sample
if ($CONFIG['DEBUG_MODE']) {
	function __($str) {
		$retval = gettext($str);
		if ($str == $retval) {
			trigger_error("missing translation for "$str", E_USER_NOTICE);
		}
		return $retval;
	}
} else {
	function __($str) {
		return gettext($str);
	}
}
?>

Moriyoshi

> 
> Not sure if this is right place for this, but anyways:
> 
> Wouldn't it be nice to have a configure flag for turning on/off the 
> function alias _() for the gettext() function, or maybe even a php.ini 
> setting if that's possible.
> 
> If this feature existed it would be possible to create your own _() 
> function which could do things in addition to calling gettext().
> 
> Example:
> function _($string) {
> 	$ret = gettext($string);
> 	if ($ret == $string) {
> 		/***
> 		... notify of missing msgid in .mo/.po file ...
> 		***/
> 	}
> 	return $ret;
> }
> 
> This however would be slower than using the alias _() directly, but it 
> would be _VERY_ nice to have for debugging and development purposes.
> 
> -- 
> Bjørn Tore Hagen
> Programmer
> 
> -- 
> PHP Internationalization Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

-- 
PHP Internationalization Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.