You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wrong code character : replace ’-’, ’’ with ’-’, ’’ and remove invisible illegal characters. fixed code:
// Properly convert a language tag to a Locale
def computeLocale(tag : String) = tag.split(Array(’-’, ’_’)) match {
case Array(lang) => new Locale(lang)
case Array(lang, country) => new Locale(lang, country)
case Array(lang, country, variant) => new Locale(lang, country, variant)
}
// Define this to be whatever name you want
val LOCALE_COOKIE_NAME = "SelectedLocale"
LiftRules.localeCalculator = {
case fullReq @ Full(req) => {
// Check against a set cookie, or the locale sent in the request
def currentLocale : Locale =
S.findCookie(LOCALE_COOKIE_NAME).flatMap {
cookie => cookie.value.map(computeLocale)
} openOr LiftRules.defaultLocaleCalculator(fullReq)
// Check to see if the user explicitly requests a new locale
S.param("locale") match {
case Full(requestedLocale) if requestedLocale != null => {
val computedLocale = computeLocale(requestedLocale)
S.addCookie(HTTPCookie(LOCALE_COOKIE_NAME, requestedLocale))
computedLocale
}
case _ => currentLocale
}
}
case _ => Locale.getDefault
}
The text was updated successfully, but these errors were encountered:
In http://exploring.liftweb.net/master/index-D.html in the end of file part "Calculating Locale Based on Cookies and Parameters" code
wrong code character : replace ’-’, ’’ with ’-’, ’’ and remove invisible illegal characters. fixed code:
The text was updated successfully, but these errors were encountered: