summaryrefslogtreecommitdiff
path: root/core/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'core/libraries')
-rw-r--r--core/libraries/I18n.php26
1 files changed, 24 insertions, 2 deletions
diff --git a/core/libraries/I18n.php b/core/libraries/I18n.php
index 2007bb07..0aa6652b 100644
--- a/core/libraries/I18n.php
+++ b/core/libraries/I18n.php
@@ -19,12 +19,34 @@
*/
/**
- * @see I18n_Core::translate($message, $options)
+ * Translates a localizable message.
+ * @param $message String The message to be translated. E.g. "Hello world"
+ * @param $options array (optional) Options array for key value pairs which are used
+ * for pluralization and interpolation. Special key: "locale" to override the
+ * currently configured locale.
+ * @return String The translated message string.
*/
function t($message, $options=array()) {
return I18n::instance()->translate($message, $options);
}
+/**
+ * Translates a localizable message with plural forms.
+ * @param $singular String The message to be translated. E.g. "There is one album."
+ * @param $plural String The plural message to be translated. E.g.
+ * "There are %count albums."
+ * @param $count Number The number which is inserted for the %count placeholder and
+ * which is used to select the proper plural form ($singular or $plural).
+ * @param $options array (optional) Options array for key value pairs which are used
+ * for pluralization and interpolation. Special key: "locale" to override the
+ * currently configured locale.
+ * @return String The translated message string.
+ */
+function t2($singular, $plural, $count, $options=array()) {
+ return I18n::instance()->translate(array("one" => $singular, "other" => $plural),
+ array_merge($options, array("count" => $count)));
+}
+
class I18n_Core {
private $_config = array();
@@ -52,7 +74,7 @@ class I18n_Core {
* the latter to override the currently configured locale.
* @return String The translated message string.
*/
- public function translate($message, $options=array() /** @todo , $hint=null */) {
+ public function translate($message, $options=array()) {
$locale = empty($options['locale']) ? $this->_config['default_locale'] : $options['locale'];
$count = empty($options['count']) ? null : $options['count'];
$values = $options;