]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
added some comments
authorIsaac Cambron <isaac@isaaccambron.com>
Wed, 2 Oct 2013 21:29:24 +0000 (17:29 -0400)
committerIsaac Cambron <isaac@isaaccambron.com>
Wed, 2 Oct 2013 21:29:24 +0000 (17:29 -0400)
moment.js
test/moment/lang.js

index f57c1214203bf20884d11a1c4682c292b9e17f96..82b6ec31511bac389355ae07eca7e7767de72d22 100644 (file)
--- a/moment.js
+++ b/moment.js
             key = [key];
         }
 
+        //pick the language from the array
+        //try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
+        //substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
         while (i < key.length) {
             split = normalizeLanguage(key[i]).split('-');
             j = split.length;
index b0d4654ad092df1f1255577bc12e3cea405ab95e..6e42cc13fb1ebe600844d139a142534d4a7b6144 100644 (file)
@@ -51,6 +51,7 @@ exports.lang = {
         test.equals(moment.lang(['fake-CA', 'fake-MX', 'fr']), 'fr', "always find something if possible");
         test.equals(moment.lang(['fake-CA', 'fake-MX', 'fr']), 'fr', "always find something if possible");
         test.equals(moment.lang(['fake-CA', 'fake-MX', 'fr-fake-fake-fake']), 'fr', "always find something if possible");
+        test.equals(moment.lang(['en', 'en-CA']), 'en', "prefer earlier if it works");
         test.done();
     },