diff --git a/pom.xml b/pom.xml
index 45805fa..ed2f84e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
org.vaadin.addons.flowingcode
year-month-calendar
- 4.2.2-SNAPSHOT
+ 4.3.0-SNAPSHOT
Year Month Calendar Add-on
Year Month Calendar Add-on for Vaadin Flow
diff --git a/src/main/java/com/flowingcode/addons/ycalendar/InlineDatePicker.java b/src/main/java/com/flowingcode/addons/ycalendar/InlineDatePicker.java
index 39bceb3..7ccb4f3 100644
--- a/src/main/java/com/flowingcode/addons/ycalendar/InlineDatePicker.java
+++ b/src/main/java/com/flowingcode/addons/ycalendar/InlineDatePicker.java
@@ -2,7 +2,7 @@
* #%L
* Year Month Calendar Add-on
* %%
- * Copyright (C) 2021 - 2023 Flowing Code
+ * Copyright (C) 2021 - 2024 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,10 +23,13 @@
import com.vaadin.flow.component.HasSize;
import com.vaadin.flow.component.HasTheme;
import com.vaadin.flow.component.Tag;
+import com.vaadin.flow.component.datepicker.DatePicker.DatePickerI18n;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.dependency.Uses;
import com.vaadin.flow.function.SerializableFunction;
+import com.vaadin.flow.internal.JsonSerializer;
import java.time.LocalDate;
+import java.util.Objects;
import java.util.Optional;
@SuppressWarnings("serial")
@@ -72,4 +75,14 @@ public boolean isWeekNumbersVisible() {
return getElement().getProperty("showWeekNumbers", false);
}
+ /**
+ * Sets the i18n object.
+ *
+ * @param i18n the {@code DatepickerI18n} object used to initialize i18n
+ */
+ public void setI18n(DatePickerI18n i18n) {
+ Objects.requireNonNull(i18n, "The I18N properties object should not be null");
+ getElement().setPropertyJson("i18n", JsonSerializer.toJson(i18n));
+ }
+
}
diff --git a/src/main/resources/META-INF/frontend/fc-inline-date-picker/fc-inline-date-picker.js b/src/main/resources/META-INF/frontend/fc-inline-date-picker/fc-inline-date-picker.js
index b392a31..4e91ad0 100644
--- a/src/main/resources/META-INF/frontend/fc-inline-date-picker/fc-inline-date-picker.js
+++ b/src/main/resources/META-INF/frontend/fc-inline-date-picker/fc-inline-date-picker.js
@@ -2,7 +2,7 @@
* #%L
* Year Month Calendar Add-on
* %%
- * Copyright (C) 2021 - 2023 Flowing Code
+ * Copyright (C) 2021 - 2024 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,8 +54,10 @@ export class InlineDatePicker extends LitElement {
this.displayDate = this.displayDate || new Date();
}
if (changedProperties.has('i18n') && this.i18n) {
- this.shadowRoot.querySelector("fc-year-month-field").i18n=this.i18n;
- this.shadowRoot.querySelector("fc-month-calendar").i18n=this.i18n;
+ [
+ this.shadowRoot.querySelector("fc-year-month-field"),
+ this.shadowRoot.querySelector("fc-month-calendar")
+ ].forEach(e=>{if (e) e.i18n=this.i18n;});
}
}
diff --git a/src/test/java/com/flowingcode/addons/ycalendar/InlineDatePickerDemo.java b/src/test/java/com/flowingcode/addons/ycalendar/InlineDatePickerDemo.java
index a7c3297..b604551 100644
--- a/src/test/java/com/flowingcode/addons/ycalendar/InlineDatePickerDemo.java
+++ b/src/test/java/com/flowingcode/addons/ycalendar/InlineDatePickerDemo.java
@@ -2,14 +2,14 @@
* #%L
* Year Month Calendar Add-on
* %%
- * Copyright (C) 2021 - 2023 Flowing Code
+ * Copyright (C) 2021 - 2024 Flowing Code
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -34,6 +34,9 @@ public class InlineDatePickerDemo extends Div {
public InlineDatePickerDemo() {
InlineDatePicker field = new InlineDatePicker();
+ // #if vaadin eq 0
+ add(new LocaleSelector(field::setI18n));
+ // #endif
field.addValueChangeListener(ev->{
Notification.show(Objects.toString(ev.getValue()));