Open jnpwly opened 5 years ago
I suspect the SetPrincipalAppLanguageForRequest
method has evolved somewhat.
It's original purpose was two-fold:
Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = langtag.GetCultureInfo();
Looks like 2. was then moved to the handler model with a default handler installed to invoke that default logic -- but updateThreadCulture
wasn't adpated at the same time.
I suspect most clients will probably NOT install their own handlers and just expect the default handler here to update the cultures if updateThreadCulture == true
.
Maybe the best way forward is:
updateThreadCulture
argument from existing methods. That will break the API but not behaviour that is according to spec.SetPrincipalAppLanguageForRequestWithoutCallingHandlers
that does what it says.
In the
HttpContextExtensions.cs
file, there is a comment that by setting theupdateThreadCulture
boolean, the user can change whether the CurrentCulture/CurrentUICulture settings can be changed:https://github.com/turquoiseowl/i18n/blob/ce7bdc9d8a8b92022c42417edeff4fb9ce8d3170/src/i18n/Helpers/HttpContextExtensions.cs#L135
However, this boolean ultimately has no impact; it is not actually used in the method.
It's not clear to me what the intention with this boolean was. Was it meant to allow the end user to ultimately change just the
Thread.CurrentThread.CurrentCulture
and not theThread.CurrentThread.CurrentUICulture
? Or, was there something else in mind?I am more than happy to submit a PR that changes the comment, to indicate that it doesn't do anything. That's the easiest thing to do. Probably can't just remove the boolean, as that might break existing usages of the
i18n
library. Alternatively, I could work on developing a PR that attempts to only update theThread.CurrentThread.CurrentCulture
and not theThread.CurrentThread.CurrentUICulture
. But, seeing as the library user can implement their ownSetPrincipalAppLanguageForRequestHandler
, then maybe that is the method that end users should use to avoid changing the UI Culture??