proper language selection for anonymous
This commit is contained in:
parent
004d4d97f1
commit
8c2b22cd18
|
@ -12,17 +12,20 @@ object I18n extends LilaController {
|
|||
|
||||
private def env = Env.i18n
|
||||
|
||||
def select = AuthBody { implicit ctx =>
|
||||
me =>
|
||||
import play.api.data.Forms._
|
||||
import play.api.data._
|
||||
implicit val req = ctx.body
|
||||
Form(single("lang" -> text.verifying(env.pool contains _))).bindFromRequest.fold(
|
||||
_ => funit,
|
||||
lang => lila.user.UserRepo.setLang(me.id, lang)
|
||||
) inject Redirect {
|
||||
HTTPRequest referer ctx.req getOrElse routes.Lobby.home.url
|
||||
def select = OpenBody { implicit ctx =>
|
||||
import play.api.data.Forms._
|
||||
import play.api.data._
|
||||
implicit val req = ctx.body
|
||||
Form(single("lang" -> text.verifying(env.pool contains _))).bindFromRequest.fold(
|
||||
_ => notFound,
|
||||
lang => (ctx.me ?? { me => lila.user.UserRepo.setLang(me.id, lang) }) inject Redirect {
|
||||
s"${Env.api.Net.Protocol}${lang}.${Env.api.Net.Domain}" + {
|
||||
HTTPRequest.referer(ctx.req).fold(routes.Lobby.home.url) { str =>
|
||||
new java.net.URL(str).getPath
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
def contribute = Open { implicit ctx =>
|
||||
|
|
|
@ -23,12 +23,8 @@ final class I18nRequestHandler(
|
|||
} yield Redirect(redirectUrlLang(req, userLang))
|
||||
|
||||
private def redirectUrl(req: RequestHeader) =
|
||||
protocol +
|
||||
I18nDomain(req.domain).withLang(pool preferred req).domain +
|
||||
req.uri
|
||||
redirectUrlLang(req, pool.preferred(req).language)
|
||||
|
||||
private def redirectUrlLang(req: RequestHeader, lang: String) =
|
||||
protocol +
|
||||
I18nDomain(req.domain).withLang(lang).domain +
|
||||
req.uri
|
||||
s"$protocol${I18nDomain(req.domain).withLang(lang).domain}${req.uri}"
|
||||
}
|
||||
|
|
|
@ -1253,6 +1253,7 @@ div.lichess_language {
|
|||
.language_links li:last-child {
|
||||
width: 50%;
|
||||
font-weight: bold;
|
||||
padding-top: 10px;
|
||||
}
|
||||
#themepicker {
|
||||
float: right;
|
||||
|
|
Loading…
Reference in a new issue