summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Sack <mail@jakobsack.de>2013-08-01 19:54:51 +0200
committerJakob Sack <mail@jakobsack.de>2013-08-01 19:54:51 +0200
commit495e44e76c15d43eb847dd73317bdb9d6926ff31 (patch)
treef99fa7c7c540d57a9f165fc77483c998771c6fb8
parente064e53aa318bdfa43e62105e56f390f19a309f4 (diff)
downloadnextcloud-server-495e44e76c15d43eb847dd73317bdb9d6926ff31.tar.gz
nextcloud-server-495e44e76c15d43eb847dd73317bdb9d6926ff31.zip
Update l10n.php to read plural_forms string
-rw-r--r--lib/l10n.php30
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/l10n.php b/lib/l10n.php
index 8348962cc10..d24717a23a2 100644
--- a/lib/l10n.php
+++ b/lib/l10n.php
@@ -55,6 +55,11 @@ class OC_L10N{
private $translations = array();
/**
+ * Plural forms
+ */
+ private $plural_forms = "";
+
+ /**
* Localization
*/
private $localizations = array(
@@ -138,6 +143,9 @@ class OC_L10N{
}
}
}
+ if(isset($PLURAL_FORMS)) {
+ $this->plural_forms = $PLURAL_FORMS;
+ }
}
if(file_exists(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php')) {
@@ -177,18 +185,13 @@ class OC_L10N{
* Returns the translation. If no translation is found, $text will be
* returned. %n will be replaced with the number of objects.
*
- * In case there is more than one plural form you can add a function
- * "selectplural" in core/l10n/l10n-*.php
- *
- * Example:
+ * The correct plural is determined by the plural_forms-function
+ * provided by the po file.
*
- * [...]
- * 'selectplural' => function($i){return $i == 1 ? 0 : $i == 2 ? 1 : 2},
- * [...]
*/
public function n($text_singular, $text_plural, $count, $parameters = array()) {
$identifier = "_${text_singular}__${text_plural}_";
- if(array_key_exists( $this->localizations, "selectplural") && array_key_exists($this->translations, $identifier)) {
+ if( array_key_exists($this->translations, $identifier)) {
return new OC_L10N_String( $this, $identifier, $parameters, $count );
}
else{
@@ -236,6 +239,17 @@ class OC_L10N{
}
/**
+ * @brief getPluralForms
+ * @returns Fetches the gettext "Plural-Forms"-string
+ *
+ * Returns a string like "nplurals=2; plural=(n != 1);"
+ */
+ public function getPluralForms() {
+ $this->init();
+ return $this->plural_forms;
+ }
+
+ /**
* @brief get localizations
* @returns Fetch all localizations
*