From 57a42d23056262b5f1ec36f21eb9bb2142cfb672 Mon Sep 17 00:00:00 2001 From: Tony Valle <79843014+superskip@users.noreply.github.com> Date: Mon, 6 Mar 2023 14:16:40 +0100 Subject: [PATCH] feat: [DHIS2-14597] add translations in calendar picker (#1663) --- d2-tracker/dhis2.angular.directives.js | 5 ++- d2-tracker/dhis2.angular.services.js | 5 ++- index.ejs | 6 ++++ .../jquery.calendars-lo.js | 20 ++++++++++++ .../jquery.calendars.picker-lo.js | 32 +++++++++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 vendor/jquery.calendars.package-1.2.1/jquery.calendars-lo.js create mode 100644 vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker-lo.js diff --git a/d2-tracker/dhis2.angular.directives.js b/d2-tracker/dhis2.angular.directives.js index f6cc68aab..0e55da73a 100644 --- a/d2-tracker/dhis2.angular.directives.js +++ b/d2-tracker/dhis2.angular.directives.js @@ -426,9 +426,12 @@ var d2Directives = angular.module('d2Directives', []) dateFormat = 'dd-mm-yyyy'; } + const locale = calendarSetting.locale === 'en' ? '' : calendarSetting.locale; + $.calendars.picker.setDefaults($.calendars.picker.regional[locale]); + var minDate = $parse(attrs.minDate)(scope); var maxDate = $parse(attrs.maxDate)(scope); - var calendar = $.calendars.instance(calendarSetting.keyCalendar); + var calendar = $.calendars.instance(calendarSetting.keyCalendar, locale); var pickerClass = attrs.pickerClass; var initializeDatePicker = function( sDate, eDate ){ diff --git a/d2-tracker/dhis2.angular.services.js b/d2-tracker/dhis2.angular.services.js index a24b823af..006e6a51e 100644 --- a/d2-tracker/dhis2.angular.services.js +++ b/d2-tracker/dhis2.angular.services.js @@ -132,13 +132,16 @@ var d2Services = angular.module('d2Services', ['ngResource']) }) /* service for getting calendar setting */ -.service('CalendarService', function (storage, $rootScope) { +.service('CalendarService', function (storage, SessionStorageService, $rootScope) { return { getSetting: function () { var dhis2CalendarFormat = {keyDateFormat: 'yyyy-MM-dd', keyCalendar: 'gregorian', momentFormat: 'YYYY-MM-DD'}; var storedFormat = storage.get('SYSTEM_SETTING'); + var userSettings = SessionStorageService.get('USER_SETTING'); + + dhis2CalendarFormat.locale = userSettings.keyUiLocale.replace('_', '-'); if (angular.isObject(storedFormat) && storedFormat.keyDateFormat && storedFormat.keyCalendar) { if (storedFormat.keyCalendar === 'iso8601') { diff --git a/index.ejs b/index.ejs index 57ba86a84..618bb6b24 100644 --- a/index.ejs +++ b/index.ejs @@ -52,6 +52,12 @@ + <% const supportedCalendarLocales = ['ar', 'ar-EG', 'zn-CH', 'cs', 'da', 'nl', 'fr', 'km', 'lo', 'pt-BR', 'ro', 'ru', 'es', 'sv', 'uk', 'ur', 'vi']; %> + <% supportedCalendarLocales.forEach(locale => { %> + + + <% }); %> + diff --git a/vendor/jquery.calendars.package-1.2.1/jquery.calendars-lo.js b/vendor/jquery.calendars.package-1.2.1/jquery.calendars-lo.js new file mode 100644 index 000000000..ed96848d4 --- /dev/null +++ b/vendor/jquery.calendars.package-1.2.1/jquery.calendars-lo.js @@ -0,0 +1,20 @@ +/* http://keith-wood.name/calendars.html + Laos localisation for Gregorian/Julian calendars for jQuery. + Stuart. */ +(function ($) { + $.calendars.calendars.gregorian.prototype.regional["lo"] = { + name: "Gregorian", + epochs: ["BCE", "CE"], + monthNames: ["ເດືອນມັງກອນ", "ເດືອນກຸມພາ", "ເດືອນມີນາ", "ເດືອນເມສາ", "ເດືອນພຶດສະພາ", "ເດືອນມິຖຸນາ", "ເດືອນກໍລະກົດ", "ເດືອນສິງຫາ", "ເດືອນກັນຍາ", "ເດືອນຕຸລາ", "ເດືອນພະຈິກ", "ເດືອນທັນວາ"], + monthNamesShort: ["ມັງກອນ", "ກຸມພາ", "ມີນາ", "ເມສາ", "ພຶດສະພາ", "ມິຖຸນາ", "ກໍລະກົດ", "ສິງຫາ", "ກັນຍາ", "ຕຸລາ", "ພະຈິກ", "ທັນວາ"], + dayNames: ["ວັນອາທິດ", "ວັນຈັນ", "ວັນອັງຄານ", "ວັນພຸດ", "ວັນພະຫັດ", "ວັນສຸກ", "ວັນເສົາ"], + dayNamesShort: ["ທິດ", "ຈັນ", "ຄານ", "ພຸດ", "ພະຫັດ", "ສຸກ", "ເສົາ"], + dayNamesMin: ["ທ", "ຈ", "ຄ", "ພ", "ພຫ", "ສ", "ສ"], + dateFormat: "ວັນທີ/ເດືອນ/ປີ", + firstDay: 1, + isRTL: false + }; + if ($.calendars.calendars.julian) { + $.calendars.calendars.julian.prototype.regional["lo"] = $.calendars.calendars.gregorian.prototype.regional["lo"]; + } +})(jQuery); diff --git a/vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker-lo.js b/vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker-lo.js new file mode 100644 index 000000000..13d1ea03d --- /dev/null +++ b/vendor/jquery.calendars.package-1.2.1/jquery.calendars.picker-lo.js @@ -0,0 +1,32 @@ +/* http://keith-wood.name/calendars.html + Laos localisation for calendars datepicker for jQuery. + Stuart. */ +(function ($) { + $.calendars.picker.regional["lo"] = { + renderer: $.calendars.picker.defaultRenderer, + prevText: "ຜ່ານມາ", + prevStatus: "ສະແດງເດືອນຜ່ານມາ", + prevJumpText: "<<", + prevJumpStatus: "ສະແດງປີຜ່ານມາ", + nextText: "ຕໍ່ໄປ", + nextStatus: "ສະແດງເດືອນຕໍ່ໄປ", + nextJumpText: ">>", + nextJumpStatus: "ສະແດງປີຕໍ່ໄປ", + currentText: "ປະຈຸບັນ", + currentStatus: "ສະແດງເດືອນປະຈຸບັນ", + todayText: "ມື້ນີ້", + todayStatus: "ສະແດງເດືອນນີ້", + clearText: "ລຶບ", + clearStatus: "ລຶບວັນທີ່ທັ້ງໝົດ", + closeText: "ສຳເລັດ", + closeStatus: "ປິດຕົວເລືອກວັນທີ່", + yearStatus: "ປ່ຽນປີ", + monthStatus: "ປ່ຽນເດືອນ", + weekText: "ອາທິດ", + weekStatus: "ອາທິດຂອງປີ", + dayStatus: "ເລືອກ ວັນທີ່, ເດືອນ ວັນ, ປີ", + defaultStatus: "ເລືອກວັນທີ່", + isRTL: false + }; + $.calendars.picker.setDefaults($.calendars.picker.regional["lo"]); +})(jQuery);