public static Language GetSelectedLanguage(HttpContextBase context, string defaultCultureCode = null, Market market = null) { market = market ?? GetCurrentMarket(context); var cultureCode = GetSelectedCultureCode(context, defaultCultureCode); var language = GlobalUtilities.GetLanguage(cultureCode, market); return(language); }
public static Language GetLanguageByCustomerID(int customerID) { // Get the user's language preference based on their saved preference var customer = ExigoDAL.GetCustomer(customerID); var market = GlobalUtilities.GetMarket(customer.MainAddress.Country); var language = GlobalUtilities.GetLanguage(customer.LanguageID, market); // Return the language return(language); }
public static string GetSelectedCultureCode(HttpContextBase context, string defaultCultureCode = null) { // get the cookie (generates using default value if not available) var value = GlobalUtilities.GetCookie( context, cookieName: GlobalSettings.Globalization.LanguageCookieName, defaultValue: defaultCultureCode, defaultExpiration: DateTime.Now.AddYears(1), httpOnly: false // allow access via JavaScript ); return(value); }
/// <summary> /// Get the selected country code /// </summary> /// <remarks>Defaults to country of the default market</remarks> /// <returns></returns> public static string GetSelectedCountryCode(HttpContextBase context, string countryCode = null) { // get market that matches country code (or default) var defaultMarket = GlobalUtilities.GetMarket(countryCode); // get the cookie (generates using default value if not available) var value = GlobalUtilities.GetCookie( context, cookieName: GlobalSettings.Globalization.CountryCookieName, defaultValue: defaultMarket.MainCountry, defaultExpiration: DateTime.Now.AddYears(1), httpOnly: false // allow access via JavaScript ); // return the value return(value); }
public static int GetSelectedExigoLanguageID() { //If the cookie LanguagePreference exists, we set the culture code appropriately var languageKey = GlobalUtilities.GetSelectedLanguage(); switch (languageKey) { // not being used case "fr-CA": return(Languages.French); case "es-US": return(Languages.Spanish); case "en-US": default: return(Languages.English); } }
/// <summary> /// Sets the selected country code /// </summary> /// <returns></returns> public static string SetSelectedCountryCode(HttpContextBase context, string countryCode) { // get the market for the selected country var market = GlobalUtilities.GetMarket(countryCode); // get the current cookie value (generates if it doesn't exist) var value = GetSelectedCountryCode(context, market.MainCountry); // if existing value is different, set with new value if (!value.Equals_IgnoreCase(market.MainCountry)) { value = market.MainCountry; GlobalUtilities.SetCookie( context, name: GlobalSettings.Globalization.CountryCookieName, value: value); } // return the value return(value); }
/// <summary> /// Gets the configuration, based on the country cookie /// </summary> public static Market GetCurrentMarket(HttpContextBase context) { var countryCode = GlobalUtilities.GetSelectedCountryCode(context); return(GetMarket(countryCode)); }
/// <summary> /// Gets the configuration, based on the country cookie /// </summary> public static Market GetCurrentMarket() { var countryCode = GlobalUtilities.GetSelectedCountryCode(); return(GlobalSettings.Markets.AvailableMarkets.FirstOrDefault(c => c.Countries.Contains(countryCode))); }