<commit_before>| master | dev | latest |
| --- | --- | --- |
| [![master](https://ci.appveyor.com/api/projects/status/63g2yulmxod35vd1/branch/master?svg=true)](https://ci.appveyor.com/project/JohnKorsnes/identityserver3-contrib-localization/branch/master) | [![dev](https://ci.appveyor.com/api/projects/status/63g2yulmxod35vd1/branch/dev?svg=true)](https://ci.appveyor.com/project/JohnKorsnes/identityserver3-contrib-localization/branch/dev) | [![NuGet Stable](http://img.shields.io/nuget/v/IdentityServer3.Localization.svg?style=flat)](https://www.nuget.org/packages/IdentityServer3.Localization/)|

# Contents
Implementation of IdentityServerV3's ILocalizationService.

### What does it translate?
  - Resource strings defined by IdentityServer. See [a list of defined resources here.](http://johnkors.github.io/IdentityServer3.Contrib.Localization/#/Default)
  - If what you want to translate is not defined by those resources, you would need to implement it yourself.

## Usage

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

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

- To use IdentityServer3s default provided localization fixed:
```
   var factory = new IdentityServerServiceFactory();
   factory.LocalizationService = new Registration<ILocalizationService, GlobalizedLocalizationService>();
```

- To use Pirate culture:
```
   var factory = new IdentityServerServiceFactory();
   var options = new LocaleOptions { LocaleProvider = env => "pirate" };

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

```

- Making use of the users language setting:
```
using System.Net.Http.Headers; // if you want to use StringWithQualityHeaderValue
 

  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<LocaleOptions>(opts));
  factory.LocalizationService = new Registration<ILocalizationService, GlobalizedLocalizationService>();

```

## Supported languages
 * See the [live docs of all translations](http://johnkors.github.io/IdentityServer3.Contrib.Localization/#/Default)<commit_msg>Removed pirate from the readme<commit_after>| master | dev | latest |
| --- | --- | --- |
| [![master](https://ci.appveyor.com/api/projects/status/63g2yulmxod35vd1/branch/master?svg=true)](https://ci.appveyor.com/project/JohnKorsnes/identityserver3-contrib-localization/branch/master) | [![dev](https://ci.appveyor.com/api/projects/status/63g2yulmxod35vd1/branch/dev?svg=true)](https://ci.appveyor.com/project/JohnKorsnes/identityserver3-contrib-localization/branch/dev) | [![NuGet Stable](http://img.shields.io/nuget/v/IdentityServer3.Localization.svg?style=flat)](https://www.nuget.org/packages/IdentityServer3.Localization/)|

# Contents
Implementation of IdentityServerV3's ILocalizationService.

### What does it translate?
  - Resource strings defined by IdentityServer. See [a list of defined resources here.](http://johnkors.github.io/IdentityServer3.Contrib.Localization/#/Default)
  - If what you want to translate is not defined by those resources, you would need to implement it yourself.

## Usage

- Set a specific culture for all users:
```
   var factory = new IdentityServerServiceFactory();
   var options = new LocaleOptions { LocaleProvider = env => "nb-NO" };

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

- Making use of the users language setting from the browser:
```
using System.Net.Http.Headers; // if you want to use StringWithQualityHeaderValue
 

  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<LocaleOptions>(opts));
  factory.LocalizationService = new Registration<ILocalizationService, GlobalizedLocalizationService>();

```

## Supported languages
 * See the [live docs of all translations](http://johnkors.github.io/IdentityServer3.Contrib.Localization/#/Default)
{'fraction_non_alphanumeric': 0.11948291782086796, 'fraction_numerical': 0.007571560480147738, 'mean_word_length': 3.835714285714286, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 21, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '391978', 'n_tokens_mistral': 1550, 'n_tokens_neox': 1473, 'n_words': 305}