Commits

Frank Bennett committed 82b67df

Fix gender handling. Again.

Comments (0)

Files changed (2)

src/util_locale.js

     var blob, locale, nodes, attributes, pos, ppos, term, form, termname, styleopts, attr, date, attrname, len, genderform, target, i, ilen;
     lang_in = lang_in.replace("_", "-");
     lang_out = lang_out.replace("_", "-");
-    
+
     if (!this.locale[lang_out]) {
         this.locale[lang_out] = {};
         this.locale[lang_out].terms = {};
             } else {
                 var match = this.sys.xml.getAttributeValue(term, 'match');
                 var termstub = termname.slice(8);
+                var genderform = this.sys.xml.getAttributeValue(term, 'gender-form');
+                if (!genderform) {
+                    genderform = "neuter";
+                }
                 if (!match) {
                     match = "last-two-digits";
                     if (termstub.slice(0,1) === "0") {
                 if (termstub.slice(0,1) === "0") {
                     termstub = termstub.slice(1);
                 }
-                ordinals101[match][termstub] = termname;
+                if (!ordinals101[match][termstub]) {
+                    ordinals101[match][termstub] = {};
+                }
+                ordinals101[match][termstub][genderform] = termname;
             }
             this.locale[lang_out].ord.keys[termname] = true;
         }

src/util_number.js

                     delete this.suffixes[this.state.opt.lang][gender];
                     break;
                 }
-                this.suffixes[this.state.opt.lang][gender].push(ordinal);            
+                this.suffixes[this.state.opt.lang][gender].push(ordinal);
             }
         }
     }
     num = parseInt(num, 10);
     str = "" + num;
     var suffix = "";
+    var trygenders = [];
+    if (gender) {
+        trygenders.push(gender);
+    }
+    trygenders.push("neuter");
     if (this.state.locale[this.state.opt.lang].ord["1.0.1"]) {
-        suffix = this.state.getTerm("ordinal");
-        if (this.state.locale[this.state.opt.lang].ord["1.0.1"]["whole-number"][str]) {
-            suffix = this.state.getTerm(this.state.locale[this.state.opt.lang].ord["1.0.1"]["whole-number"][str],false,0,gender);
-        } else if (this.state.locale[this.state.opt.lang].ord["1.0.1"]["last-two-digits"][str.slice(str.length - 2)]) {
-            suffix = this.state.getTerm(this.state.locale[this.state.opt.lang].ord["1.0.1"]["last-two-digits"][str.slice(str.length - 2)],false,0,gender);
-        } else if (str === "0" && this.state.locale[this.state.opt.lang].ord["1.0.1"]["last-two-digits"][str.slice(str.length - 1)]) {
-            suffix = this.state.getTerm(this.state.locale[this.state.opt.lang].ord["1.0.1"]["last-two-digits"]["00"],false,0,gender);
-        } else if (this.state.locale[this.state.opt.lang].ord["1.0.1"]["last-digit"][str.slice(str.length - 1)]) {
-            suffix = this.state.getTerm(this.state.locale[this.state.opt.lang].ord["1.0.1"]["last-digit"][str.slice(str.length - 1)],false,0,gender);
+        suffix = this.state.getTerm("ordinal",false,0,gender);
+        var trygender;
+        for (var i = 0, ilen = trygenders.length; i < ilen; i += 1) {
+            trygender = trygenders[i];
+            var ordinfo = this.state.locale[this.state.opt.lang].ord["1.0.1"];
+            if (ordinfo["whole-number"][str] && ordinfo["whole-number"][str][trygender]) {
+                suffix = this.state.getTerm(this.state.locale[this.state.opt.lang].ord["1.0.1"]["whole-number"][str][trygender],false,0,gender);
+            } else if (ordinfo["last-two-digits"][str.slice(str.length - 2)] && ordinfo["last-two-digits"][str.slice(str.length - 2)][trygender]) {
+                suffix = this.state.getTerm(this.state.locale[this.state.opt.lang].ord["1.0.1"]["last-two-digits"][str.slice(str.length - 2)][trygender],false,0,gender);
+            } else if (ordinfo["last-digit"][str.slice(str.length - 1)] && ordinfo["last-digit"][str.slice(str.length - 1)][trygender]) {
+                suffix = this.state.getTerm(this.state.locale[this.state.opt.lang].ord["1.0.1"]["last-digit"][str.slice(str.length - 1)][trygender],false,0,gender);
+            }
+            if (suffix) {
+                break;
+            }
         }
     } else {
         this.state.fun.ordinalizer.init();