-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jukka Snellman
committed
Aug 16, 2022
1 parent
2e39299
commit 9d6385d
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
`.NET string localizer with culture` | ||
|
||
Implements [`IStringLocalizer`](https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.localization.istringlocalizer) | ||
that is bound to specific culture. | ||
|
||
See https://github.com/dotnet/aspnetcore/issues/7756 for context. | ||
|
||
```csharp | ||
var services = new ServiceCollection() | ||
.AddLocalizationWithCulture(options => options.ResourcesPath = "Resources") | ||
.BuildServiceProvider(); | ||
|
||
var localizerFactory = services.GetRequiredService<IStringLocalizerWithCultureFactory>(); | ||
var localizer = localizerFactory.Create(typeof(MyClass), CultureInfo.GetCultureInfo("en-US")); | ||
var translated = localizer["Hello"]; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters