This project allows localization for NetCore using .json files instead of .resx.
- Add the package reference
dotnet add package LocalizationCultureCore --version x.x.x
- On Startup.cs
services.AddJsonLocalization(options => options.ResourcesPath = "Resources");
- Create a folder named "Resources" in the project's root directory. In this folder will be the resource json files: 'en-US.json', 'en.json', etc.
To configure Localization Culture NetCore you must to add these lines in the ConfigureServices method on Startup.cs
services.AddJsonLocalization(options => options.ResourcesPath = "Resources");
services.AddMvc().AddViewLocalization();
The last line allows to use the localizer in the views. To configure a default culture, you can do the following:
CultureInfo.CurrentUICulture = new CultureInfo("en-US");
You can see a full example here
- Build the application on release mode.
dotnet build -c release
- Pack the application.
dotnet pack /p:PackageVersion=x.x.x -c release.
-
The NuGet Package is now in /bin/release/LocalizationCultureCore.x.x.x.nupkg.
-
Login at NuGet and upload the .nupkg file in Upload section.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
This project is based on AspNet5Localization