// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Globalization; namespace Microsoft.AspNet.Localization { /// /// Specifies options for the . /// public class RequestLocalizationOptions { private RequestCulture _defaultRequestCulture = new RequestCulture(CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture); /// /// Creates a new with default values. /// public RequestLocalizationOptions() { RequestCultureProviders = new List { new QueryStringRequestCultureProvider { Options = this }, new CookieRequestCultureProvider { Options = this }, new AcceptLanguageHeaderRequestCultureProvider { Options = this } }; } /// /// Gets or sets the default culture to use for requests when a supported culture could not be determined by /// one of the configured s. /// Defaults to and . /// public RequestCulture DefaultRequestCulture { get { return _defaultRequestCulture; } set { if (value == null) { throw new ArgumentNullException(nameof(value)); } _defaultRequestCulture = value; } } /// /// Gets or sets a value indicating whether to set a request culture to an ancestor culture in the case the /// culture determined by the configured s is not in the /// list but an ancestor culture is. /// Defaults to true; /// /// /// If this property is true and the application is configured to support the culture "fr", but not the /// culture "fr-FR", and a configured determines a request's culture is /// "fr-FR", then the request's culture will be set to the culture "fr", as it is an ancestor of "fr-FR". /// public bool FallBackToParentCultures { get; set; } = true; /// /// Gets or sets a value indicating whether to set a request UI culture to an ancestor culture in the case the /// UI culture determined by the configured s is not in the /// list but an ancestor culture is. /// Defaults to true; /// /// /// If this property is true and the application is configured to support the UI culture "fr", but not /// the UI culture "fr-FR", and a configured determines a request's UI /// culture is "fr-FR", then the request's UI culture will be set to the culture "fr", as it is an ancestor of /// "fr-FR". /// public bool FallBackToParentUICultures { get; set; } = true; /// /// The cultures supported by the application. The will only set /// the current request culture to an entry in this list. /// Defaults to . /// public IList SupportedCultures { get; set; } = new List { CultureInfo.CurrentCulture }; /// /// The UI cultures supported by the application. The will only set /// the current request culture to an entry in this list. /// Defaults to . /// public IList SupportedUICultures { get; set; } = new List { CultureInfo.CurrentUICulture }; /// /// An ordered list of providers used to determine a request's culture information. The first provider that /// returns a non-null result for a given request will be used. /// Defaults to the following: /// /// /// /// /// /// public IList RequestCultureProviders { get; set; } } }