Skip to content

Commit

Permalink
Merge pull request #600 from niccokunzmann/set_locale
Browse files Browse the repository at this point in the history
Test setting of the calendar locale
  • Loading branch information
niccokunzmann authored Jan 20, 2025
2 parents 24d0190 + 1034d4c commit c738b5a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
12 changes: 12 additions & 0 deletions open_web_calendar/features/language.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,15 @@ Feature: The calendar is translated into different languages. We want to
| calendrier | French |
| Kalender | Deutsch |
| calendarios | Español |

Scenario Outline: When I set the language parameter, the calendar changes its language.
Given we add the calendar "event-with-html-markup"
And we set the "language" parameter to "<language>"
When we look at 2024-04-14
Then we can see the text "<word>"

Examples:
| word | language |
| MONTH | en |
| MONAT | de |
| ДЕНЬ | ru |
16 changes: 5 additions & 11 deletions open_web_calendar/static/js/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,6 @@ var template = {
}
}

/* The files use a Scheduler variable.
* scheduler.locale is used to load the locale.
* This creates the required interface.
*/
const setLocale = function(){};
const Scheduler = {plugin:function(setLocale_){
// this is called by the locale_??.js files.
setLocale = setLocale_;
}};

function showError(element) {
var icon = document.getElementById("errorStatusIcon");
icon.classList.add("onError");
Expand Down Expand Up @@ -269,7 +259,11 @@ function loadCalendar() {
*/
scheduler.config.hour_date = specification["hour_format"];
var format = scheduler.date.date_to_str(scheduler.config.hour_date);
setLocale(scheduler);

// set the locale
// loaded from /locale_<lang>.js
// see also https://docs.dhtmlx.com/scheduler/api__scheduler_locale_other.html
scheduler.i18n.setLocale(OWCLocale);
// load plugins, see https://docs.dhtmlx.com/scheduler/migration_from_older_version.html#5360
scheduler.plugins({
agenda_view: true,
Expand Down
4 changes: 1 addition & 3 deletions open_web_calendar/templates/locale.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
// SPDX-License-Identifier: CC-BY-SA-4.0
/* Generated locale from the calendar sources. */

Scheduler.plugin(function(e){
e.locale = {{ locale }};
});
const OWCLocale = {{ locale }};

0 comments on commit c738b5a

Please sign in to comment.