Localization is not working in schedule component.

I followed the globalization guide below.

https://ej2.syncfusion.com/vue/documentation/schedule/localization


<!-- my source -->
<template>
  <div>
    <ejs-schedule height='700px' width='100%' :selectedDate="selectedDate" :eventSettings="eventSettings"
      :allowInline="true" :locale="ko">
      <e-views>
        <e-view option='TimelineYear'></e-view>
      </e-views>
    </ejs-schedule>
  </div>
</template>

<script setup>
import { ref, onMounted, provide, inject } from 'vue';
import { ScheduleComponent as EjsSchedule, ViewDirective as EView, ViewsDirective as EViews, TimelineYear } from '@syncfusion/ej2-vue-schedule';
provide('schedule', [TimelineYear]);

const selectedDate = new Date();
const eventSettings = { dataSource: [] };
</script>

<style scoped>
</style>


The following error occurs:

[WARNING] :: Module "Week" is not available in Schedule component! You either misspelled the module name or forgot to load it.
[Vue warn]: Unhandled error during execution of mounted hook
  at <ScheduleComponent height="700px" width="100%" selectedDate= Mon Sep 30 2024 14:32:38 GMT+0900 (한국 표준시) ... >
  at <InvHoliday onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy(Object) {__v_skip: true} > >
  at <KeepAlive include= (2) ['inv-holiday', 'home-page'] >
  at <RouterView>
  at <BaseSidebar position="Left" >
  at <BaseLayout>
  at <App>
Uncaught TypeError TypeError: Cannot convert undefined or null to object
    at Schedule2.getDayNames (e:\Dev\Vue\kalpa.signal.vue\node_modules\@syncfusion\ej2-vue-schedule\node_modules\@syncfusion\ej2-schedule\src\schedule\base\schedule.js:526:38)
    at TimelineYear2.renderHeader (e:\Dev\Vue\kalpa.signal.vue\node_modules\@syncfusion\ej2-vue-schedule\node_modules\@syncfusion\ej2-schedule\src\schedule\renderer\timeline-year.js:76:68)
    at Year2.renderLayout (e:\Dev\Vue\kalpa.signal.vue\node_modules\@syncfusion\ej2-vue-schedule\node_modules\@syncfusion\ej2-schedule\src\schedule\renderer\year.js:53:14)
    at Render2.initializeLayout (e:\Dev\Vue\kalpa.signal.vue\node_modules\@syncfusion\ej2-vue-schedule\node_modules\@syncfusion\ej2-schedule\src\schedule\renderer\renderer.js:125:32)
    at Render2.initializeLayout (e:\Dev\Vue\kalpa.signal.vue\node_modules\@syncfusion\ej2-vue-schedule\node_modules\@syncfusion\ej2-schedule\src\schedule\renderer\renderer.js:94:29)
    at Render2.render (e:\Dev\Vue\kalpa.signal.vue\node_modules\@syncfusion\ej2-vue-schedule\node_modules\@syncfusion\ej2-schedule\src\schedule\renderer\renderer.js:14:14)
    at Schedule2.initializeView (e:\Dev\Vue\kalpa.signal.vue\node_modules\@syncfusion\ej2-vue-schedule\node_modules\@syncfusion\ej2-schedule\src\schedule\base\schedule.js:480:27)
    at Schedule2.renderElements (e:\Dev\Vue\kalpa.signal.vue\node_modules\@syncfusion\ej2-vue-schedule\node_modules\@syncfusion\ej2-schedule\src\schedule\base\schedule.js:266:14)
    at Schedule2.initializeResources (e:\Dev\Vue\kalpa.signal.vue\node_modules\@syncfusion\ej2-vue-schedule\node_modules\@syncfusion\ej2-schedule\src\schedule\base\schedule.js:234:18)
    at Schedule2.render (e:\Dev\Vue\kalpa.signal.vue\node_modules\@syncfusion\ej2-vue-schedule\node_modules\@syncfusion\ej2-schedule\src\schedule\base\schedule.js:136:14)

5 Replies

AK Ashokkumar Karuppasamy Syncfusion Team October 2, 2024 06:50 AM UTC

Hi ThreeGo,

We suspect that the locale is not properly prepared. Therefore, we have created a sample in Vue Schedule using the 'ko' locale. The attached code snippet and the following example demonstrate the solution. Please give it a try, and feel free to reach out if you need further assistance.

We require the below files to localize the Schedule.

  • ca-gregorian.json
  • numbers.json
  • timeZoneNames.json
  • numberingSystems.json


Example:

1. You can get the above files by Installing the CLDR-Data package by using the below command.

>> npm install cldr-data –save


Once the installation is completed you can find the files required to localize the Schedule for each culture from the directory as shown below.



You can get ca-gregorian.jsonnumbers.json, and timeZoneNames.json files from the directory as shown below.



