Search results

Globalization

Globalization is the combination of internationalization and localization. You can adapt the component to various languages by parsing and formatting the date or number (Internationalization, and also add culture specific customization and translation to the text (localization).

By default, the Calendar date format, week, and month names are specific to American English culture. It uses the Essential JavaScript 2 Internationalization package to parse and format date object based on the culture using the official UNICODE CLDR JSON data. It provides the loadCldr method to load the culture-specific CLDR JSON data.

The Calendar component supports only the Gregorian type of calendar. All the Essential JS 2 component are specific to English culture (‘en-US’). If you want to go with the different culture other than English, follow the below steps.

  • Install the CLDR-Data package by using the below command (installs the CLDR JSON data). To know more about CLDR data, refer to the CLDR-Data link.
npm install cldr-data --save

Once the package installed, you can find the culture specific JSON data under the location \node_modules\cldr-data.

  • Now, import the installed CLDR JSON data to the app.vue file. To import JSON data, install the JSON plugin loader. In the example, SystemJS JSON plugin loader is used.
npm install systemjs-plugin-json --save-dev
  • After it is installed, configure the system.config.js settings as given below to map the systemjs-plugin-json loader.
System.config({
    paths: {
        'npm:': './node_modules/',
        'syncfusion:': 'npm:@syncfusion/'

    },
    map: {
        app: 'app',

        //Syncfusion packages mapping
        "@syncfusion/ej2-base": "syncfusion:ej2-base/dist/ej2-base.umd.min.js",
        "@syncfusion/ej2-data": "syncfusion:ej2-data/dist/ej2-data.umd.min.js",
        "@syncfusion/ej2-inputs": "syncfusion:ej2-inputs/dist/ej2-inputs.umd.min.js",
        "@syncfusion/ej2-lists": "syncfusion:ej2-lists/dist/ej2-lists.umd.min.js",
        "@syncfusion/ej2-popups": "syncfusion:ej2-popups/dist/ej2-popups.umd.min.js",
        "@syncfusion/ej2-splitbuttons": "syncfusion:ej2-splitbuttons/dist/ej2-splitbuttons.umd.min.js",
        "@syncfusion/ej2-buttons": "syncfusion:ej2-buttons/dist/ej2-buttons.umd.min.js",
        "@syncfusion/ej2-calendars": "syncfusion:ej2-calendars/dist/ej2-calendars.umd.min.js",
        "@syncfusion/ej2-vue-base": "syncfusion:ej2-vue-base/dist/ej2-vue-base.umd.min.js",
        "@syncfusion/ej2-vue-calendars": "syncfusion:ej2-vue-calendars/dist/ej2-vue-calendars.umd.min.js",
        "cldr-data": 'npm:cldr-data',
        "plugin-json": "npm:systemjs-plugin-json/json.js"
    },
    meta: {
        '*.json': { loader: 'plugin-json' }
    },
    packages: {
        'app': { main: 'app', defaultExtension: 'js' },
        'cldr-data': { main: 'index.js', defaultExtension: 'js' }
    }
});

System.import('app');
  • Now use the loadCldr method to load the culture specific CLDR JSON data from the installed location to app.vue file as like the below code example.
//Load the loadCldr from ej2-base
import { loadCldr } from '@syncfusion/ej2-base';

declare var require: any;

loadCldr(
    require('cldr-data/main/de/ca-gregorian.json'),
    require('cldr-data/main/de/numbers.json'),
    require('cldr-data/main/de/timeZoneNames.json')
    );

The Localization library allows you to localize default text content of the Calendar. The Calendar component has static text for today feature that can be changed to other cultures (Arabic, Deutsch, French, etc.) by defining the locale value and translation object.

Locale keywords Text
today Name of the button to choose Today date.
  • Before changing the culture other than English, ensure that locale text for the concerned culture is loaded through load method of L10n class.
//Load the L10n from ej2-base
import { L10n } from '@syncfusion/ej2-base';

//load the locale object to set the localized today value
L10n.load({
    'de': {
        'calendar': { today: 'heute' }
    }
});
  • Set the culture by using the locale property.

The following example demonstrates the Calendar in German culture

Source
Preview
app.vue
<template>
  <div id="app">
        <div class='wrap'>
           <ejs-calendar id='calendar' locale='de'></ejs-calendar>
        </div>
  </div>
</template>
<script>
import Vue from "vue";
import { loadCldr, L10n } from '@syncfusion/ej2-base';
import { CalendarPlugin } from "@syncfusion/ej2-vue-calendars";
import * as numberingSystems from './numberingSystems.json';
import * as gregorian from './ca-gregorian.json';
import * as numbers from './numbers.json';
import * as timeZoneNames from './timeZoneNames.json';

Vue.use(CalendarPlugin);
loadCldr(numberingSystems, gregorian, numbers, timeZoneNames);

L10n.load({
    'de': {
      'calendar': { today: 'heute'}
    }
});
export default {}
</script>

<style>
  @import "../node_modules/@syncfusion/ej2-base/styles/material.css";
  @import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
  @import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material.css";
 .wrap {
    margin: 0px auto;
    width: 240px;
}
</style>

Right-to-Left

The Calendar supports right-to-left functionality for languages like Arabic, Hebrew, etc. To display text in the right-to-left direction, use enableRtl property.

The following code example initializes the Calendar component in Arabic culture.

Source
Preview
app.vue
<template>
  <div id="app">
        <div class='wrap'>
           <ejs-calendar id='calendar' locale='ar' enableRtl='true'></ejs-calendar>
        </div>
  </div>
</template>
<script>
import Vue from "vue";
import { loadCldr, L10n } from '@syncfusion/ej2-base';
import { CalendarPlugin } from "@syncfusion/ej2-vue-calendars";
import * as numberingSystems from './numberingSystems.json';
import * as gregorian from './ca-gregorian.json';
import * as numbers from './numbers.json';
import * as timeZoneNames from './timeZoneNames.json';

Vue.use(CalendarPlugin);
loadCldr(numberingSystems, gregorian, numbers, timeZoneNames);

L10n.load({
    'ar': {
      'calendar': {  today: "اليوم"}
    }
});
export default {}
</script>

<style>
  @import "../node_modules/@syncfusion/ej2-base/styles/material.css";
  @import "../node_modules/@syncfusion/ej2-buttons/styles/material.css";
  @import "../node_modules/@syncfusion/ej2-vue-calendars/styles/material.css";
 .wrap {
    margin: 0px auto;
    width: 240px;
}
</style>