summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorxue <>2006-04-07 03:26:25 +0000
committerxue <>2006-04-07 03:26:25 +0000
commit8b7717c06b86262d188827fb26a4bfb2e480c256 (patch)
tree96023ccf343851aca76f4fb2af3f3d8b561546e2 /framework
parent87f0e27dc5bf7ac5695861c5ad7b5861540314b1 (diff)
Moved localize() into PradoBase.
Diffstat (limited to 'framework')
-rw-r--r--framework/I18N/Translation.php41
-rw-r--r--framework/PradoBase.php41
2 files changed, 41 insertions, 41 deletions
diff --git a/framework/I18N/Translation.php b/framework/I18N/Translation.php
index ba8ec0a5..960ff1f9 100644
--- a/framework/I18N/Translation.php
+++ b/framework/I18N/Translation.php
@@ -91,45 +91,4 @@ class Translation extends TComponent
}
}
-/**
- * Localize a text to the locale/culture specified in the globalization handler.
- * @param string text to be localized.
- * @param array a set of parameters to substitute.
- * @param string a different catalogue to find the localize text.
- * @param string the input AND output charset.
- * @return string localized text.
- * @see TTranslate::formatter()
- * @see TTranslate::init()
- */
-function localize($text, $parameters=array(), $catalogue=null, $charset=null)
-{
-
- $app = Prado::getApplication()->getGlobalization();
-
- $params = array();
- foreach($parameters as $key => $value)
- $params['{'.$key.'}'] = $value;
-
- //no translation handler provided
- if(is_null($config = $app->getTranslationConfiguration()))
- return strtr($text, $params);
-
- Translation::init();
-
- if(empty($catalogue) && isset($config['catalogue']))
- $catalogue = $config['catalogue'];
-
- //globalization charset
- $appCharset = is_null($app) ? '' : $app->getCharset();
-
- //default charset
- $defaultCharset = (is_null($app)) ? 'UTF-8' : $app->getDefaultCharset();
-
- //fall back
- if(empty($charset)) $charset = $appCharset;
- if(empty($charset)) $charset = $defaultCharset;
-
- return Translation::formatter()->format($text,$params,$catalogue,$charset);
-}
-
?> \ No newline at end of file
diff --git a/framework/PradoBase.php b/framework/PradoBase.php
index 59ab5b14..5325005a 100644
--- a/framework/PradoBase.php
+++ b/framework/PradoBase.php
@@ -519,6 +519,47 @@ class PradoBase
require_once(PRADO_DIR.'/Util/TVarDumper.php');
return TVarDumper::dump($var,$depth,$highlight);
}
+
+ /**
+ * Localize a text to the locale/culture specified in the globalization handler.
+ * @param string text to be localized.
+ * @param array a set of parameters to substitute.
+ * @param string a different catalogue to find the localize text.
+ * @param string the input AND output charset.
+ * @return string localized text.
+ * @see TTranslate::formatter()
+ * @see TTranslate::init()
+ */
+ public static function localize($text, $parameters=array(), $catalogue=null, $charset=null)
+ {
+ Prado::using('System.I18N.Translation');
+ $app = Prado::getApplication()->getGlobalization();
+
+ $params = array();
+ foreach($parameters as $key => $value)
+ $params['{'.$key.'}'] = $value;
+
+ //no translation handler provided
+ if(($config = $app->getTranslationConfiguration())===null)
+ return strtr($text, $params);
+
+ Translation::init();
+
+ if(empty($catalogue) && isset($config['catalogue']))
+ $catalogue = $config['catalogue'];
+
+ //globalization charset
+ $appCharset = $app===null ? '' : $app->getCharset();
+
+ //default charset
+ $defaultCharset = ($app===null) ? 'UTF-8' : $app->getDefaultCharset();
+
+ //fall back
+ if(empty($charset)) $charset = $appCharset;
+ if(empty($charset)) $charset = $defaultCharset;
+
+ return Translation::formatter()->format($text,$params,$catalogue,$charset);
+ }
}
/**