You can get the numberingSystems.json file from the directory as shown below. This file is common for all cultures.



"2. Import the required CLDR data files (ca-gregorian.json, numberingSystems.json, numbers.json, and timeZoneNames.json) and load them using the loadCldr method. You can find the culture files in our shared sample, as shown in the below snippet. These files are copied from the CLDR-Data package installed in step 1."


[app.vue]


[locale. Json]



3. Load the locale words as shown below using the load method of L10n. You can find the localized word for the different cultures from the below repository.

ej2-local: https://github.com/syncfusion/ej2-locale

The attached code snippet and the following example demonstrate the solution. Please give it a try, and feel free to reach out if you need further assistance.

Sample: schedule-locale-ko-sample (forked) - StackBlitz

Regards,
Ashok 



TH ThreeGo October 2, 2024 11:19 AM UTC

I first used cldr-data in app.vue like this:

import { setCulture, setCurrencyCode, L10n, Ajax, loadCldr } from '@syncfusion/ej2-base';

import * as numberingSystems from 'cldr-data/supplemental/numberingSystems.json';

import * as gregorian from 'cldr-data/main/ko/ca-gregorian.json';

import * as numbers from 'cldr-data/main/ko/numbers.json';

import * as timeZoneNames from 'cldr-data/main/ko/timeZoneNames.json';

import * as weekData from 'cldr-data/supplemental/weekdata.json';

 loadCldr(gregorian, timeZoneNames, numbersnumberingSystems, weekData);


After that I changed it by looking at the following guide.

https://ej2.syncfusion.com/vue/documentation/common/internationalization

import { setCulture, setCurrencyCode, L10n, Ajax, loadCldr } from '@syncfusion/ej2-base';

  import koGregorian from '@syncfusion/ej2-cldr-data/main/ko/ca-gregorian.json';

  import koTimeZoneData from '@syncfusion/ej2-cldr-data/main/ko/timeZoneNames.json';

  import koNumberData from '@syncfusion/ej2-cldr-data/main/ko/numbers.json';

  import koCurrencies from '@syncfusion/ej2-cldr-data/main/en/currencies.json';

  import koNumberingSystem from '@syncfusion/ej2-cldr-data/supplemental/numberingSystems.json';

  import weekData from '@syncfusion/ej2-cldr-data/supplemental/weekData.json';


  loadCldr(koGregorian, koTimeZoneData, koNumberData, koCurrencies, koNumberingSystem, weekData);


It works fine in datepicker.


I have some questions.


1.Is it okay to set this only once in app.vue?

2.Should I use the file from cldr-data instead of @syncfusion/ej2-cldr-data?



TH ThreeGo October 3, 2024 07:12 AM UTC

I followed the example you sent and it still doesn't work.

To verify that the cldr data is loaded, I did the following:


<ejs-schedule @actionBegin="actionBegin">

import { cldrData } from '@syncfusion/ej2-base';

const actionBegin = () => {

  console.log(cldrData);

}

Image_1130_1727939561232

It was confirmed to be loaded properly.

However, in the method where the error occurs, the cldr data is not loaded.

<schedule.js>

import { EventHandler, Browser, Internationalization, getDefaultDateObject, cldrData, L10n } from '@syncfusion/ej2-base';

Schedule.prototype.getDayNames = function (type) {

        var culShortNames = [];

        var cldrObj;

        var nameSpace = '';

        if (isNullOrUndefined(this.locale) || this.locale === 'en' || this.locale === 'en-US') {

            nameSpace = 'days.stand-alone.';

            cldrObj = (getValue(nameSpace + type, getDefaultDateObject(this.getCalendarMode())));

        }

        else {

            nameSpace = 'main.' + '' + this.locale + '.dates.calendars.' + this.getCalendarMode() + '.days.format.' + type;

            cldrObj = (getValue(nameSpace, cldrData));

        }

        for (var _i = 0, _a = Object.keys(cldrObj); _i < _a.length; _i++) {

            var obj = _a[_i];

            culShortNames.push(getValue(obj, cldrObj));

        }

        return culShortNames;

    };


Even though the getDayNames method occurs later than actionBegin, there is no data in cldrData.

I really don't know the cause. Do you have any guesses?




TH ThreeGo October 3, 2024 10:34 AM UTC

I found the cause of the error. 

I checked package.json and found that I had not added "@syncfusion/ej2-base". 

It is really absurd, but it would be good to check it when there is a similar query. 

I apologize for wasting your time. 

Thank you for your support.



VR Vijay Ravi Syncfusion Team October 4, 2024 04:38 AM UTC

Hi ThreeGo

No problem, ThreeGo. We are glad to know that  your issue has been resolved. Please get back to us if you need any other assistance.


Regards,

Vijay

Loader.
Up arrow icon