diff options
| author | Andy Staudacher <andy.st@gmail.com> | 2009-06-02 00:43:04 -0700 |
|---|---|---|
| committer | Andy Staudacher <andy.st@gmail.com> | 2009-06-02 00:43:04 -0700 |
| commit | 1cfed1fac1f2aa109e96c2aa5c9f66002610b0f8 (patch) | |
| tree | c3db88317ca0251829b370ef84343bcba1fd8dd9 /modules/gallery/libraries | |
| parent | f0395984109bb279b6dac157bff885b45e489a52 (diff) | |
Extend L10n client to provide UI for plural translation.
Ticket 148.
Diffstat (limited to 'modules/gallery/libraries')
| -rw-r--r-- | modules/gallery/libraries/I18n.php | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/modules/gallery/libraries/I18n.php b/modules/gallery/libraries/I18n.php index f2801169..03a6d8f6 100644 --- a/modules/gallery/libraries/I18n.php +++ b/modules/gallery/libraries/I18n.php @@ -148,30 +148,37 @@ class I18n_Core { public function has_translation($message, $options=null) { $locale = empty($options['locale']) ? $this->_config['default_locale'] : $options['locale']; - $count = empty($options['count']) ? null : $options['count']; - $values = $options; - unset($values['locale']); - $this->log($message, $options); $entry = $this->lookup($locale, $message); if (null === $entry) { return false; - } else if (!is_array($entry)) { + } else if (!is_array($message)) { return $entry !== ''; } else { - $plural_key = self::get_plural_key($locale, $count); - return isset($entry[$plural_key]) - && $entry[$plural_key] !== null - && $entry[$plural_key] !== ''; + if (!is_array($entry) || empty($entry)) { + return false; + } + // It would be better to verify that all the locale's plural forms have a non-empty + // translation, but this is fine for now. + foreach ($entry as $value) { + if ($value === '') { + return false; + } + } + return true; } } - public static function get_message_key($message) { + static function get_message_key($message) { $as_string = is_array($message) ? implode('|', $message) : $message; return md5($as_string); } + static function is_plural_message($message) { + return is_array($message); + } + private function interpolate($locale, $string, $values) { // TODO: Handle locale specific number formatting. |
