Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
better i18n Accept-Language parsing to properly support examples (+ as standalone function) #1850
there is now a function to replicate the default behaviour of a translation context (as returning null simply uses the first element in languages) + the cases that were advertised in the examples (like rewriting en_GB to en_US if only that is available) actually work now and are unittested.
I couldn't find the examples (http://vibed.org/docs#web-localization) in the repository so I didn't change the documentation there that now you can also use
This is definitely good to have as a public API. Apart from the behavior change with regards to the fallback behavior this looks good.
I only changed the behaviour of the documented unittest (example on the website) to show that you should do this instead of returning null because it gives the user the best user experience if the programmer overrides the provider to support cookies, etc. Before it would default to the first language in the array (en_US) if if wasn't in the session which would mean that potential matches of the Accept-Language header were lost.