From bb8131528e20e71e2ab98460a00f54519866ceb2 Mon Sep 17 00:00:00 2001 From: Tony Valle <79843014+superskip@users.noreply.github.com> Date: Tue, 7 Mar 2023 22:30:23 +0100 Subject: [PATCH] fix: [DHIS2-14596] use English as fallback in date picker (#1672) --- d2-tracker/dhis2.angular.services.js | 5 +++++ index.ejs | 3 ++- .../{jquery.calendars-no.js => jquery.calendars-nb.js} | 6 +++--- ...calendars.picker-no.js => jquery.calendars.picker-nb.js} | 4 ++-- 4 files changed, 12 insertions(+), 6 deletions(-) rename vendor/jquery.calendars.package-1.2.1/{jquery.calendars-no.js => jquery.calendars-nb.js} (78%) rename vendor/jquery.calendars.package-1.2.1/{jquery.calendars.picker-no.js => jquery.calendars.picker-nb.js} (85%) diff --git a/d2-tracker/dhis2.angular.services.js b/d2-tracker/dhis2.angular.services.js index 006e6a51e..47f75187e 100644 --- a/d2-tracker/dhis2.angular.services.js +++ b/d2-tracker/dhis2.angular.services.js @@ -133,6 +133,8 @@ var d2Services = angular.module('d2Services', ['ngResource']) /* service for getting calendar setting */ .service('CalendarService', function (storage, SessionStorageService, $rootScope) { + // The following array should be manually kept in sync with the one in `index.ejs` + const supportedCalendarLocales = ['ar', 'ar-EG', 'zn-CH', 'cs', 'da', 'nl', 'fr', 'km', 'lo', 'nb', 'pt-BR', 'ro', 'ru', 'es', 'sv', 'uk', 'ur', 'vi']; return { getSetting: function () { @@ -142,6 +144,9 @@ var d2Services = angular.module('d2Services', ['ngResource']) var userSettings = SessionStorageService.get('USER_SETTING'); dhis2CalendarFormat.locale = userSettings.keyUiLocale.replace('_', '-'); + if (!supportedCalendarLocales.find(locale => locale === dhis2CalendarFormat.locale)) { + dhis2CalendarFormat.locale = 'en'; + } if (angular.isObject(storedFormat) && storedFormat.keyDateFormat && storedFormat.keyCalendar) { if (storedFormat.keyCalendar === 'iso8601') { diff --git a/index.ejs b/index.ejs index 618bb6b24..d9f14dace 100644 --- a/index.ejs +++ b/index.ejs @@ -52,7 +52,8 @@ - <% const supportedCalendarLocales = ['ar', 'ar-EG', 'zn-CH', 'cs', 'da', 'nl', 'fr', 'km', 'lo', 'pt-BR', 'ro', 'ru', 'es', 'sv', 'uk', 'ur', 'vi']; %> + + <% const supportedCalendarLocales = ['ar', 'ar-EG', 'zn-CH', 'cs', 'da', 'nl', 'fr', 'km', 'lo', 'nb', 'pt-BR', 'ro', 'ru', 'es', 'sv', 'uk', 'ur', 'vi']; %> <% supportedCalendarLocales.forEach(locale => { %> diff --git a/vendor/jquery.calendars.package-1.2.1/jquery.calendars-no.js b/vendor/jquery.calendars.package-1.2.1/jquery.calendars-nb.js similarity index 78% rename from vendor/jquery.calendars.package-1.2.1/jquery.calendars-no.js rename to vendor/jquery.calendars.package-1.2.1/jquery.calendars-nb.js index 719c5cff4..9c5d9faf9 100644 --- a/vendor/jquery.calendars.package-1.2.1/jquery.calendars-no.js +++ b/vendor/jquery.calendars.package-1.2.1/jquery.calendars-nb.js @@ -2,7 +2,7 @@ Norwegian localisation for Gregorian/Julian calendars for jQuery. Written by Naimdjon Takhirov (naimdjon@gmail.com). */ (function($) { - $.calendars.calendars.gregorian.prototype.regional['no'] = { + $.calendars.calendars.gregorian.prototype.regional['nb'] = { name: 'Gregorian', epochs: ['BCE', 'CE'], monthNames: ['Januar','Februar','Mars','April','Mai','Juni', @@ -17,7 +17,7 @@ isRTL: false }; if ($.calendars.calendars.julian) { - $.calendars.calendars.julian.prototype.regional['no'] = - $.calendars.calendars.gregorian.prototype.regional['no']; + $.calendars.calendars.julian.prototype.regional['nb'] = + $.calendars.calendars.gregorian.prototype.regional['nb']; } })(jQuery); diff --git a/vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker-no.js b/vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker-nb.js similarity index 85% rename from vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker-no.js rename to vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker-nb.js index 8bb23ee04..c28190b26 100644 --- a/vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker-no.js +++ b/vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker-nb.js @@ -2,7 +2,7 @@ Norwegian localisation for calendars datepicker for jQuery. Written by Naimdjon Takhirov (naimdjon@gmail.com). */ (function($) { - $.calendars.picker.regional['no'] = { + $.calendars.picker.regional['nb'] = { renderer: $.calendars.picker.defaultRenderer, prevText: '«Forrige', prevStatus: '', prevJumpText: '<<', prevJumpStatus: '', @@ -17,5 +17,5 @@ dayStatus: 'DD, M d', defaultStatus: '', isRTL: false }; - $.calendars.picker.setDefaults($.calendars.picker.regional['no']); + $.calendars.picker.setDefaults($.calendars.picker.regional['nb']); })(jQuery);