[pLog-svn] r856 - plog/trunk/class/locale
ork at devel.plogworld.net
ork at devel.plogworld.net
Thu Jan 27 00:52:35 GMT 2005
Author: ork
Date: 2005-01-27 00:52:35 +0000 (Thu, 27 Jan 2005)
New Revision: 856
Modified:
plog/trunk/class/locale/locale.class.php
Log:
- added default direction
- changed _loadLocaleInfo to use default values
few tweaks to not throw warnings..
Modified: plog/trunk/class/locale/locale.class.php
===================================================================
--- plog/trunk/class/locale/locale.class.php 2005-01-27 00:49:18 UTC (rev 855)
+++ plog/trunk/class/locale/locale.class.php 2005-01-27 00:52:35 UTC (rev 856)
@@ -18,6 +18,11 @@
* default encoding if the locale does not specify one
*/
define( "DEFAULT_ENCODING", "iso-8859-1" );
+
+ /**
+ * default direction for texts, if the locale does not specify one
+ */
+ define( "DEFAULT_DIRECTION", "ltr" );
/**
* Class used to localize messages and things such as dates and numbers.
@@ -108,15 +113,13 @@
$this->_loadLocaleFile();
// get the info that we need
- $this->_description = $this->_messages["locale_description"];
- $this->_charset = $this->_messages["encoding"];
- $this->_direction = $this->_messages["direction"];
- $this->_dateFormat = $this->_messages["date_format"];
- // use a default one if none available
- if( $this->_dateFormat == "" )
- $this->_dateFormat = DEFAULT_LOCALE_FORMAT;
+ $this->_description = isset($this->_messages["locale_description"]) ? $this->_messages["locale_description"] : "no description for " . $this->_code;
+ $this->_charset = isset($this->_messages["encoding"]) ? $this->_messages["encoding"] : DEFAULT_ENCODING;
+ $this->_direction = isset($this->_messages["direction"]) ? $this->_messages["direction"] : DEFAULT_DIRECTION;
+ $this->_dateFormat = isset($this->_messages["date_format"]) ? $this->_messages["date_format"] : DEFAULT_LOCALE_FORMAT;
unset( $this->_messages );
+
$this->_messages = NULL;
$this->log->debug('Freeing memory for locate ' . $this->_code . ': ' . memory_get_usage());
@@ -195,15 +198,18 @@
function getString( $id )
{
// load the file if it hadn't been loaded yet
- if( !is_array($this->_messages)) {
+ if( !is_array($this->_messages) ) {
$this->_loadLocaleFile();
}
- $string = $this->_messages[ $id ];
- if( $string == "" )
+ if( array_key_exists($id, $this->_messages) &&
+ $this->_messages[ $id ] != "" ) {
+ $string = $this->_messages[ $id ];
+ } else {
$string = $id;
+ }
- if( $this->_direction == "rtl" )
+ if( $this->getDirection() == "rtl" )
$string = "<span dir=\"rtl\">$string</span>";
return $string;
More information about the pLog-svn
mailing list