|
1 | | -# angular-scheduler-globalization-and-localization |
| 1 | +# Angular Scheduler - Globalization and Localization |
2 | 2 | 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. |
| 3 | + |
| 4 | +## Project pre-requisites |
| 5 | +Make sure that you have the compatible versions of TypeScript and Angular in your machine before starting to work on this project. |
| 6 | +* Angular 4+ |
| 7 | +* TypeScript 2.6+ |
| 8 | + |
| 9 | +## How to run this application? |
| 10 | +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. |
| 11 | + |
| 12 | +To do so, open the command prompt and run the below commands one after the other. |
| 13 | + |
| 14 | +``` |
| 15 | +git clone https://github.com/SyncfusionSamples/angular-scheduler-globalization-and-localization grid-example |
| 16 | +cd grid-example |
| 17 | +``` |
| 18 | + |
| 19 | +## Installing |
| 20 | +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. |
| 21 | + |
| 22 | +``` |
| 23 | +npm install |
| 24 | +``` |
| 25 | + |
| 26 | +## Globalization and Localization |
| 27 | +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. |
| 28 | + |
| 29 | +### Globalization |
| 30 | +1. To globalize the date and time formats in Scheduler, install the `cldr-data` package using the command, |
| 31 | + |
| 32 | +``` |
| 33 | +npm install cldr-data --save |
| 34 | +``` |
| 35 | + |
| 36 | +2. Once the installation is done, import `loadCldr` function from `@syncfusion/ej2-base` package within the `app.component.ts` file. |
| 37 | + |
| 38 | +``` |
| 39 | +import { loadCldr } from '@syncfusion/ej2-base'; |
| 40 | +``` |
| 41 | + |
| 42 | +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. |
| 43 | + |
| 44 | +``` |
| 45 | +declare var require: any; |
| 46 | +
|
| 47 | +loadCldr( |
| 48 | + require('cldr-data/supplemental/numberingSystems.json'), |
| 49 | + require('cldr-data/main/fr-CH/ca-gregorian.json'), |
| 50 | + require('cldr-data/main/fr-CH/numbers.json'), |
| 51 | + require('cldr-data/main/fr-CH/timeZoneNames.json')); |
| 52 | +``` |
| 53 | + |
| 54 | +3. Now, you can set the `locale` property to Scheduler and assign the required culture code(`fr-CH) to it. |
| 55 | + |
| 56 | +``` |
| 57 | + <ejs-schedule |
| 58 | + [eventSettings]="eventObject" |
| 59 | + locale='fr-CH' |
| 60 | + [selectedDate]="setDate"> |
| 61 | + </ejs-schedule> |
| 62 | +``` |
| 63 | + |
| 64 | +4. 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. |
| 65 | + |
| 66 | + |
| 67 | +### Localization |
| 68 | + |
| 69 | +5. 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. |
| 70 | + |
| 71 | +``` |
| 72 | +import { L10n } from '@syncfusion/ej2-base'; |
| 73 | +``` |
| 74 | + |
| 75 | +6. Next, using the `load` function of L10n class, pass the appropriate locale words of `fr-CH` culture as follows, |
| 76 | + |
| 77 | +> NOTE: You can also pass the locale words of other cultures separated by a comma list. |
| 78 | +
|
| 79 | +``` |
| 80 | +L10n.load({ |
| 81 | + 'fr-CH': { |
| 82 | + 'schedule': { |
| 83 | + 'day': 'journée', |
| 84 | + 'week': 'La semaine', |
| 85 | + 'workWeek': 'Semaine de travail', |
| 86 | + 'month': 'Mois', |
| 87 | + 'today': 'Aujourd`hui', |
| 88 | + 'agenda': 'Ordre du jour' |
| 89 | + } |
| 90 | + }, |
| 91 | + 'ar': { |
| 92 | + 'schedule': { |
| 93 | + ... |
| 94 | + ... |
| 95 | + } |
| 96 | + } |
| 97 | +}); |
| 98 | +``` |
| 99 | + |
| 100 | +7. Now, you can notice the Scheduler displaying localized text as shown below. |
| 101 | + |
| 102 | + |
| 103 | +8. You can refer the available locale keys from the following documentation link: |
| 104 | +https://ej2.syncfusion.com/angular/documentation/schedule/localization/?#localizing-the-static-scheduler-text |
| 105 | + |
| 106 | +## Running on development server |
| 107 | +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. |
| 108 | + |
| 109 | +## Further help |
| 110 | + |
| 111 | +To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md). |
| 112 | + |
0 commit comments