View on GitHub

IdentityServer3.Contrib.Localization

Localization support for IdentityServer3

Download this project as a .zip file Download this project as a tar.gz file

IdentityServer3.Contrib.Localization

master NuGet Stable

Contents

Implementation of IdentityServerV3s ILocalizationService

Usage

Hard code a specific culture:

   var factory = new IdentityServerServiceFactory();
   var options = new LocaleOptions { LocaleProvider = env => "nb-NO" };

   factory.Register(new Registration(options));   
   factory.LocalizationService = new Registration<ILocalizationService, GlobalizedLocalizationService>();

Provide language from accept header:

   // if you want to use StringWithQualityHeaderValue
  using System.Net.Http.Headers; 
 

  var opts = new LocaleOptions
  {
      LocaleProvider = env =>
      {
          var owinContext = new OwinContext(env);
          var owinRequest = owinContext.Request;
          var headers = owinRequest.Headers;
          var accept_language_header = headers["accept-language"].ToString();
          var languages = accept_language_header
                              .Split(',')
                              .Select(StringWithQualityHeaderValue.Parse)
                              .OrderByDescending(s => s.Quality.GetValueOrDefault(1));
         var locale = languages.First().Value;
         return locale;
      }
  };
  
  factory.Register(new Registration(opts));
  factory.LocalizationService = new Registration<ILocalizationService, GlobalizedLocalizationService\>();

Live view of supported translations

Install

  PM> Install-Package IdentityServer3.Localization

NuGet: https://www.nuget.org/packages/IdentityServer3.Localization

Contributing

How to add another language:

Dependencies