Skip to content

Commit d55ae61

Browse files
committed
Reimplement language switcher to make it work when JavaScript is disabled.
Don't show the current language by default but show another language instead. This also should help to users that don't understand the current language and looking for a way to choose another one. Fix #608
1 parent eb57501 commit d55ae61

File tree

20 files changed

+97
-641
lines changed

20 files changed

+97
-641
lines changed

src/main/java/ru/mystamps/web/Url.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public final class Url {
8383
public static final String ADD_SERIES_WITH_COUNTRY_PAGE = "/series/add/country/{slug}";
8484

8585
// MUST be updated when any of our resources were modified
86-
public static final String RESOURCES_VERSION = "v0.3.3";
86+
public static final String RESOURCES_VERSION = "v0.3.4";
8787

8888
// CheckStyle: ignore LineLength for next 4 lines
8989
public static final String MAIN_CSS = "/static/" + RESOURCES_VERSION + "/styles/main.min.css";

src/main/resources/ru/mystamps/i18n/Messages.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
typeMismatch = Invalid value
22

33
# shared
4-
t_english = English
5-
t_russian = Russian
64
t_login = Login
75
t_logout = Sign out
86
t_password = Password

src/main/resources/ru/mystamps/i18n/Messages_ru.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
typeMismatch = Некорректное значение
22

33
# используемые на нескольких страницах
4-
t_english = Английский
5-
t_russian = Русский
64
t_login = Логин
75
t_logout = Выйти
86
t_password = Пароль

src/main/webapp/WEB-INF/static/styles/main.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ label {
9999
float: none;
100100
}
101101

102-
.dropdown-entry-lang {
103-
padding-left: 5px;
104-
}
105-
106102
.link-vcenter {
107103
line-height: 34px;
108104
}

src/main/webapp/WEB-INF/views/account/activate.html

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -21,50 +21,12 @@
2121
<a href="../site/index.html" th:href="'/'" th:text="#{t_my_stamps}">My stamps</a>
2222
</div><!--
2323
24-
--><div class="col-sm-1 vcenter">
25-
<div class="dropdown">
26-
<!--/*/
27-
<th:block th:switch="${#locale.language}">
28-
<th:block th:case="'ru'">
29-
<span class="lang-xs" lang="ru"></span>
30-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_russian}">
31-
Russian
32-
</a>
33-
</th:block>
34-
<th:block th:case="*">
35-
/*/-->
36-
<span class="lang-xs" lang="en"></span>
37-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_english}">
38-
English
39-
</a>
40-
<!--/*/
41-
</th:block>
42-
</th:block>
43-
/*/-->
44-
<span class="caret"></span>
45-
<ul class="dropdown-menu" th:switch="${#locale.language}">
46-
<!--/*/
47-
<li th:case="'ru'">
48-
<div class="dropdown-entry-lang">
49-
<span class="lang-xs" lang="en"></span>
50-
<a href="?lang=en"
51-
hreflang="en"
52-
th:href="@{${ACTIVATE_ACCOUNT_PAGE}(key=${param.key},lang=en)}"
53-
th:text="#{t_english}">English</a>
54-
</div>
55-
</li>
56-
/*/-->
57-
<li th:case="*">
58-
<div class="dropdown-entry-lang">
59-
<span class="lang-xs" lang="ru"></span>
60-
<a href="?lang=ru"
61-
hreflang="ru"
62-
th:href="@{${ACTIVATE_ACCOUNT_PAGE}(key=${param.key},lang=ru)}"
63-
th:text="#{t_russian}">Russian</a>
64-
</div>
65-
</li>
66-
</ul>
67-
</div>
24+
--><div class="col-sm-1 vcenter"
25+
th:with="lang=${#locale.language == 'en' ? 'ru' : 'en'},langName=${#locale.language == 'en' ? 'Русский' : 'English'}">
26+
<span class="lang-xs" lang="ru"
27+
th:lang="${lang}"></span>
28+
<a href="javascript:void(0)" hreflang="ru"
29+
th:href="@{${ACTIVATE_ACCOUNT_PAGE}(key=${param.key},lang=${lang})}" th:hreflang="${lang}" th:text="${langName}">Русский</a>
6830
</div><!--
6931
7032
--><div id="user_bar" class="col-sm-2 vcenter">

