Skip to content

Commit

Permalink
Finally, fix the Greek language.
Browse files Browse the repository at this point in the history
There are two issues here.  First, the Greek language was added
recently, but a date/time format for the datepicker javascript was not
added.  Second, the flatpickr library incorrectly names the locale `gr`
instead of `el`.  So that has to be worked around.
  • Loading branch information
drgrice1 committed Nov 21, 2023
1 parent 04dbc2e commit 8484570
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 27 deletions.
15 changes: 10 additions & 5 deletions htdocs/js/DatePicker/datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'en-US': 'L/d/yy, h:mm a',
'cs-CZ': 'dd.LL.yy H:mm',
de: 'dd.LL.yy, HH:mm',
el: 'd/L/yy, h:mm a',
es: 'd/L/yy, H:mm',
'fr-CA': "yyyy-LL-dd HH 'h' mm",
fr: 'dd/LL/yyyy HH:mm',
Expand Down Expand Up @@ -65,7 +66,10 @@
ariaDateFormat: datetimeFormats[luxon.Settings.defaultLocale],
defaultDate: orig_value,
defaultHour: 0,
locale: rule.dataset.locale ? rule.dataset.locale.substring(0, 2) : 'en',
locale:
luxon.Settings.defaultLocale.substring(0, 2) === 'el'
? 'gr'
: luxon.Settings.defaultLocale.substring(0, 2),
clickOpens: false,
disableMobile: true,
wrap: true,
Expand All @@ -87,8 +91,8 @@
const today = new Date();
// If there isn't a selected date, then use 12:00 am on the current date.
const selectedDate = fp.selectedDates[0] ?? new Date(new Date().toDateString());
selectedDate.setFullYear(today.getFullYear())
selectedDate.setMonth(today.getMonth())
selectedDate.setFullYear(today.getFullYear());
selectedDate.setMonth(today.getMonth());
selectedDate.setDate(today.getDate());
fp.setDate(selectedDate);
} else if (index === 1) {
Expand Down Expand Up @@ -136,8 +140,9 @@
// timezone of the course.
if (format === 'U') return (date.getTime() + timezoneAdjustment) / 1000;

return luxon.DateTime.fromMillis(date.getTime())
.toFormat(datetimeFormats[luxon.Settings.defaultLocale]);
return luxon.DateTime.fromMillis(date.getTime()).toFormat(
datetimeFormats[luxon.Settings.defaultLocale]
);
}
});

Expand Down
15 changes: 10 additions & 5 deletions htdocs/js/ProblemSetList/problemsetlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
'en-US': 'L/d/yy, h:mm a',
'cs-CZ': 'dd.LL.yy H:mm',
de: 'dd.LL.yy, HH:mm',
el: 'd/L/yy, h:mm a',
es: 'd/L/yy, H:mm',
'fr-CA': "yyyy-LL-dd HH 'h' mm",
fr: 'dd/LL/yyyy HH:mm',
Expand Down Expand Up @@ -85,7 +86,10 @@
altFormat: datetimeFormats[luxon.Settings.defaultLocale],
ariaDateFormat: datetimeFormats[luxon.Settings.defaultLocale],
defaultHour: 0,
locale: importDateShift.dataset.locale ? importDateShift.dataset.locale.substring(0, 2) : 'en',
locale:
luxon.Settings.defaultLocale.substring(0, 2) === 'el'
? 'gr'
: luxon.Settings.defaultLocale.substring(0, 2),
clickOpens: false,
disableMobile: true,
wrap: true,
Expand All @@ -107,8 +111,8 @@
const today = new Date();
// If there isn't a selected date, then use 12:00 am on the current date.
const selectedDate = fp.selectedDates[0] ?? new Date(new Date().toDateString());
selectedDate.setFullYear(today.getFullYear())
selectedDate.setMonth(today.getMonth())
selectedDate.setFullYear(today.getFullYear());
selectedDate.setMonth(today.getMonth());
selectedDate.setDate(today.getDate());
fp.setDate(selectedDate);
} else if (index === 1) {
Expand Down Expand Up @@ -149,8 +153,9 @@
// timezone of the course.
if (format === 'U') return (date.getTime() + timezoneAdjustment) / 1000;

return luxon.DateTime.fromMillis(date.getTime())
.toFormat(datetimeFormats[luxon.Settings.defaultLocale]);
return luxon.DateTime.fromMillis(date.getTime()).toFormat(
datetimeFormats[luxon.Settings.defaultLocale]
);
}
});

