Fix for CLDR plural rule parser for old browsers without String.trim
authorBrion Vibber <brion@pobox.com>
Fri, 28 Feb 2014 21:13:02 +0000 (13:13 -0800)
committerBrion Vibber <brion@pobox.com>
Fri, 28 Feb 2014 21:16:42 +0000 (13:16 -0800)
This fixes MobileFrontend's "last modified" message on Kindle 3.4

Submitted upstream as https://github.com/santhoshtr/CLDRPluralRuleParser/pull/10

Bug: 62072
Change-Id: I350264847417f521c111e3cb81da46805608425a

resources/mediawiki.libs/CLDRPluralRuleParser.js

index 3def37c..83c2524 100644 (file)
@@ -45,7 +45,7 @@ function pluralRuleParser(rule, number) {
        */
 
        // we don't evaluate the samples section of the rule. Ignore it.
-       rule = rule.split('@')[0].trim();
+       rule = rule.split('@')[0].replace(/^\s*/, '').replace(/\s*$/, '');
 
        if (!rule.length) {
                // empty rule or 'other' rule.