Skip to content

Commit

Permalink
added README
Browse files Browse the repository at this point in the history
  • Loading branch information
Jukka Snellman committed Aug 16, 2022
1 parent 2e39299 commit 9d6385d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions README.md
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"];
```
7 changes: 6 additions & 1 deletion StringLocalizerWithCulture.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ VisualStudioVersion = 17.2.32616.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StringLocalizerWithCulture", "StringLocalizerWithCulture\StringLocalizerWithCulture.csproj", "{8DA84E58-3228-4BE1-A7B4-23A57B1F5B18}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StringLocalizerWithCulture.Tests", "StringLocalizerWithCulture.Tests\StringLocalizerWithCulture.Tests.csproj", "{C53FE560-2103-446C-A390-9D6E50F7C4F1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StringLocalizerWithCulture.Tests", "StringLocalizerWithCulture.Tests\StringLocalizerWithCulture.Tests.csproj", "{C53FE560-2103-446C-A390-9D6E50F7C4F1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1AE54F6F-CC3D-42F6-A854-1A8EDBCAB792}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down

0 comments on commit 9d6385d

Please sign in to comment.