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: aspnetcore/blazor/globalization-localization.md
+92-81Lines changed: 92 additions & 81 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1075,9 +1075,23 @@ The component adopts the following approaches to work for either SSR or CSR comp
1075
1075
}
1076
1076
```
1077
1077
1078
+
In the `.Client` project's `_Imports` file (`_Imports.razor`), add the namespace for the components in the `Pages` folder, updating the namespace to match your `.Client` project's namespace:
1079
+
1080
+
```razor
1081
+
@using BlazorSample.Client.Pages
1082
+
```
1083
+
1078
1084
> [!NOTE]
1079
1085
> For more information on <xref:Microsoft.JSInterop.IJSInProcessRuntime>, see <xref:blazor/js-interop/call-javascript-from-dotnet#invoke-javascript-functions-without-reading-a-returned-value-invokevoidasync>.
1080
1086
1087
+
In the `.Client` project, add the `CultureSelector` component to the `MainLayout` component. Place the following markup inside the closing `</main>` tag in the `Layout/MainLayout.razor` file:
1088
+
1089
+
```razor
1090
+
<article class="bottom-row px-4">
1091
+
<CultureSelector @rendermode="InteractiveAuto" />
1092
+
</article>
1093
+
```
1094
+
1081
1095
In the `.Client` project, place the following `CultureClient` component to study how globalization works for CSR components.
1082
1096
1083
1097
`Pages/CultureClient.razor`:
@@ -1133,6 +1147,83 @@ In the `.Client` project, place the following `CultureClient` component to study
1133
1147
}
1134
1148
```
1135
1149
1150
+
In the `.Client` project, place the following `CultureServer` component to study how globalization works for SSR components.
Use the `CultureExample1` component shown in the [Demonstration component](#demonstration-component) section to study how globalization works for a component that inherits the global Auto render mode. Add the `CultureExample1` component to the `.Client` project's `Pages` folder.
1206
+
1207
+
Add the `CultureClient`, `CultureServer`, and `CultureExample1` components to the sidebar navigation in `Layout/NavMenu.razor`:
Add the [`Microsoft.Extensions.Localization`](https://www.nuget.org/packages/Microsoft.Extensions.Localization) package to the server project.
@@ -1253,89 +1344,9 @@ public class CultureController : Controller
1253
1344
> [!WARNING]
1254
1345
> Use the <xref:Microsoft.AspNetCore.Mvc.ControllerBase.LocalRedirect%2A> action result, as shown in the preceding example, to prevent open redirect attacks. For more information, see <xref:security/preventing-open-redirects>.
1255
1346
1256
-
Add the `CultureSelector` component to the `MainLayout` component. Place the following markup inside the closing `</main>` tag in the `Components/Layout/MainLayout.razor` file:
1257
-
1258
-
```razor
1259
-
<article class="bottom-row px-4">
1260
-
<CultureSelector @rendermode="InteractiveAuto" />
1261
-
</article>
1262
-
```
1263
-
1264
-
Use the `CultureExample1` component shown in the [Demonstration component](#demonstration-component) section to study how the preceding example works.
1265
-
1266
-
In the server project, place the following `CultureServer` component to study how globalization works for SSR components.
0 commit comments