Search results

Localization in ASP.NET Core Dialog control

27 Jul 2021 / 1 minute to read

Localization library allows to localize the default text content of Dialog. In Dialog, The close button’s tooltip text alone will be localize based on culture.

Locale key en-US (default)
close close

Loading translations

To load translation object in an application use load function of L10n class.

In the below sample, French culture is set to Dialog and change the close button’s tooltip text.

tagHelper
controller.cs
Copied to clipboard
<div id='container' style="height:400px;">
    <ejs-button id="targetButton" content="Ouvrir le dialogue"></ejs-button>
    <ejs-dialog id="dialog" locale="fr-BE" showCloseIcon="true" header="Dialogue" content="Dialogue avec la culture française" target="#container" width="250px"></ejs-dialog>
</div>

<script>
    window.onload = function () {
        document.getElementById('targetButton').onclick = function () {
            var dialog = document.getElementById("dialog").ej2_instances[0];
            dialog.show();
        }
        ej.base.L10n.load({
            'fr-BE': {
                'dialog': { 'close': "Fermer" }
            }
        });
    }
</script>
Copied to clipboard
public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
}

Output be like the below.

dialog