Search results

Localization

Localization library allows you to localize the default text content of Dialog. In Dialog, The close button’s tooltip text alone will be localized based on the culture. By using Locale property, you can set the culture dynamically in dialog component.

Locale key en-US (default)
close Close

Loading translations

To load the translation object in an application, define the culture and the component’s locale text corresponding to the language in a separate locale.json file.

{
    "fr-CH": {
        "dialog": {
            "close": "Fermer"
        }
    }
}

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

@using Syncfusion.EJ2.Blazor
@using Syncfusion.EJ2.Blazor.Popups
@using Syncfusion.EJ2.Blazor.Buttons
@using Microsoft.JSInterop;

<EjsButton @onclick="@OnBtnClick">Open Dialog</EjsButton>
<EjsDialog @ref="DialogObj" Width="250px" Locale="fr-CH" ShowCloseIcon="true" >
    <DialogTemplates>
        <Header> Dialogue</Header>
        <Content> Dialogue avec la culture française</Content>
    </DialogTemplates>
</EjsDialog>

@code {
    EjsDialog DialogObj;
    [Inject]
    protected IJSRuntime JsRuntime { get; set; }

    protected override void OnAfterRender(bool firstRender) {
        //Refer the path for the locale data
        this.JsRuntime.Ejs().LoadLocaleData("wwwroot/js/locale.json");
    }
    private void OnBtnClick()
    {
        this.DialogObj.Show();
    }
}

The output will be as follows.

dialog