From 9ab64ec44d68bcc7b940b610855ebfdb5139639a Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 11 Aug 2016 17:42:00 -0700 Subject: [PATCH] Allow localization of month-day format string The short month-day format ex: 'Aug 8', is not built-in to momentjs, so we need to localize it. // FREEBIE --- _locales/en/messages.json | 4 ++++ js/views/timestamp_view.js | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index ba3e56ee..3786e9e4 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -320,5 +320,9 @@ "timestamp_h": { "description": "Brief timestamp for messages sent about one minute ago. Displayed in the conversation list and message bubble.", "message": "1 hour" + }, + "timestampFormat_M": { + "description": "Timestamp format string for displaying month and day (but not the year) of a date within the current year, ex: use 'MMM D' for 'Aug 8', or 'D MMM' for '8 Aug'.", + "message": "MMM D" } } diff --git a/js/views/timestamp_view.js b/js/views/timestamp_view.js index 3de8b515..ff8b108a 100644 --- a/js/views/timestamp_view.js +++ b/js/views/timestamp_view.js @@ -53,7 +53,7 @@ return timestamp.format(this._format.y); } else if (timediff.months() > 0 || timediff.days() > 6) { this.delay = null; - return timestamp.format(this._format.mo); + return timestamp.format(this._format.M); } else if (timediff.days() > 0) { this.delay = moment(timestamp).add(timediff.days() + 1,'d').diff(moment()); return timestamp.format(this._format.d); @@ -78,8 +78,8 @@ return moment.duration(number, string).humanize(); }, _format: { - y: "MMM D, YYYY", - mo: "MMM D", + y: "ll", + M: i18n('timestampFormat_M') || "MMM D", d: "ddd" } }); @@ -88,8 +88,8 @@ return moment.duration(-1 * number, string).humanize(string !== 's'); }, _format: { - y: "MMM D, YYYY LT", - mo: "MMM D LT", + y: "lll", + M: (i18n('timestampFormat_M') || "MMM D") + ' LT', d: "ddd LT" } });