Skip to content

Wolox/localization-culture-core

Repository files navigation

Localization Culture NetCore

Description

This project allows localization for NetCore using .json files instead of .resx.

Configuration in your project

  1. Add the package reference
    dotnet add package LocalizationCultureCore --version x.x.x
  1. On Startup.cs
    services.AddJsonLocalization(options => options.ResourcesPath = "Resources");
  1. 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.

Example

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

Steps to create and upload a NuGet Package

  1. Build the application on release mode.
    dotnet build -c release
  1. Pack the application.
    dotnet pack /p:PackageVersion=x.x.x -c release.
  1. The NuGet Package is now in /bin/release/LocalizationCultureCore.x.x.x.nupkg.

  2. Login at NuGet and upload the .nupkg file in Upload section.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

This project is based on AspNet5Localization

About

This project allows localization for NetCore using .json files instead of .resx.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages