From 1cfed1fac1f2aa109e96c2aa5c9f66002610b0f8 Mon Sep 17 00:00:00 2001 From: Andy Staudacher Date: Tue, 2 Jun 2009 00:43:04 -0700 Subject: Extend L10n client to provide UI for plural translation. Ticket 148. --- modules/gallery/helpers/l10n_client.php | 76 +++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/l10n_client.php b/modules/gallery/helpers/l10n_client.php index d26739f5..4e905c6c 100644 --- a/modules/gallery/helpers/l10n_client.php +++ b/modules/gallery/helpers/l10n_client.php @@ -200,4 +200,80 @@ class l10n_client_Core { // @todo Move messages out of outgoing into incoming, using new rev? // @todo show which messages have been rejected / are pending? } + + /** + * Plural forms. + */ + static function plural_forms($locale) { + $parts = explode('_', $locale); + $language = $parts[0]; + + // Data from CLDR 1.6 (http://unicode.org/cldr/data/common/supplemental/plurals.xml). + // Docs: http://www.unicode.org/cldr/data/charts/supplemental/language_plural_rules.html + switch ($language) { + case 'az': + case 'fa': + case 'hu': + case 'ja': + case 'ko': + case 'my': + case 'to': + case 'tr': + case 'vi': + case 'yo': + case 'zh': + case 'bo': + case 'dz': + case 'id': + case 'jv': + case 'ka': + case 'km': + case 'kn': + case 'ms': + case 'th': + return array('other'); + + case 'ar': + return array('zero', 'one', 'two', 'few', 'many', 'other'); + + case 'lv': + return array('zero', 'one', 'other'); + + case 'ga': + case 'se': + case 'sma': + case 'smi': + case 'smj': + case 'smn': + case 'sms': + return array('one', 'two', 'other'); + + case 'ro': + case 'mo': + case 'lt': + case 'cs': + case 'sk': + case 'pl': + return array('one', 'few', 'other'); + + case 'hr': + case 'ru': + case 'sr': + case 'uk': + case 'be': + case 'bs': + case 'sh': + case 'mt': + return array('one', 'few', 'many', 'other'); + + case 'sl': + return array('one', 'two', 'few', 'other'); + + case 'cy': + return array('one', 'two', 'many', 'other'); + + default: // en, de, etc. + return array('one', 'other'); + } + } } \ No newline at end of file -- cgit v1.2.3 From d8eca7682d36e66cffa86fd101998d72b4e413d1 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Tue, 2 Jun 2009 12:41:59 -0700 Subject: make cleanm static --- modules/gallery/helpers/p.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'modules/gallery/helpers') diff --git a/modules/gallery/helpers/p.php b/modules/gallery/helpers/p.php index c3074c23..0a6210dc 100644 --- a/modules/gallery/helpers/p.php +++ b/modules/gallery/helpers/p.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class p_Core { - function clean($dirty_html) { + static function clean($dirty_html) { return html::specialchars($dirty_html); } } -- cgit v1.2.3