Skip to content

Commit

Permalink
fix: [DHIS2-14596] use English as fallback in date picker (#1672)
Browse files Browse the repository at this point in the history
  • Loading branch information
superskip authored Mar 7, 2023
1 parent 0889117 commit bb81315
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions d2-tracker/dhis2.angular.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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') {
Expand Down
3 changes: 2 additions & 1 deletion index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
<script src="vendor/jquery.calendars.package-1.2.1/jquery.calendars.plus.min.js"></script>
<script src="vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker.ext.js"></script>

<% const supportedCalendarLocales = ['ar', 'ar-EG', 'zn-CH', 'cs', 'da', 'nl', 'fr', 'km', 'lo', 'pt-BR', 'ro', 'ru', 'es', 'sv', 'uk', 'ur', 'vi']; %>
<!-- The following array should be manually kept in sync with the one in `CalendarService` -->
<% 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 => { %>
<script src="vendor/jquery.calendars.package-1.2.1/jquery.calendars-<%= locale %>.js"></script>
<script src="vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker-<%= locale %>.js"></script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Norwegian localisation for Gregorian/Julian calendars for jQuery.
Written by Naimdjon Takhirov ([email protected]). */
(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',
Expand All @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Norwegian localisation for calendars datepicker for jQuery.
Written by Naimdjon Takhirov ([email protected]). */
(function($) {
$.calendars.picker.regional['no'] = {
$.calendars.picker.regional['nb'] = {
renderer: $.calendars.picker.defaultRenderer,
prevText: '&laquo;Forrige', prevStatus: '',
prevJumpText: '&#x3c;&#x3c;', prevJumpStatus: '',
Expand All @@ -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);

0 comments on commit bb81315

Please sign in to comment.