mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 07:09:20 +01:00
Et2Date: Add localization
This commit is contained in:
parent
36f41a9470
commit
63b2755dbf
@ -17,6 +17,11 @@ import {dateStyles} from "./DateStyles";
|
||||
import {LitFlatpickr} from "lit-flatpickr";
|
||||
import "flatpickr/dist/plugins/scrollPlugin.js";
|
||||
|
||||
import(egw.webserverUrl + "/node_modules/flatpickr/dist/l10n/" + (egw.preference('lang') + ".js")).then(() =>
|
||||
{
|
||||
// @ts-ignore
|
||||
flatpickr.localize(flatpickr.l10ns[egw.preference('lang')]);
|
||||
});
|
||||
|
||||
/**
|
||||
* Parse a date string into a Date object
|
||||
@ -369,6 +374,8 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(ValidateMixin(LitFl
|
||||
options.dateFormat = "Y-m-dT00:00:00\\Z";
|
||||
options.weekNumbers = true;
|
||||
|
||||
this._localize(options);
|
||||
|
||||
if(this.inline)
|
||||
{
|
||||
options.inline = this.inline;
|
||||
@ -384,6 +391,20 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(ValidateMixin(LitFl
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set localize options & translations
|
||||
* @param options
|
||||
* @protected
|
||||
*/
|
||||
protected _localize(options)
|
||||
{
|
||||
let first_dow = this.egw().preference('weekdaystarts', 'calendar') || 'Monday';
|
||||
const DOW_MAP = {Monday: 1, Sunday: 0, Saturday: 6};
|
||||
options.locale = {
|
||||
firstDayOfWeek: DOW_MAP[first_dow]
|
||||
};
|
||||
}
|
||||
|
||||
set_value(value)
|
||||
{
|
||||
if(!value || value == 0 || value == "0")
|
||||
|
Loading…
Reference in New Issue
Block a user