Browse Source

Cherry-pick only those languages from Moment which we support in converse.js

JC Brand 10 năm trước cách đây
mục cha
commit
c745e1ebff
10 tập tin đã thay đổi với 63 bổ sung10 xóa
  1. 1 1
      bower.json
  2. 5 4
      converse.js
  3. 19 1
      main.js
  4. 1 0
      spec/chatbox.js
  5. 1 1
      src/deps-full.js
  6. 1 1
      src/deps-no-otr.js
  7. 1 1
      src/deps-website-no-otr.js
  8. 1 1
      src/deps-website.js
  9. 2 0
      src/locales.js
  10. 31 0
      src/moment_locales.js

+ 1 - 1
bower.json

@@ -22,7 +22,7 @@
     "almond": "~0.3.0",
     "requirejs-text": "~2.0.12",
     "requirejs-tpl-jcbrand": "*",
-    "momentjs": "~2.6.0",
+    "momentjs": "~2.10.3",
     "jquery.browser": ">=0.0.7",
     "jquery-easing-original": "https://raw.githubusercontent.com/jcbrand/jquery.easing/7de3458b1845a72c1f407debf6b223c8446396bf/jquery.easing.1.3.js",
     "bootstrap": "~3.2.0",

+ 5 - 4
converse.js

@@ -6126,14 +6126,15 @@
             }
         },
         'env': {
-            'jQuery': $,
-            'Strophe': Strophe,
             '$build': $build,
             '$iq': $iq,
-            '$pres': $pres,
             '$msg': $msg,
+            '$pres': $pres,
+            'Strophe': Strophe,
             '_': _,
-            'b64_sha1':  b64_sha1
+            'b64_sha1':  b64_sha1,
+            'jQuery': $,
+            'moment': moment
         }
     };
 }));

+ 19 - 1
main.js

@@ -26,7 +26,7 @@ require.config({
         "jquery-private":           "src/jquery-private",
         "jquery.browser":           "components/jquery.browser/dist/jquery.browser",
         "jquery.easing":            "components/jquery-easing-original/index",          // XXX: Only required for https://conversejs.org website
-        "moment":                   "components/momentjs/min/moment-with-langs",
+        "moment":                   "components/momentjs/min/moment.min",
         "strophe-base64":           "components/strophejs/src/base64",
         "strophe-bosh":             "components/strophejs/src/bosh",
         "strophe-core":             "components/strophejs/src/core",
@@ -83,6 +83,24 @@ require.config({
         "uk":        "locale/uk/LC_MESSAGES/converse.json",
         "zh":        "locale/zh/LC_MESSAGES/converse.json",
 
+        "moment_with_locales": "src/moment_locales",
+        'moment_af':        "components/momentjs/locale/af",
+        'moment_de':        "components/momentjs/locale/de",
+        'moment_es':        "components/momentjs/locale/es",
+        'moment_fr':        "components/momentjs/locale/fr",
+        'moment_he':        "components/momentjs/locale/he",
+        'moment_hu':        "components/momentjs/locale/hu",
+        'moment_id':        "components/momentjs/locale/id",
+        'moment_it':        "components/momentjs/locale/it",
+        'moment_ja':        "components/momentjs/locale/ja",
+        'moment_nb':        "components/momentjs/locale/nb",
+        'moment_nl':        "components/momentjs/locale/nl",
+        'moment_pl':        "components/momentjs/locale/pl",
+        'moment_pt-br':     "components/momentjs/locale/pt-br",
+        'moment_ru':        "components/momentjs/locale/ru",
+        'moment_uk':        "components/momentjs/locale/uk",
+        'moment_zh':        "components/momentjs/locale/zh-cn",
+
         // Templates
         "action":                   "src/templates/action",
         "add_contact_dropdown":     "src/templates/add_contact_dropdown",

+ 1 - 0
spec/chatbox.js

@@ -10,6 +10,7 @@
 } (this, function ($, mock, test_utils) {
     var $msg = converse_api.env.$msg;
     var Strophe = converse_api.env.Strophe;
+    var moment = converse_api.env.moment;
 
     return describe("Chatboxes", $.proxy(function(mock, test_utils) {
         describe("A Chatbox", $.proxy(function () {

+ 1 - 1
src/deps-full.js

@@ -2,7 +2,7 @@ define("converse-dependencies", [
     "jquery",
     "utils",
     "otr",
-    "moment",
+    "moment_with_locales",
     "strophe",
     "strophe.vcard",
     "strophe.disco",

+ 1 - 1
src/deps-no-otr.js

@@ -1,7 +1,7 @@
 define("converse-dependencies", [
     "jquery",
     "utils",
-    "moment",
+    "moment_with_locales",
     "strophe",
     "strophe.vcard",
     "strophe.disco",

+ 1 - 1
src/deps-website-no-otr.js

@@ -1,7 +1,7 @@
 define("converse-dependencies", [
     "jquery",
     "utils",
-    "moment",
+    "moment_with_locales",
     "strophe",
     "strophe.vcard",
     "strophe.disco",

+ 1 - 1
src/deps-website.js

@@ -3,7 +3,7 @@ define("converse-dependencies", [
     "underscore",
     "utils",
     "otr",
-    "moment",
+    "moment_with_locales",
     "strophe",
     "strophe.vcard",
     "strophe.disco",

+ 2 - 0
src/locales.js

@@ -3,6 +3,8 @@
  *
  * Translations take up a lot of space and you are therefore advised to remove
  * from here any languages that you don't need.
+ *
+ * See also src/moment_locales.js
  */
 (function (root, factory) {
     define("locales", ['jquery', 'jed', 

+ 31 - 0
src/moment_locales.js

@@ -0,0 +1,31 @@
+/*
+ * This file specifies the supported locales for moment.js.
+ *
+ * Translations take up a lot of space and you are therefore advised to remove
+ * from here any languages that you don't need.
+ *
+ * See also src/locales.js
+ */
+(function (root, factory) {
+    define("moment_with_locales", [
+        'moment',   // Everything below can be removed except for moment itself.
+        'moment_af',
+        'moment_de',
+        'moment_es',
+        'moment_fr',
+        'moment_he',
+        'moment_hu',
+        'moment_id',
+        'moment_it',
+        'moment_ja',
+        'moment_nb',
+        'moment_nl',
+        'moment_pl',
+        'moment_pt-br',
+        'moment_ru',
+        'moment_uk',
+        'moment_zh'
+        ], function (moment) {
+            return moment;
+        });
+})(this);