Internationalization

30 Sep 20223 minutes to read

Maps provide support for internationalization for the below elements.

  • Data label
  • Tooltip

For more information about number and date formatter, refer to the internationalization section.

Globalization

Globalization is the process of designing and developing a component that works in different cultures/locales. Internationalization library is used to globalize number, date, time values in Maps component using Format property in the Maps.

Numeric format

The numeric formats such as currency, percentage and so on can be displayed in the tooltip and data labels of the Maps using the Format property in the Maps. In the below example, the tooltip is globalized to German culture. When setting the UseGroupingSeparator property as true, the numeric text in the Maps separates with the comma separator.

@using Syncfusion.EJ2.Maps;

@{
    var internData = new[]
    {
        new { Country= "China", Membership="Permanent", population= "38332521" },
        new { Country= "France", Membership="Permanent", population= "19651127" },
        new { Country= "Russia", Membership="Permanent", population= "3090416" },
        new { Country= "Kazakhstan", Membership="Non-Permanent", population= "1232521" },
        new { Country= "Poland", Membership="Non-Permanent", population= "90332521" },
        new { Country= "Sweden", Membership="Non-Permanent", population= "383521" }
    };
    var colorMapping = new List<Syncfusion.EJ2.Maps.MapsColorMapping> {
        new MapsColorMapping {Value="Permanent", Color="#D84444"},
        new MapsColorMapping {Value="Non-Permanent", Color="#316DB5"}
     };
}
<ejs-maps id="maps" format="c" useGroupingSeparator="true">
    <e-maps-layers>
        <e-maps-layer dataSource="internData" shapeData="ViewBag.world_map" shapeDataPath="Country" shapePropertyPath='new[] { "name" }'>
            <e-layersettings-shapesettings colorValuePath="Membership" fill="#E5E5E5" colorMapping="colorMapping">
            </e-layersettings-shapesettings>
            <e-layersettings-tooltipsettings visible="true" valuePath="population"></e-layersettings-tooltipsettings>
        </e-maps-layer>
    </e-maps-layers>
</ejs-maps>
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.worldMap = GetMap();
            return View();
        }
        public object GetWorldMap()
        {
            string allText = System.IO.File.ReadAllText("./wwwroot/scripts/MapsData/world_map.js");
            return JsonConvert.DeserializeObject(allText);
        }
        public object GetMap()
        {
            string allText = System.IO.File.ReadAllText(Server.MapPath("~/App_Data/WorldMap.json"));
            return JsonConvert.DeserializeObject(allText, typeof(object));
        }
    }
}

Internationalization