How can I set ine datePicker in french ?

Dear Support, I have read the documentation : https://ej2.syncfusion.com/vue/documentation/datetimepicker/globalization/


I have 3 questions about it : 


1/ I don't know how to do the same in french.


Is there some special json file needed ?

3/ Moreover, I can I prevent the user from writting a date (or anything else) by himself in the input part of the datepicker ?


I would like to user to be only able to select a date from the datePicker calendar, not to write something on his own.

3/ I would like to force the format to be "yyyy-mm-dd". 

I wrote this : 


data: () => {
return {
form: {
id:null,
date: null,
},
// Form validator
formObj: "",
options: {
customPlacement: function (inputelement, errorElement) {
var parentElement = inputelement.closest(".error-element");
parentElement.appendChild(errorElement);
},
rules: {
dateUpdate: {
date : '2000-01-01'
}


But when I type "01/01/2021" and submit it I have no validator mystake.
What did I do wrong ? 

best regards


5 Replies

BC Berly Christopher Syncfusion Team July 13, 2021 02:07 PM UTC

Hi Sandra, 
  
Greetings from Syncfusion support. 
  
Query 1: 
  
1/ I don't know how to do the same in french. 
Is there some special json file needed? 
  
Response: 
  
Yes, we need to load the required cldr-data files such as “ca-gregorian.json, numbers.json, timeZoneNames.json, numberingSystems.json” with help of loadCldr method. Kindly refer the below code example. 
  
<template> 
  <div class="control_wrapper"> 
    <ejs-datepicker id="datepicker" locale="fr"></ejs-datepicker> 
  </div> 
</template> 
<script> 
import Vue from "vue"; 
import { DatePickerPlugin } from "@syncfusion/ej2-vue-calendars"; 
import { L10n , loadCldrfrom "@syncfusion/ej2-base"; 
Vue.use(DatePickerPlugin); 
loadCldr( 
    require('cldr-data/main/fr/numbers.json'), 
    require('cldr-data/main/fr/ca-gregorian.json'), 
    require('cldr-data/main/fr/numbers.json'), 
    require('cldr-data/main/fr/timeZoneNames.json'), 
    require('cldr-data/supplemental/weekdata.json'// To load the culture based first day of week 
); 
L10n.load({ 
  fr: { 
    datepicker: { 
     "today": "Aujourd'hui", 
      "placeholder": "Choisissez une date" 
    } 
  } 
}); 
export default Vue.extend({ 
  data: function() { 
    return {}; 
  } 
}); 
</script> 
 
  
Screenshot: 
 
  
If you want to get the CLDR-data for other culture means, we need to install CLDR-data with help of “npm install cldr-data --save” as mentioned in the below documentation. After run this command the above mentioned culture files will be download under the node_modules/cldr-data folder.  
  
  
Query 2: 
  
Moreover, I can I prevent the user from writting a date (or anything else) by himself in the input part of the datepicker ? 
I would like to user to be only able to select a date from the datePicker calendar, not to write something on his own. 
  
Response: 
  
We can achieve the requested requirement by using the “allowEdit” property as false in the DatePicker component which prevents the user to enter the value in the input.  
  
  
  <ejs-datepicker id="datepicker" :allowEdit=allowEdit locale="fr"></ejs-datepicker> 
export default Vue.extend({ 
  data: function() { 
    return { 
      allowEdit:false 
    }; 
  } 
}); 
 
  
Query 3: 
  
I would like to force the format to be "yyyy-mm-dd".  
  
Response: 
  
By default, the DatePicker will be displayed the date value in the en-US format. If we load any culture, then DatePicker will be displayed the date value in the loaded culture’s format. If you want to display the date value in own custom format, then we suggest you to define the own format in the format property.  
  
    <ejs-datepicker id="datepicker" :allowEdit=allowEdit locale="fr" format="yyyy-mm-dd"></ejs-datepicker> 
 
  
For your reference, we have prepared the sample and attached it below. 
  
Query 4: 
  
But when I type "01/01/2021" and submit it I have no validator mystake.
What did I do wrong ? 
 
  
Response: 
  
As per the above requested details, you want to prevent the user to type in the input of the DatePicker component. If we done this, we could not enter the value against the date format in the component. If you want the user to enter the provided format alone in the DatePicker means, we can achieve this by using mask support. Kindly refer the below demo and documentation to know more about this support. 
  
  
  
Regards, 
Berly B.C 



SB Sandra Bordier July 13, 2021 08:03 PM UTC

Thank you for the answer.

I tried to do it as you said, but got the error "

calendar.js?9f52:284 Uncaught TypeError: Cannot convert undefined or null to object

    at Function.keys (<anonymous>)

    at DatePicker.CalendarBase.getCultureValues (calendar.js?9f52:284)

    at DatePicker.CalendarBase.createContentHeader (calendar.js?9f52:320)

    at DatePicker.CalendarBase.createContent (calendar.js?9f52:268)

    at DatePicker.Calendar.createContent (calendar.js?9f52:2230)

    at DatePicker.CalendarBase.render (calendar.js?9f52:140)

    at DatePicker.Calendar.render (calendar.js?9f52:2086)

    at DatePicker.show (datepicker.js?dd17:1149)

    at VueComponent.DatePickerComponent.show (datepicker.component.js?26d8:116)

    at VueComponent.onFocus (Create.vue?edf9:187)"


Can you help me ? Here is the zip file.


Attachment: create_c6f44d89.zip


BC Berly Christopher Syncfusion Team July 14, 2021 10:01 AM UTC

Hi Sandra, 
  
We have checked the reported issue and this issue caused due to the CLDR-data specified in the application is not loaded on component rendering. So, we suggest you to ensure that CLDR-data installed inside the node_modules folder. Else, we suggest you to install the CLDR-data with help of “npm install cldr-data --save” else, please make use of the below attached CDLR-data files under your node_modules folder. 
  
  
Regards, 
Berly B.C 



SB Sandra Bordier July 15, 2021 09:37 PM UTC

I did npm install cldr-data --save


I can see it in my package JSON file : 

"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.3",
"@fortawesome/fontawesome-svg-core": "^1.2.35",
"@fortawesome/free-solid-svg-icons": "^5.15.3",
"@fortawesome/vue-fontawesome": "^2.0.2",
"@syncfusion/ej2-buttons": "^18.4.33",
"@syncfusion/ej2-vue-base": "^18.4.30",
"@syncfusion/ej2-vue-buttons": "^18.4.33",
"@syncfusion/ej2-vue-calendars": "^19.1.66",
"@syncfusion/ej2-vue-dropdowns": "^18.4.49",
"@syncfusion/ej2-vue-grids": "^18.4.49",
"@syncfusion/ej2-vue-inputs": "^18.4.33",
"@syncfusion/ej2-vue-navigations": "^18.4.47",
"@syncfusion/ej2-vue-notifications": "^19.1.63",
"@syncfusion/ej2-vue-popups": "^18.4.30",
"@syncfusion/ej2-vue-schedule": "^18.4.42",
"@syncfusion/ej2-vue-splitbuttons": "^18.4.31",
"@syncfusion/ej2-vue-treegrid": "^18.4.33",
"cldr-data": "^36.0.0",
"epic-spinners": "^1.1.0",
"moment": "^2.29.1",
"vue-router": "^3.5.2",
"vuex": "^3.6.2",
"vuex-persist": "^3.1.3"



So I need to get cldr-data in the package.json file and in the node module folder ? Do you mean I have to put your cldr-data folder in here ? : 


capture

Because as you can see, I have to nodes_modules folder at different places.



DR Deepak Ramakrishnan Syncfusion Team July 16, 2021 11:57 AM UTC

Hi Sandra,  
  
  We suspect there may be duplicate packages installed in your application while upgrading. Please follow the steps in the below documentation and ensure whether the same issue still exists in your end also with the above requested information.   
  
  
  
Regards,  
Deepak Ramakrishnan.  


Loader.
Up arrow icon