Skip to content

Commit

Permalink
Fix for localization selection
Browse files Browse the repository at this point in the history
  • Loading branch information
lw authored and stefano-maggiolo committed Jul 25, 2017
1 parent 800163e commit 38da3be
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 0 additions & 2 deletions cms/server/contest/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ def prepare(self):
"""
super(BaseHandler, self).prepare()

self._ = self.locale.translate

# We need this to be computed for each request because we want to be
# able to import new contests without having to restart CWS. But only
# in multi-contest mode.
Expand Down
6 changes: 4 additions & 2 deletions cms/server/contest/handlers/contest.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ def prepare(self):
super(ContestHandler, self).prepare()
self.choose_contest()

self._ = self.locale.translate

if self.is_multi_contest():
self.contest_url = \
create_url_builder(self.url(self.contest.name))
Expand Down Expand Up @@ -294,14 +296,14 @@ def get_user_locale(self):
self.langs = self.application.service.langs
lang_codes = self.langs.keys()

if self.contest and len(self.contest.allowed_localizations) > 0:
if self.contest.allowed_localizations:
lang_codes = filter_language_codes(
lang_codes, self.contest.allowed_localizations)

# Select the one the user likes most.
basic_lang = 'en'

if self.contest and len(self.contest.allowed_localizations):
if self.contest.allowed_localizations:
basic_lang = lang_codes[0].replace("_", "-")

http_langs = [lang_code.replace("_", "-") for lang_code in lang_codes]
Expand Down
2 changes: 1 addition & 1 deletion cms/server/contest/static/cws_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ CMS.CWSUtils.prototype.rel_to_abs = function(sRelPath) {
};

CMS.CWSUtils.prototype.switch_lang = function() {
var cookie_path = this.rel_to_abs(this.contest_url());
var cookie_path = this.rel_to_abs(this.contest_url() + "/").slice(0, -1) || "/";
var lang = $("#lang").val();
if (lang === "") {
document.cookie = "language="
Expand Down

0 comments on commit 38da3be

Please sign in to comment.