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
+52-4Lines changed: 52 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,15 @@ The `Telerik.UI.for.Blazor` NuGet package includes a [`Telerik.Blazor.Resources.
26
26
27
27
## Localize Telerik Blazor Components
28
28
29
-
This tutorial assumes that the [Telerik resource files](#step-2-add-resouce-files) reside in `~/Resources/` and have names like `TelerikMessages.<locale>.resx`. It is possible to use different file and folder names. This will affect the name of the generated static class in `TelerikMessages.Designer.cs`, and the namespaces in the [Telerik localization service](#step-3-implement-itelerikstringlocalizer-service).
29
+
The tutorial below assumes that:
30
+
31
+
* The Blazor app name and the root namespace is `ServerLocalizationResx`.
32
+
* The [Telerik resource files](#step-2-add-resouce-files) exist in folder `~/Resources/` and have names like `TelerikMessages.<locale>.resx`.
33
+
34
+
Using your own names is possible and will affect:
35
+
36
+
* The class name and file name of the auto generated designer class (for example, `TelerikMessages` in `TelerikMessages.Designer.cs`)
37
+
* The used namespace and class in the [Telerik localization service](#step-3-implement-itelerikstringlocalizer-service) (for example, `AppName.Resources` and `TelerikMessages`)
This step is optional. You need it to manually render localized strings from the Telerik resource files. For example, the Telerik resource files include keys for the [built-in Grid commands]({%slug components/grid/columns/command%}).
132
+
133
+
* Import the `Telerik.Blazor.Services` namespace.
134
+
* Inject your `ITelerikStringLocalizer` service.
135
+
* Import the namespace of your Telerik localization `designer.cs` class.
136
+
137
+
>caption Localized .razor file with Telerik Blazor components
138
+
139
+
<divclass="skip-repl"></div>
140
+
141
+
````CSHTML
142
+
@using ServerLocalizationResx.Resources
143
+
144
+
@using Telerik.Blazor.Services
145
+
@inject ITelerikStringLocalizer TelerikLocalizer
146
+
147
+
<p>Localized Strings from Telerik Resource Files</p>
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/):
125
172
126
-
* <ahref="https://github.com/telerik/blazor-ui/tree/master/common/localization/ServerLocalizationResx"target="_blank">Blazor Web App with Server render mode</a>
* <ahref="https://github.com/telerik/blazor-ui/tree/master/common/localization/ServerLocalizationResx"target="_blank">Localized Telerik Blazor Web App with Server render mode</a>
You can also find a localization implementation in the offline version of the [Telerik UI for Blazor demos](https://demos.telerik.com/blazor-ui). Check your Telerik UI for Blazor installation folder or visit [UI for Blazor automated installer]({%slug installation/msi%}) or [UI for Blazor ZIP archive]({%slug installation/zip%}) for download instructions.
130
177
131
178
132
179
## Troubleshooting
133
180
181
+
Outdated Telerik resource files may cause [some UI labels to appear in English]({%slug common-kb-partial-localization%}), or the app may trigger a [`Value cannot be null. (Parameter 'format')` exception]({%slug common-kb-value-cannot-be-null-parameter-format%}).
134
182
135
-
*This is not related to the Telerik components, but our experience shows that setting `ResourcePath` in `services.AddLocalization()` may break the standard `IStringLocalizer` in your app.
183
+
This is not related to the Telerik components, but setting `ResourcePath` in `services.AddLocalization()` may break the standard `IStringLocalizer` in your app or make it more difficult to use.
0 commit comments