@@ -194,29 +194,31 @@ public static LanguageItem[] GetRequestUserLanguages(this System.Web.HttpContext
194
194
if ( UserLanguages == null )
195
195
{
196
196
// Construct UserLanguages list and cache it for the rest of the request.
197
- context . Items [ "i18n.UserLanguages" ]
198
- = UserLanguages
199
- = LanguageItem . ParseHttpLanguageHeader (
200
- context . Request . Headers [ "Accept-Language" ] ) ;
201
- // NB: originally we passed LocalizedApplication.Current.DefaultLanguageTag
202
- // here as the second parameter i.e. to specify the PAL. However, this was
203
- // found to be incorrect when operating i18n with EarlyUrlLocalization disabled,
204
- // as SetPrincipalAppLanguageForRequest was not being called, that normally
205
- // overwriting the PAL set erroneously here.
197
+ context . Items [ "i18n.UserLanguages" ]
198
+ = UserLanguages = GetRequestUserLanguagesImplementation ( context ) ;
199
+ // NB: originally we passed LocalizedApplication.Current.DefaultLanguageTag
200
+ // here as the second parameter i.e. to specify the PAL. However, this was
201
+ // found to be incorrect when operating i18n with EarlyUrlLocalization disabled,
202
+ // as SetPrincipalAppLanguageForRequest was not being called, that normally
203
+ // overwriting the PAL set erroneously here.
206
204
}
207
205
return UserLanguages ;
208
206
}
209
207
210
- /// <summary>
211
- /// Add a Content-Language HTTP header to the response, based on any languages
212
- /// that have provided resources during the request.
213
- /// </summary>
214
- /// <param name="context">Context of the current request.</param>
215
- /// <returns>
216
- /// true if header added; false if no languages provided content during the request and
217
- /// so no header was added.
218
- /// </returns>
219
- public static bool SetContentLanguageHeader ( this System . Web . HttpContext context )
208
+ public delegate LanguageItem [ ] GetRequestUserLanguagesProc ( System . Web . HttpContextBase context ) ;
209
+
210
+ public static GetRequestUserLanguagesProc GetRequestUserLanguagesImplementation { get ; set ; } = ( context ) => LanguageItem . ParseHttpLanguageHeader ( context . Request . Headers [ "Accept-Language" ] ) ;
211
+
212
+ /// <summary>
213
+ /// Add a Content-Language HTTP header to the response, based on any languages
214
+ /// that have provided resources during the request.
215
+ /// </summary>
216
+ /// <param name="context">Context of the current request.</param>
217
+ /// <returns>
218
+ /// true if header added; false if no languages provided content during the request and
219
+ /// so no header was added.
220
+ /// </returns>
221
+ public static bool SetContentLanguageHeader ( this System . Web . HttpContext context )
220
222
{
221
223
return context . GetHttpContextBase ( ) . SetContentLanguageHeader ( ) ;
222
224
}
0 commit comments