johnkors / IdentityServer3.Contrib.Localization

Localization support for IdentityServer3
MIT License
19 stars 40 forks source link

IdnetityServer.Localization not working #63

Closed bayramucuncu closed 6 years ago

bayramucuncu commented 6 years ago

I am using IdentityServer3 v2.6 and IdentityServer3.Localization v0.3.194

I have created a custom LocaleOptions class,

   public class BrowserLanguageOptionsSelector : LocaleOptions
    {
        public BrowserLanguageOptionsSelector()
        {
            LocaleProvider = env =>
            {
                var owinContext = new OwinContext(env);
                var owinRequest = owinContext.Request;
                var headers = owinRequest.Headers;
                var acceptLanguageHeader = headers["accept-language"].ToString();
                var languages = acceptLanguageHeader
                    .Split(',')
                    .Select(StringWithQualityHeaderValue.Parse)
                    .OrderByDescending(s => s.Quality.GetValueOrDefault(1));
                var locale = languages.First().Value;
                return locale;
            };
        }
    }

And setted factory options like this:

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

But this does not work. When I try different language browsers, it show only English alnguage options.

When I set breakpoint in

LocalProvider = env

line, it breaks, but when I set breakpoint in

var owinContext = new OwinContext(env);

line, it does not break. I mean it does not go into env method.

I used specific culture like this:

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

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

But did not worked.

johnkors commented 6 years ago

What's showing in english when you set it for norwegian?

johnkors commented 6 years ago

The localization extensions for identityServer3 only allows us to translate a given set of resources, and not everything defined in the views unfortunately. Maybe this is what you're seeing.

https://github.com/johnkors/IdentityServer3.Contrib.Localization#what-does-it-translate

bayramucuncu commented 6 years ago

Ok. I needed to translate view options in this case. Thanks. So i will change the templates.