Expand Down
19 changes: 11 additions & 8 deletions templates/ContentGenerator/Base/set_status.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
% && $set->reduced_scoring_date
% && $set->reduced_scoring_date != $set->due_date
% );
%
%
<div class="alert alert-info mb-3">
<%== $useReducedScoring ? '<p>' : '<p class="mb-0">' =%>
<%== $useReducedScoring ? '<p>' : '<p class="mb-0">' =%>
<strong>
% if (before($set->open_date)) {
<%= maketext('Set opens on [_1].', $c->formatDateTime($set->open_date)) %>
<%= maketext('Set opens on [_1].',
$c->formatDateTime($set->open_date, undef, $ce->{studentDateDisplayFormat})) %>
% } elsif ($useReducedScoring && before($set->reduced_scoring_date)) {
<%= maketext('Set is due on [_1].', $c->formatDateTime($set->reduced_scoring_date)) %>
<%= maketext('Set is due on [_1].',
$c->formatDateTime($set->reduced_scoring_date, undef, $ce->{studentDateDisplayFormat})) %>
% } elsif (before($set->due_date)) {
<%= maketext('Set closes on [_1].', $c->formatDateTime($set->due_date)) %>
<%= maketext('Set closes on [_1].',
$c->formatDateTime($set->due_date, undef, $ce->{studentDateDisplayFormat})) %>
% } else {
<%= maketext('Set is closed.') %>
% }
Expand All @@ -31,7 +34,7 @@
<%= maketext(
'After the due date this set enters a reduced scoring period until it closes on [_1]. All work '
. 'completed during the reduced scoring period counts for [_2]% of its value.',
$c->formatDateTime($set->due_date), $reducedScoringPerCent
$c->formatDateTime($set->due_date, undef, $ce->{studentDateDisplayFormat}), $reducedScoringPerCent
) =%>
% } elsif (between($reduced_scoring_date, $set->due_date)) {
<%= maketext(
Expand All @@ -42,8 +45,8 @@
<%= maketext(
'This set had a reduced scoring period that started on [_1] and ended on [_2]. '
. 'During that period all work counted for [_3]% of its value.',
$c->formatDateTime($reduced_scoring_date),
$c->formatDateTime($set->due_date),
$c->formatDateTime($reduced_scoring_date, undef, $ce->{studentDateDisplayFormat}),
$c->formatDateTime($set->due_date, undef, $ce->{studentDateDisplayFormat}),
$reducedScoringPerCent
) =%>
% }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
<%= javascript getAssetURL($ce, 'node_modules/luxon/build/global/luxon.min.js'), defer => undef =%>
<%= javascript getAssetURL($ce, 'node_modules/flatpickr/dist/flatpickr.min.js'), defer => undef =%>
% if ($ce->{language} !~ /^en/) {
<%= javascript
getAssetURL($ce, 'node_modules/flatpickr/dist/l10n/' . ($ce->{language} =~ s/^(..).*/$1/gr) . '.js'),
defer => undef =%>
<%= javascript getAssetURL(
$ce,
'node_modules/flatpickr/dist/l10n/'
. ($ce->{language} =~ /^el/ ? 'gr' : ($ce->{language} =~ s/^(..).*/$1/gr))
. '.js'
), defer => undef =%>
% }
<%= javascript getAssetURL($ce, 'node_modules/flatpickr/dist/plugins/confirmDate/confirmDate.js'),
defer => undef =%>
Expand Down
9 changes: 6 additions & 3 deletions templates/ContentGenerator/Instructor/ProblemSetList.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
<%= javascript getAssetURL($ce, 'node_modules/luxon/build/global/luxon.min.js'), defer => undef =%>
<%= javascript getAssetURL($ce, 'node_modules/flatpickr/dist/flatpickr.min.js'), defer => undef =%>
% if ($ce->{language} !~ /^en/) {
<%= javascript
getAssetURL($ce, 'node_modules/flatpickr/dist/l10n/' . ($ce->{language} =~ s/^(..).*/$1/gr) . '.js'),
defer => undef =%>
<%= javascript getAssetURL(
$ce,
'node_modules/flatpickr/dist/l10n/'
. ($ce->{language} =~ /^el/ ? 'gr' : ($ce->{language} =~ s/^(..).*/$1/gr))
. '.js'
), defer => undef =%>
% }
<%= javascript getAssetURL($ce, 'node_modules/flatpickr/dist/plugins/confirmDate/confirmDate.js'),
defer => undef =%>
Expand Down
9 changes: 6 additions & 3 deletions templates/ContentGenerator/Instructor/UserDetail.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
<%= javascript getAssetURL($ce, 'node_modules/luxon/build/global/luxon.min.js'), defer => undef =%>
<%= javascript getAssetURL($ce, 'node_modules/flatpickr/dist/flatpickr.min.js'), defer => undef =%>
% if ($ce->{language} !~ /^en/) {
<%= javascript
getAssetURL($ce, 'node_modules/flatpickr/dist/l10n/' . ($ce->{language} =~ s/^(..).*/$1/gr) . '.js'),
defer => undef =%>
<%= javascript getAssetURL(
$ce,
'node_modules/flatpickr/dist/l10n/'
. ($ce->{language} =~ /^el/ ? 'gr' : ($ce->{language} =~ s/^(..).*/$1/gr))
. '.js'
), defer => undef =%>
% }
<%= javascript getAssetURL($ce, 'node_modules/flatpickr/dist/plugins/confirmDate/confirmDate.js'),
defer => undef =%>
Expand Down

0 comments on commit 8484570

Please sign in to comment.