Giter VIP home page Giter VIP logo

syncfusionexamples / angular-scheduler-globalization-and-localization Goto Github PK

View Code? Open in Web Editor NEW
0.0 5.0 0.0 58 KB

A quick start Angular project that helps you to create an Angular Scheduler that works globally to meet the diverse needs of users from different cultures and regions. You will also learn how to localize the static text on the Angular Scheduler UI.

JavaScript 15.20% TypeScript 71.42% HTML 12.54% CSS 0.84%
globalization globalization-and-localization globalize localization localize cldr-data cldr internationalization localizable angular angular8 angular7 angular-cli scheduler event-calendar angular-scheduler angular-calendar essentialjs2 typescript cultures

angular-scheduler-globalization-and-localization's Introduction

Angular Scheduler - Globalization and Localization

A quick start Angular project that helps you to create an Angular Scheduler that works globally to meet the diverse needs of users from different cultures and regions. You will also learn how to localize the static text on the Angular Scheduler UI.

Project pre-requisites

Make sure that you have the compatible versions of TypeScript and Angular in your machine before starting to work on this project.

  • Angular 4+
  • TypeScript 2.6+

How to run this application?

To run this application, you need to first clone the angular-scheduler-globalization-and-localization repository and then navigate to its appropriate path where it has been located in your system.

To do so, open the command prompt and run the below commands one after the other.

git clone https://github.com/SyncfusionSamples/angular-scheduler-globalization-and-localization scheduler-example
cd scheduler-example

Installing

Once done with downloading, next you need to install the necessary packages required to run this application locally. The npm install command will install all the needed angular packages into your current project and to do so, run the below command.

npm install

Globalization and Localization

Although the above npm install command will pre-configure the project with all the necessary settings to work with globalization and localization concept, please find the actual steps followed to globalize the Scheduler.

Globalization

  1. To globalize the date and time formats in Scheduler, install the cldr-data package using the command,
npm install cldr-data --save
  1. Once the installation is done, import loadCldr function from @syncfusion/ej2-base package within the app.component.ts file.
import { loadCldr } from '@syncfusion/ej2-base';

Next, you need to load the related cldr data files of the required cultures within the app.component.ts file using the loadCldr function, to use the cultures other than en-US. In the below code example, I've included the cldr data files of fr-CH culture.

declare var require: any;

loadCldr(
    require('cldr-data/supplemental/numberingSystems.json'),
    require('cldr-data/main/fr-CH/ca-gregorian.json'),
    require('cldr-data/main/fr-CH/numbers.json'),
    require('cldr-data/main/fr-CH/timeZoneNames.json'));
  1. Now, you can set the locale property to Scheduler and assign the required culture code fr-CH to it.
  <ejs-schedule 
  [eventSettings]="eventObject"
  locale='fr-CH' 
  [selectedDate]="setDate">
  </ejs-schedule>
  1. You can notice the Scheduler displaying globalized date and time values in its UI, as shown in the following image, but the static text like Day, Week, Work Week and so on, are not changed as per the locale assigned to Scheduler.

Globalization in Scheduler

Localization

  1. To change these static text on Scheduler, provide the appropriate locale word collection to the Scheduler. As a first step, import the L10n class from @syncfusion/ej2-base package within the app.component.ts file.
import { L10n } from '@syncfusion/ej2-base';
  1. Next, using the load function of L10n class, pass the appropriate locale words of fr-CH culture as shown below,

NOTE: You can also pass the locale words of other cultures separated by a comma list.

L10n.load({
    'fr-CH': {
        'schedule': {
            'day': 'journée',
            'week': 'La semaine',
            'workWeek': 'Semaine de travail',
            'month': 'Mois',
            'today': 'Aujourd`hui',
            'agenda': 'Ordre du jour'
        }
    },
    'ar-AE': {
       'schedule': {
           ...
           ...
       }
    }
});
  1. Now, you can notice the Scheduler displaying localized text as shown below.

Localization in Scheduler

  1. You can refer all the available locale keys from the following documentation link: https://ej2.syncfusion.com/angular/documentation/schedule/localization/?#localizing-the-static-scheduler-text

Running on development server

Run ng serve command for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Further help

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

angular-scheduler-globalization-and-localization's People

Contributors

sarubala20 avatar umamaheswarichandrabose avatar vinothkumar-ganesan avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.