[pLog-svn] r1876 - in plog/branches/plog-1.0.1/class: action/admin
locale
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Tue Apr 19 18:26:51 GMT 2005
Author: oscar
Date: 2005-04-19 18:26:51 +0000 (Tue, 19 Apr 2005)
New Revision: 1876
Modified:
plog/branches/plog-1.0.1/class/action/admin/adminaddlocaleaction.class.php
plog/branches/plog-1.0.1/class/locale/localefinder.class.php
plog/branches/plog-1.0.1/class/locale/locales.class.php
Log:
this should allow for more permissive locale names as per mark's request here: http://bugs.plogworld.net/view.php?id=435.
So far only locale names such as locale_xx_YY.php were accepted as valid locale files but now things like locale_xx_YY_whatever-you-want-to-write-here.php are also accepted as valid locale names. This should allow site administrator to provide the same language in different encodings and leave it up to the blog owner to decide which one to use.
Hope this helps :)
Modified: plog/branches/plog-1.0.1/class/action/admin/adminaddlocaleaction.class.php
===================================================================
--- plog/branches/plog-1.0.1/class/action/admin/adminaddlocaleaction.class.php 2005-04-19 17:48:15 UTC (rev 1875)
+++ plog/branches/plog-1.0.1/class/action/admin/adminaddlocaleaction.class.php 2005-04-19 18:26:51 UTC (rev 1876)
@@ -105,8 +105,7 @@
// and once it's there, we can do as if we were adding a locale code
$upload = new FileUpload( $files["localeFile"] );
- $regexp = "/locale_([a-z][a-z]_[A-Z][A-Z])\.php/";
- $res = preg_match( $regexp, $upload->getFileName(), $matches );
+ $res = preg_match( REGEXP_VALID_LOCALE, $upload->getFileName(), $matches );
$localeCode = $matches[1];
// add the file to the list of locales
Modified: plog/branches/plog-1.0.1/class/locale/localefinder.class.php
===================================================================
--- plog/branches/plog-1.0.1/class/locale/localefinder.class.php 2005-04-19 17:48:15 UTC (rev 1875)
+++ plog/branches/plog-1.0.1/class/locale/localefinder.class.php 2005-04-19 18:26:51 UTC (rev 1876)
@@ -31,9 +31,12 @@
*/
function getKeyForFile( $fileName )
{
- $regexp = "/.*locale_([a-z]{2}_[A-Z]{2})/";
- $result = preg_match( $regexp, $fileName, $matches );
+ // this regexp allows for more permissive locale names so that people can
+ // at least have things like locale_xx_YY_utf-8.php
+ $result = preg_match( REGEXP_VALID_LOCALE, $fileName, $matches );
+ print("filename = $fileName<br/>");
+
// in case there is some crap in the locale/ folder, then ignore
// it (that is, if the file name does not match our regexp!
if( !$result )
@@ -53,7 +56,7 @@
function find()
{
// first find the new ones
- parent::find( Locales::getAvailableLocales(), "locale_??_??.php" );
+ parent::find( Locales::getAvailableLocales(), "locale_*.php" );
// and then return them, if any
return( $this->getNew());
Modified: plog/branches/plog-1.0.1/class/locale/locales.class.php
===================================================================
--- plog/branches/plog-1.0.1/class/locale/locales.class.php 2005-04-19 17:48:15 UTC (rev 1875)
+++ plog/branches/plog-1.0.1/class/locale/locales.class.php 2005-04-19 18:26:51 UTC (rev 1876)
@@ -7,6 +7,8 @@
include_once( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
define("DEFAULT_LOCALE", "en_UK");
+
+ define( "REGEXP_VALID_LOCALE", "/.*locale_([a-z]{2}_[A-Z]{2}_?([a-zA-Z0-9\-]*)+)\.php$/" );
/**
* \ingroup Locale
@@ -177,8 +179,7 @@
*/
function isValidLocaleFileName( $fileName )
{
- $regexp = "/locale_([a-z]{2}_[A-Z]{2})\.php/";
- return( preg_match( $regexp, $fileName ));
+ return( preg_match( REGEXP_VALID_LOCALE, $fileName ));
}
/**
More information about the pLog-svn
mailing list