You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: globalization/localization.md
+16-12Lines changed: 16 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -31,23 +31,28 @@ Telerik provides and supports the default English texts. The offline demos carry
31
31
32
32
When localizing a Blazor app, make sure you are familiar with the way localization works in the framework. You can start from the following resources:
33
33
34
-
*[Localization in Blazor](https://docs.microsoft.com/en-us/aspnet/core/blazor/components?view=aspnetcore-3.0#localization)
34
+
*[Globalization and Localization in Blazor](https://docs.microsoft.com/en-us/aspnet/core/blazor/globalization-localization?view=aspnetcore-3.1)
35
35
*[Localization in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/localization?view=aspnetcore-3.0)
36
36
37
+
>tip You can find sample runnable projects for both server-side Blazor and for WebAssembly in the [Telerik Blazor UI Samples Repo](https://github.com/telerik/blazor-ui/tree/master/common/localization/).
38
+
>
39
+
>You can also find an example server-side implementation in our offline demos project that are available your Telerik UI for Blazor installation (both [msi]({%slug installation/msi%}) and [zip]({%slug installation/zip%})).
40
+
41
+
42
+
### Walkthrough - How to Add Globalization and Localization to a Server-side Blazor App
43
+
44
+
This section will show a tutorial on how to add globalization and localization to a server-side Blazor app. For a WebAssemly app, chek out the [ClientLocalizationResx sample project](https://github.com/telerik/blazor-ui/tree/master/common/localization/ClientLocalizationResx).
45
+
37
46
The necessary steps are to:
38
47
39
48
1. Enable the .NET Core localization services.
40
49
1. Implement the UI culture storage (for example, a cookie).
41
50
1. Optionally, add UI that will let the user change the culture so you can test how this works (for example, a dropdownlist that will redirect to the appropriate controller). Alternatively, you can hardcode the `options.DefaultRequestCulture` in the `ConfigureServices` method inside `Startup.cs` when generating the options for the framework localization service.
42
51
1. Implement a service for localizing the Telerik components - it must return the desired string based on the current culture and the requested key (see the explanations above).
43
52
44
-
>note The code snippets below will showcase a sample implementation for a server-side app. For a client-side app, some framework configurations my differ and you cannot use `.resx` files because the framework does not support them.
45
53
46
-
>tip You can find an example implementation in our offline demos project that are available your Telerik UI for Blazor installation (both [msi]({%slug installation/msi%}) and [zip]({%slug installation/zip%})).
47
-
>
48
-
> More examples are available in the following repo: [https://github.com/telerik/blazor-ui/tree/master/common/localization/](https://github.com/telerik/blazor-ui/tree/master/common/localization/).
49
54
50
-
>note When following this tutorial to add localization to an existing app, make sure to compare the configuration you are copying so that you do not remove configuration necessary for your app.
55
+
>note When following this tutorial to add localization to an existing app, make sure to compare the configuration you are copying so that you do not remove configuration necessary for your app. Code comments and regions explain details.
51
56
52
57
>caption Step 1 - Example for enabling localization in the app
53
58
@@ -148,10 +153,7 @@ public class CultureController : Controller
@@ -247,9 +249,11 @@ public class CultureController : Controller
247
249
248
250
>caption Step 4 - Sample Telerik localization service implementation - this example relies on a `~/Resources` folder with the necessary `.resx` files.
249
251
250
-
>important You must implement the indexer only. You can obtain the needed strings from any source you prefer and that matches you application, such as database, `resx` files (not supported in client-side projects at the time of writing), `json` files, hash tables, and so on.
252
+
>tip You must implement the indexer only. You can obtain the needed strings from any source you prefer and that matches your application needs, such as database, `resx` files, `json` files, hash tables, and so on.
@@ -278,7 +282,7 @@ It is required that you add the resource file provided in your Telerik UI for Bl
278
282
Make sure to:
279
283
280
284
* Mark the `resx` files as `Embedded Resource` (right click > Properties > Build Action).
281
-
* Have the following in your `ProjectName.csproj` file so the designer file is generated (it should be added when you add the main messages file, or when you open and save it. Copy the snippet in case it is not added). If the `Designer` file does not get generated, open the `resx` file in Visual Studio and toggle its `Access Modifier` to `Public`.
285
+
* Have the following in your `ProjectName.csproj` file so the designer file is generated. It should be added when you add the main messages file, or when you open and save it. Copy the snippet in case it is not added. If the `Designer` file does not get generated, open the `resx` file in Visual Studio and toggle its `Access Modifier` to `Public`.
0 commit comments