Localization
30 Sep 20223 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.
@using Syncfusion.EJ2.Maps;
@using Syncfusion.EJ2;
<div id="control-section">
<ejs-maps id="maps" locale="ar-AR">
<e-maps-zoomsettings enable="true"></e-maps-zoomsettings>
<e-maps-layers>
<e-maps-layer shapeData="ViewBag.world_map">
</e-maps-layer>
</e-maps-layers>
</ejs-maps>
</div>
<script>
ej.base.L10n.load({
'ar-AR': {
'maps': {
ZoomIn: 'تكبير',
ZoomOut: 'تصغير',
Zoom: 'زوم',
Pan: 'مقلاة',
Reset: 'إعادة تعيين'
},
}
});
</script>
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using EJ2_Core_Application.Models;
using Newtonsoft.Json;
namespace EJ2_Core_Application.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
ViewBag.world_map = GetWorldMap();
ViewBag.electionData = GetElectionData();
return View();
}
public object GetWorldMap()
{
string allText = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/world_map.js");
return JsonConvert.DeserializeObject(allText);
}
public object GetElectionData()
{
string text = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/electiondata.js");
return JsonConvert.DeserializeObject(text);
}
}
}