src/main/webapp/WEB-INF/views/account/auth.html

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,12 @@
2121
<a href="../site/index.html" th:href="'/'" th:text="#{t_my_stamps}">My stamps</a>
2222
</div><!--
2323
24-
--><div class="col-sm-1 vcenter">
25-
<div class="dropdown">
26-
<!--/*/
27-
<th:block th:switch="${#locale.language}">
28-
<th:block th:case="'ru'">
29-
<span class="lang-xs" lang="ru"></span>
30-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_russian}">
31-
Russian
32-
</a>
33-
</th:block>
34-
<th:block th:case="*">
35-
/*/-->
36-
<span class="lang-xs" lang="en"></span>
37-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_english}">
38-
English
39-
</a>
40-
<!--/*/
41-
</th:block>
42-
</th:block>
43-
/*/-->
44-
<span class="caret"></span>
45-
<ul class="dropdown-menu" th:switch="${#locale.language}">
46-
<!--/*/
47-
<li th:case="'ru'">
48-
<div class="dropdown-entry-lang">
49-
<span class="lang-xs" lang="en"></span>
50-
<a href="?lang=en" hreflang="en" th:text="#{t_english}">English</a>
51-
</div>
52-
</li>
53-
/*/-->
54-
<li th:case="*">
55-
<div class="dropdown-entry-lang">
56-
<span class="lang-xs" lang="ru"></span>
57-
<a href="?lang=ru" hreflang="ru" th:text="#{t_russian}">Russian</a>
58-
</div>
59-
</li>
60-
</ul>
61-
</div>
24+
--><div class="col-sm-1 vcenter"
25+
th:with="lang=${#locale.language == 'en' ? 'ru' : 'en'},langName=${#locale.language == 'en' ? 'Русский' : 'English'}">
26+
<span class="lang-xs" lang="ru"
27+
th:lang="${lang}"></span>
28+
<a href="javascript:void(0)" hreflang="ru"
29+
th:href="|?lang=${lang}|" th:hreflang="${lang}" th:text="${langName}">Русский</a>
6230
</div><!--
6331
6432
--><div id="user_bar" class="col-sm-2 vcenter">

src/main/webapp/WEB-INF/views/account/register.html

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,12 @@
2121
<a href="../site/index.html" th:href="'/'" th:text="#{t_my_stamps}">My stamps</a>
2222
</div><!--
2323
24-
--><div class="col-sm-1 vcenter">
25-
<div class="dropdown">
26-
<!--/*/
27-
<th:block th:switch="${#locale.language}">
28-
<th:block th:case="'ru'">
29-
<span class="lang-xs" lang="ru"></span>
30-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_russian}">
31-
Russian
32-
</a>
33-
</th:block>
34-
<th:block th:case="*">
35-
/*/-->
36-
<span class="lang-xs" lang="en"></span>
37-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_english}">
38-
English
39-
</a>
40-
<!--/*/
41-
</th:block>
42-
</th:block>
43-
/*/-->
44-
<span class="caret"></span>
45-
<ul class="dropdown-menu" th:switch="${#locale.language}">
46-
<!--/*/
47-
<li th:case="'ru'">
48-
<div class="dropdown-entry-lang">
49-
<span class="lang-xs" lang="en"></span>
50-
<a href="?lang=en" hreflang="en" th:text="#{t_english}">English</a>
51-
</div>
52-
</li>
53-
/*/-->
54-
<li th:case="*">
55-
<div class="dropdown-entry-lang">
56-
<span class="lang-xs" lang="ru"></span>
57-
<a href="?lang=ru" hreflang="ru" th:text="#{t_russian}">Russian</a>
58-
</div>
59-
</li>
60-
</ul>
61-
</div>
24+
--><div class="col-sm-1 vcenter"
25+
th:with="lang=${#locale.language == 'en' ? 'ru' : 'en'},langName=${#locale.language == 'en' ? 'Русский' : 'English'}">
26+
<span class="lang-xs" lang="ru"
27+
th:lang="${lang}"></span>
28+
<a href="javascript:void(0)" hreflang="ru"
29+
th:href="|?lang=${lang}|" th:hreflang="${lang}" th:text="${langName}">Русский</a>
6230
</div><!--
6331
6432
--><div id="user_bar" class="col-sm-2 vcenter">

src/main/webapp/WEB-INF/views/category/add.html

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,44 +21,12 @@
2121
<a href="../site/index.html" th:href="'/'" th:text="#{t_my_stamps}">My stamps</a>
2222
</div><!--
2323
24-
--><div class="col-sm-1 vcenter">
25-
<div class="dropdown">
26-
<!--/*/
27-
<th:block th:switch="${#locale.language}">
28-
<th:block th:case="'ru'">
29-
<span class="lang-xs" lang="ru"></span>
30-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_russian}">
31-
Russian
32-
</a>
33-
</th:block>
34-
<th:block th:case="*">
35-
/*/-->
36-
<span class="lang-xs" lang="en"></span>
37-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_english}">
38-
English
39-
</a>
40-
<!--/*/
41-
</th:block>
42-
</th:block>
43-
/*/-->
44-
<span class="caret"></span>
45-
<ul class="dropdown-menu" th:switch="${#locale.language}">
46-
<!--/*/
47-
<li th:case="'ru'">
48-
<div class="dropdown-entry-lang">
49-
<span class="lang-xs" lang="en"></span>
50-
<a href="?lang=en" hreflang="en" th:text="#{t_english}">English</a>
51-
</div>
52-
</li>
53-
/*/-->
54-
<li th:case="*">
55-
<div class="dropdown-entry-lang">
56-
<span class="lang-xs" lang="ru"></span>
57-
<a href="?lang=ru" hreflang="ru" th:text="#{t_russian}">Russian</a>
58-
</div>
59-
</li>
60-
</ul>
61-
</div>
24+
--><div class="col-sm-1 vcenter"
25+
th:with="lang=${#locale.language == 'en' ? 'ru' : 'en'},langName=${#locale.language == 'en' ? 'Русский' : 'English'}">
26+
<span class="lang-xs" lang="ru"
27+
th:lang="${lang}"></span>
28+
<a href="javascript:void(0)" hreflang="ru"
29+
th:href="|?lang=${lang}|" th:hreflang="${lang}" th:text="${langName}">Русский</a>
6230
</div><!--
6331
6432
--><div id="user_bar" class="col-sm-2 vcenter">

