Skip to content

Commit

Permalink
feat: [DHIS2-14597] add translations in calendar picker (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
superskip authored Mar 6, 2023
1 parent 40d4a66 commit 57a42d2
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 2 deletions.
5 changes: 4 additions & 1 deletion d2-tracker/dhis2.angular.directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ){
Expand Down
5 changes: 4 additions & 1 deletion d2-tracker/dhis2.angular.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
6 changes: 6 additions & 0 deletions index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@
<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']; %>
<% 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>
<% }); %>

<script src="vendor/jquery.calendars.package-1.2.1/jquery.calendars.coptic.min.js"></script>
<script src="vendor/jquery.calendars.package-1.2.1/jquery.calendars.ethiopian.min.js"></script>
<script src="vendor/jquery.calendars.package-1.2.1/jquery.calendars.islamic.min.js"></script>
Expand Down
20 changes: 20 additions & 0 deletions vendor/jquery.calendars.package-1.2.1/jquery.calendars-lo.js
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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: "&lt;&lt;",
prevJumpStatus: "ສະແດງປີຜ່ານມາ",
nextText: "ຕໍ່ໄປ",
nextStatus: "ສະແດງເດືອນຕໍ່ໄປ",
nextJumpText: "&gt;&gt;",
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);

0 comments on commit 57a42d2

Please sign in to comment.