Localization in Angular Maps component
27 Apr 20242 minutes to read
The localization library allows localizing the default text content of the Maps component. The Maps component has the static text of some features such as tooltip of zoom toolbar, and that can be changed to any other culture(Arabic, Deutsch, French, etc) by defining the locale value and translation object.
Locale key words | Text to display |
Zoom | Zoom |
ZoomIn | Zoom In |
ZoomOut | Zoom Out |
Reset | Reset |
Pan | Pan |
To load translation object in the application, use load
function of L10n class. For more information about localization, refer here.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { MapsModule } from '@syncfusion/ej2-angular-maps'
import { MapsTooltipService, ZoomService } from '@syncfusion/ej2-angular-maps'
import { Component, OnInit } from '@angular/core';
import { world_map } from './world-map';
import { L10n } from '@syncfusion/ej2-base';
L10n.load({
'ar-AR': {
'maps': {
ZoomIn: 'تكبير',
ZoomOut: 'تصغير',
Zoom: 'زوم',
Pan: 'مقلاة',
Reset: 'إعادة تعيين'
},
}
});
@Component({
imports: [
MapsModule
],
providers: [MapsTooltipService, ZoomService],
standalone: true,
selector: 'app-container',
template: `<ejs-maps id='container' [locale]="Locale" [zoomSettings]='zoom'>
<e-layers>
<e-layer [shapeData]="mapData" [tooltipSettings]='tooltipSettings'></e-layer>
</e-layers>
<ejs-maps>`
})
export class AppComponent implements OnInit {
public mapData: object[] = world_map as any;
public Locale: string = 'ar-AR';
public zoom: object = {
enable: true
};
public tooltipSettings: object = {
enable: true
};
ngOnInit(): void {
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));