src/main/webapp/WEB-INF/views/category/info.html

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,12 @@
2323
<a href="../site/index.html" th:href="'/'" th:text="#{t_my_stamps}">My stamps</a>
2424
</div><!--
2525
26-
--><div class="col-sm-1 vcenter">
27-
<div class="dropdown">
28-
<!--/*/
29-
<th:block th:switch="${#locale.language}">
30-
<th:block th:case="'ru'">
31-
<span class="lang-xs" lang="ru"></span>
32-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_russian}">
33-
Russian
34-
</a>
35-
</th:block>
36-
<th:block th:case="*">
37-
/*/-->
38-
<span class="lang-xs" lang="en"></span>
39-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_english}">
40-
English
41-
</a>
42-
<!--/*/
43-
</th:block>
44-
</th:block>
45-
/*/-->
46-
<span class="caret"></span>
47-
<ul class="dropdown-menu" th:switch="${#locale.language}">
48-
<!--/*/
49-
<li th:case="'ru'">
50-
<div class="dropdown-entry-lang">
51-
<span class="lang-xs" lang="en"></span>
52-
<a href="?lang=en" hreflang="en" th:text="#{t_english}">English</a>
53-
</div>
54-
</li>
55-
/*/-->
56-
<li th:case="*">
57-
<div class="dropdown-entry-lang">
58-
<span class="lang-xs" lang="ru"></span>
59-
<a href="?lang=ru" hreflang="ru" th:text="#{t_russian}">Russian</a>
60-
</div>
61-
</li>
62-
</ul>
63-
</div>
26+
--><div class="col-sm-1 vcenter"
27+
th:with="lang=${#locale.language == 'en' ? 'ru' : 'en'},langName=${#locale.language == 'en' ? 'Русский' : 'English'}">
28+
<span class="lang-xs" lang="ru"
29+
th:lang="${lang}"></span>
30+
<a href="javascript:void(0)" hreflang="ru"
31+
th:href="|?lang=${lang}|" th:hreflang="${lang}" th:text="${langName}">Русский</a>
6432
</div><!--
6533
6634
--><div id="user_bar" class="col-sm-2 vcenter">

src/main/webapp/WEB-INF/views/category/list.html

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,44 +20,12 @@
2020
<a href="../site/index.html" th:href="'/'" th:text="#{t_my_stamps}">My stamps</a>
2121
</div><!--
2222
23-
--><div class="col-sm-1 vcenter">
24-
<div class="dropdown">
25-
<!--/*/
26-
<th:block th:switch="${#locale.language}">
27-
<th:block th:case="'ru'">
28-
<span class="lang-xs" lang="ru"></span>
29-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_russian}">
30-
Russian
31-
</a>
32-
</th:block>
33-
<th:block th:case="*">
34-
/*/-->
35-
<span class="lang-xs" lang="en"></span>
36-
<a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown" th:text="#{t_english}">
37-
English
38-
</a>
39-
<!--/*/
40-
</th:block>
41-
</th:block>
42-
/*/-->
43-
<span class="caret"></span>
44-
<ul class="dropdown-menu" th:switch="${#locale.language}">
45-
<!--/*/
46-
<li th:case="'ru'">
47-
<div class="dropdown-entry-lang">
48-
<span class="lang-xs" lang="en"></span>
49-
<a href="?lang=en" hreflang="en" th:text="#{t_english}">English</a>
50-
</div>
51-
</li>
52-
/*/-->
53-
<li th:case="*">
54-
<div class="dropdown-entry-lang">
55-
<span class="lang-xs" lang="ru"></span>
56-
<a href="?lang=ru" hreflang="ru" th:text="#{t_russian}">Russian</a>
57-
</div>
58-
</li>
59-
</ul>
60-
</div>
23+
--><div class="col-sm-1 vcenter"
24+
th:with="lang=${#locale.language == 'en' ? 'ru' : 'en'},langName=${#locale.language == 'en' ? 'Русский' : 'English'}">
25+
<span class="lang-xs" lang="ru"
26+
th:lang="${lang}"></span>
27+
<a href="javascript:void(0)" hreflang="ru"
28+
th:href="|?lang=${lang}|" th:hreflang="${lang}" th:text="${langName}">Русский</a>
6129
</div><!--
6230
6331
--><div id="user_bar" class="col-sm-2 vcenter">

0 commit comments

Comments
 (0)