diff --git a/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/localization.cs b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/localization.cs new file mode 100644 index 0000000000..c728c26fcc --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/localization.cs @@ -0,0 +1,6 @@ +public IActionResult Index() +{ + var orders = OrderDetails.GetAllRecords(); + ViewBag.datasource = orders; + return View(); +} \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/razor b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/razor new file mode 100644 index 0000000000..18234cb923 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/razor @@ -0,0 +1,169 @@ +@Html.EJS().Grid("deGrid").DataSource((IEnumerable)ViewBag.datasource).Columns(col =>{ + col.Field("OrderID").HeaderText("Order ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add(); + col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add(); +}).AllowPaging().Locale("fr-FR").Render(); +@Html.EJS().Grid("enGrid").DataSource((IEnumerable)ViewBag.datasource).Columns(col =>{ + col.Field("OrderID").HeaderText("Order ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add(); + col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); + col.Field("ShipName").HeaderText("Ship Name").Width("150").Add(); + col.Field("ShipCountry").HeaderText("Ship Country").Width("150").Add(); +}).AllowPaging().Locale("en").Render() + \ No newline at end of file diff --git a/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/tagHelper b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/tagHelper new file mode 100644 index 0000000000..1eee8080d2 --- /dev/null +++ b/ej2-asp-core-mvc/code-snippet/grid/globalization/two-localization/tagHelper @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/global-local.md b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/global-local.md index 8d24edf1f6..bba1ecfba7 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/global-local.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.MVC/global-local.md @@ -295,6 +295,24 @@ To switch to the **French** culture and set the currency code as **EUR**, you ca ![Globalization-Switch-Culture](images/globalization/switch-localization.gif) +### Set different locale for two Grids in same page + +The Syncfusion Grid allows configuring different [locale](https://help.syncfusion.com/cr/aspnetmvc-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Locale) settings for multiple Grids displayed on the same page. By using the **load** function of the **L10n** class, you can customize the text content of the Grid to be displayed in different languages. + +In this setup, each Grid can display text in a different language based on its assigned `locale`. The `load` function is used to define translations for specific languages, ensuring that each Grid correctly applies the localized text for headers, toolbar items, and action buttons. + +For example, when the first Grid is set to use the **fr-FR** locale, it applies the French translations loaded via **L10n.load**. The second Grid, set to **en-US**, retains the default English text. This demonstrates how localization can be customized per Grid without affecting other components on the page. + +{% tabs %} +{% highlight razor tabtitle="CSHTML" %} +{% include code-snippet/grid/globalization/two-localization/razor %} +{% endhighlight %} + +{% highlight c# tabtitle="Localization.cs" %} +{% include code-snippet/grid/globalization/two-localization/localization.cs %} +{% endhighlight %} +{% endtabs %} + ## Internationalization The Internationalization library in the Syncfusion ASP.NET MVC Grid provides a localized display of number, date, and time values in the Grid control based on the preferred language and region. diff --git a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/global-local.md b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/global-local.md index 552cb5a5d2..3d8ef851d9 100644 --- a/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/global-local.md +++ b/ej2-asp-core-mvc/grid/EJ2_ASP.NETCORE/global-local.md @@ -295,6 +295,24 @@ To switch to the **French** culture and set the currency code as **EUR**, you ca ![Globalization-Switch-Culture](images/globalization/switch-localization.gif) +### Set different locale for two Grids in same page + +The Syncfusion Grid allows configuring different [locale](https://help.syncfusion.com/cr/aspnetcore-js2/syncfusion.ej2.grids.grid.html#Syncfusion_EJ2_Grids_Grid_Locale) settings for multiple Grids displayed on the same page. By using the **load** function of the **L10n** class, you can customize the text content of the Grid to be displayed in different languages. + +In this setup, each Grid can display text in a different language based on its assigned `locale`. The `load` function is used to define translations for specific languages, ensuring that each Grid correctly applies the localized text for headers, toolbar items, and action buttons. + +For example, when the first Grid is set to use the **fr-FR** locale, it applies the French translations loaded via **L10n.load**. The second Grid, set to **en-US**, retains the default English text. This demonstrates how localization can be customized per Grid without affecting other components on the page. + +{% tabs %} +{% highlight cshtml tabtitle="CSHTML" %} +{% include code-snippet/grid/globalization/two-localization/tagHelper %} +{% endhighlight %} + +{% highlight c# tabtitle="Localization.cs" %} +{% include code-snippet/grid/globalization/two-localization/localization.cs %} +{% endhighlight %} +{% endtabs %} + ## Internationalization The Internationalization library in the Syncfusion ASP.NET Core Grid provides a localized display of number, date, and time values in the Grid control based on the preferred language and region.