Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

278 configurable headercheck #285

Merged

Conversation

Jandev
Copy link
Contributor

@Jandev Jandev commented Aug 5, 2016

Created delegate to let the developers decide what functionality should be implemented when parsing the user request languages. Necessary if you want to skip the "Accept-Language"-header.

This should resolve #278

@turquoiseowl turquoiseowl merged commit c6fff28 into turquoiseowl:master Aug 5, 2016
@Jandev Jandev deleted the 278_configurable_headercheck branch August 5, 2016 09:02
@turquoiseowl
Copy link
Owner

Looks very good! Thanks for the contribution.

@Jandev
Copy link
Contributor Author

Jandev commented Aug 5, 2016

Thanks!
Is there an interval you use for creating new Nuget packages, or is it random?

I'm asking so we know when to expect the functionality in a public package.

@turquoiseowl
Copy link
Owner

I'll push a new package over the weekend.

@jeancroy
Copy link
Contributor

jeancroy commented Feb 23, 2017

I just wanted to share that history item Support for ignoring Accept-Language request header
Points to this PR. However how to implement said feature is not trivial nor documented.

The problem lie in the fact that said delegate return an array of LanguageItem, a data structure specialized for dealing with Accept-Language request header and the relative scoring of each item.

First I tried to return an empty array. Unfortunately that result in index out of bound exception later.

i18n.HttpContextExtensions.GetRequestUserLanguagesImplementation =
    (context) => new LanguageItem[] {  }; 

Then I tried to return the default language. Unfortunately this involve faking ranks & magic numbers.

i18n.HttpContextExtensions.GetRequestUserLanguagesImplementation = 
  (context) => 
     new[] { new LanguageItem(LocalizedApplication.Current.DefaultLanguageTag, 1.0f, 0) };

This seems better however there's a comment that explicitly warn against using this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Customize scheme 1
3 participants