Skip to content

Commit f397abd

Browse files
authored
Add remark on designer file namespace conflict (#34318)
1 parent 77ac823 commit f397abd

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

aspnetcore/blazor/globalization-localization.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,12 +1670,25 @@ To further understand how the Blazor framework processes localization, see the [
16701670

16711671
To create localization shared resources, adopt the following approach.
16721672

1673+
* Confirm that the [`Microsoft.Extensions.Localization`](https://www.nuget.org/packages/Microsoft.Extensions.Localization) package is referenced by the project.
1674+
1675+
[!INCLUDE[](~/includes/package-reference.md)]
1676+
1677+
* Confirm that the <xref:Microsoft.Extensions.Localization?displayProperty=fullName> namespace is available to the project's Razor components via an entry in the project's `_Imports` file:
1678+
1679+
```razor
1680+
@using Microsoft.Extensions.Localization
1681+
```
1682+
16731683
* Create a dummy class with an arbitrary class name. In the following example:
16741684

16751685
* The app uses the `BlazorSample` namespace, and localization assets use the `BlazorSample.Localization` namespace.
16761686
* The dummy class is named `SharedResource`.
16771687
* The class file is placed in a `Localization` folder at the root of the app.
16781688

1689+
> [!NOTE]
1690+
> Don't use an autogenerated designer file (for example, `SharedResources.Designer.cs`). The dummy class is meant to act as the shared resource class. The presence of a designer file results in a namespace collision.
1691+
16791692
`Localization/SharedResource.cs`:
16801693

16811694
```csharp

0 commit comments

Comments
 (0)