Skip to content
This repository was archived by the owner on Sep 28, 2022. It is now read-only.

Commit 6b54337

Browse files
author
Dominik František Bučík
authored
Merge pull request #48 from dBucik/translations
refactor: 💡 Refactored how translations are loaded and used
2 parents febc9e9 + 665b45f commit 6b54337

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+331
-428
lines changed

perun-oidc-server-webapp/src/main/webapp/WEB-INF/application-context.xml

+7
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,14 @@
4646

4747
<bean id="userInfoInterceptor" class="cz.muni.ics.openid.connect.web.UserInfoInterceptor" />
4848
<bean id="serverConfigInterceptor" class="cz.muni.ics.openid.connect.web.ServerConfigInterceptor" />
49+
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
50+
<property name="paramName" value="lang"/>
51+
</bean>
4952
<mvc:interceptors>
53+
<mvc:interceptor>
54+
<mvc:mapping path="/**"/>
55+
<ref bean="localeChangeInterceptor"/>
56+
</mvc:interceptor>
5057
<mvc:interceptor>
5158
<!-- Exclude APIs and other machine-facing endpoints from these interceptors -->
5259
<mvc:mapping path="/**" />

perun-oidc-server-webapp/src/main/webapp/WEB-INF/locale-config.xml

+18-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,25 @@
1919
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2020
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
2121

22-
<bean id="messageSource" class="cz.muni.ics.openid.connect.config.JsonMessageSource">
23-
<property name="baseDirectory" value="/resources/js/locale/" />
24-
<property name="useCodeAsDefaultMessage" value="true" />
22+
<bean id="mitreIdMessageSource" class="cz.muni.ics.openid.connect.config.JsonMessageSource">
23+
<property name="baseDirectory" value="/resources/js/locale/"/>
24+
<property name="useCodeAsDefaultMessage" value="true"/>
2525
</bean>
2626

27-
<bean id="localeResolver" class="cz.muni.ics.openid.connect.config.ConfigurationBeanLocaleResolver" />
27+
<bean id="defaultPerunMessageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
28+
<property name="basename" value="localization.messages"/>
29+
<property name="defaultEncoding" value="UTF-8"/>
30+
<property name="parentMessageSource" ref="mitreIdMessageSource"/>
31+
<property name="useCodeAsDefaultMessage" value="false"/>
32+
</bean>
33+
34+
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
35+
<property name="basename" value="file:${web.langs.customfiles.path}"/>
36+
<property name="defaultEncoding" value="UTF-8"/>
37+
<property name="parentMessageSource" ref="defaultPerunMessageSource"/>
38+
<property name="useCodeAsDefaultMessage" value="false"/>
39+
</bean>
40+
41+
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"/>
2842

2943
</beans>

perun-oidc-server-webapp/src/main/webapp/WEB-INF/tags/cesnet/footer.tag

+9-8
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,33 @@
66
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
77
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
88
<%@ taglib prefix="t" tagdir="/WEB-INF/tags/common" %>
9+
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
910
<jsp:useBean id="date" class="java.util.Date" />
1011

1112
<div id="footer">
1213
<footer>
1314
<div class="container">
1415
<div class="row">
1516
<div class="col-md-4 logo">
16-
<a href="http://www.cesnet.cz/">
17+
<a href="https://www.cesnet.cz/">
1718
<img src="${samlResourcesURL}/module.php/cesnet/res/img/logo-cesnet.png" alt="CESNET logo" style="width: 250px;">
1819
</a>
1920
</div>
2021
<div class="col-md-8">
2122
<div class="row">
2223
<div class="col col-sm-6">
23-
<h2>${langProps['footer_other_projects']}</h2>
24+
<h2><spring:message code="footer_other_projects"/></h2>
2425
<ul>
25-
<li><a href="http://www.cesnet.cz/wp-content/uploads/2014/04/CzechLight-family_Posp%C3%ADchal.pdf">CzechLight</a></li>
26-
<li><a href="http://www.ultragrid.cz/en">UltraGrid</a></li>
27-
<li><a href="http://www.4kgateway.com/">4k Gateway</a></li>
28-
<li><a href="http://shongo.cesnet.cz/">Shongo</a></li>
29-
<li><a href="http://www.cesnet.cz/sluzby/sledovani-provozu-site/sledovani-infrastruktury/">FTAS a G3</a></li>
26+
<li><a href="https://www.cesnet.cz/wp-content/uploads/2014/04/CzechLight-family_Posp%C3%ADchal.pdf">CzechLight</a></li>
27+
<li><a href="https://www.ultragrid.cz/en">UltraGrid</a></li>
28+
<li><a href="https://www.4kgateway.com/">4k Gateway</a></li>
29+
<li><a href="https://shongo.cesnet.cz/">Shongo</a></li>
30+
<li><a href="https://www.cesnet.cz/sluzby/sledovani-provozu-site/sledovani-infrastruktury/">FTAS a G3</a></li>
3031
<li><a href="https://www.liberouter.org/">Librerouter</a></li>
3132
</ul>
3233
</div>
3334
<div class="col col-sm-6">
34-
<h2>${langProps['footer_helpdesk']}</h2>
35+
<h2><spring:message code="footer_helpdesk"/></h2>
3536
TEL: +420 224 352 994<br>
3637
GSM: +420 602 252 531<br>
3738
FAX: +420 224 313 211<br>

perun-oidc-server-webapp/src/main/webapp/WEB-INF/tags/common/attributesConsent.tag

+8-13
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
44
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
55
<%@ taglib prefix="o" tagdir="/WEB-INF/tags" %>
6+
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
67

78
<c:if test="${empty scopes}">
8-
<p>${langProps['no_scopes']}</p>
9+
<p><spring:message code="no_scopes"/></p>
910
</c:if>
1011
<c:if test="${not empty scopes}">
1112
<ul id="perun-table_with_attributes" class="perun-attributes">
1213
<c:forEach var="scope" items="${scopes}">
13-
<c:set var="scopeValue" value="${langProps[scope.value]}"/>
14-
<c:if test="${empty fn:trim(scopeValue)}">
15-
<c:set var="scopeValue" value="${scope.value}"/>
16-
</c:if>
14+
<spring:message code="${scope.value}" var="scope_value_txt"/>
1715
<c:set var="singleClaim" value="${fn:length(claims[scope.value]) eq 1}" />
1816
<li class="scope-item scope_${fn:escapeXml(scope.value)} ${' '} ${fn:length(claims[scope.value]) eq 0 ? 'hidden' : ''}">
1917
<div class="row">
@@ -22,24 +20,21 @@
2220
<input class="mt-0 mr-half" type="checkbox" name="scope_${ fn:escapeXml(scope.value) }" checked="checked"
2321
id="scope_${fn:escapeXml(scope.value)}" value="${fn:escapeXml(scope.value)}">
2422
</div>
25-
<h2 class="perun-attrname <c:out value="${classes['perun-attrname.h2.class']}"/>">
23+
<h2 class="perun-attrname ${classes['perun-attrname.h2.class']}">
2624
<label for="scope_${fn:escapeXml(scope.value)}"
27-
class="<c:out value="${classes['perun-attrname.h2.class']}"/>">${scopeValue}</label>
25+
class="${classes['perun-attrname.h2.class']}">${scope_value_txt}</label>
2826
</h2>
2927
</div>
3028
<div class="perun-attrcontainer col-sm-7">
3129
<span class="perun-attrvalue">
32-
<ul class="perun-attrlist <c:out value="${classes['perun-attrcontainer.ul.class']}"/>">
30+
<ul class="perun-attrlist ${classes['perun-attrcontainer.ul.class']}/>">
3331
<c:forEach var="claim" items="${claims[scope.value]}">
3432
<c:choose>
3533
<c:when test="${not singleClaim}">
3634
<li class="subclaim subclaim_${fn:escapeXml(claim.key)}">
37-
<c:set var="claimKey" value="${langProps[claim.key]}"/>
38-
<c:if test="${empty fn:trim(claimKey)}">
39-
<c:set var="claimKey" value="${claim.key}"/>
40-
</c:if>
35+
<spring:message code="${claim.key}" var="claimKey"/>
4136
<h3 class="visible-xs-block visible-sm-inline-block visible-md-inline-block
42-
visible-lg-inline-block <c:out value="${classes['perun-attrlist.h3.class']}"/>">
37+
visible-lg-inline-block ${classes['perun-attrlist.h3.class']}">
4338
${claimKey}:
4439
</h3>
4540
<c:if test="${claim.value.getClass().name eq 'java.util.ArrayList'}">

perun-oidc-server-webapp/src/main/webapp/WEB-INF/tags/common/consentButtons.tag

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
<%@ tag pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
22
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
33
<%@ taglib prefix="o" tagdir="/WEB-INF/tags" %>
4+
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
45

56
<div class="row">
67
<div class="col-sm-6">
78
<div id="yesform">
89
<button id="yesbutton" name="yes" type="submit" class="btn btn-success btn-lg btn-block btn-primary"
910
onclick="$('#user_oauth_approval').attr('value', true);">
10-
<span>${langProps['yes']}</span>
11+
<span><spring:message code="yes"/></span>
1112
</button>
1213
</div>
1314
</div>
1415
<div class="col-sm-6">
1516
<div>
1617
<button id="nobutton" name="no" type="submit" class="btn btn-lg btn-default btn-block btn-no"
1718
onclick="$('#user_oauth_approval').attr('value', false);">
18-
<span>${langProps['no']}</span>
19+
<span><spring:message code="no"/></span>
1920
</button>
2021
</div>
2122
</div>

perun-oidc-server-webapp/src/main/webapp/WEB-INF/tags/einfra/footer.tag

+15-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
77
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
88
<%@ taglib prefix="t" tagdir="/WEB-INF/tags/common" %>
9+
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
910
<jsp:useBean id="date" class="java.util.Date" />
1011

1112
<div id="footer">
@@ -18,27 +19,32 @@
1819
<div class="col-md-8">
1920
<div class="row">
2021
<div class="col col-sm-6">
21-
<h2>${langProps['footer_other_links']}</h2>
22+
<h2><spring:message code="footer_other_links"/></h2>
2223
<ul>
2324
<li>
24-
<a target="_blank" href="${langProps['einfra_link']}">${langProps['einfra_name']}</a>
25+
<spring:message code="einfra_link" var="einfra_link"/>
26+
<a target="_blank" href="${einfra_link}"><spring:message code="einfra_name"/></a>
2527
</li>
2628
<li>
27-
<a target="_blank" href="${langProps['cesnet_link']}">${langProps['cesnet_name']}</a>
29+
<spring:message code="einfra_link" var="cesnet_link"/>
30+
<a target="_blank" href="${cesnet_link}"><spring:message code="cesnet_name"/></a>
2831
</li>
2932
<li>
30-
<a target="_blank" href="${langProps['cerit_link']}">${langProps['cerit_name']}</a>
33+
<spring:message code="cerit_link" var="cerit_link"/>
34+
<a target="_blank" href="${cerit_link}"><spring:message code="cerit_name"/></a>
3135
</li>
3236
<li>
33-
<a target="_blank" href="${langProps['it4i_link']}">${langProps['it4i_name']}</a>
37+
<spring:message code="it4i_link" var="it4i_link"/>
38+
<a target="_blank" href="${it4i_link}"><spring:message code="it4i_name"/></a>
3439
</li>
3540
<li>
36-
<a target="_blank" href="${langProps['data_processing_link']}">${langProps['data_processing_name']}</a>
41+
<spring:message code="data_processing_link" var="data_processing_link"/>
42+
<a target="_blank" href="${data_processing_link}"><spring:message code="data_processing_name"/></a>
3743
</li>
3844
</ul>
3945
</div>
4046
<div class="col col-sm-6">
41-
<h2>${langProps['footer_helpdesk']}</h2>
47+
<h2><spring:message code="footer_helpdesk"/></h2>
4248
TEL: +420 234 680 222<br>
4349
GSM: +420 602 252 531<br>
4450
@@ -48,9 +54,9 @@
4854
</div>
4955
<div class="row">
5056
<div class="col col-sm-12 copyright">
51-
&copy; 2021 | <a target="_blank" href="${langProps['einfra_link']}">${langProps['einfra_name']}</a>
57+
&copy; 2021 | <a target="_blank" href="${einfra_link}"><spring:message code="einfra_name"/></a>
5258
<%-- USABLE FROM 2022 --%>
53-
<%--&copy; 2021-<fmt:formatDate value="${date}" pattern="yyyy" /> | <a target="_blank" href="${langProps['einfra_link']}">${langProps['einfra_name']}</a>--%>
59+
<%--&copy; 2021-<fmt:formatDate value="${date}" pattern="yyyy" /> | <a target="_blank" href="<spring:message code="einfra_link"/>"><spring:message code="einfra_name"/></a>--%>
5460
</div>
5561
</div>
5662
</div>

perun-oidc-server-webapp/src/main/webapp/WEB-INF/tags/muni/footer.tag

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
12
<%@ tag pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
23

34
</div>
@@ -7,8 +8,8 @@
78
<footer class="footer">
89
<div class="row-main">
910
<p class="footer__copyrights">
10-
${langProps['masaryk_university']}<br />
11-
${langProps['service']}${" "}<a href="https://it.muni.cz/sluzby/jednotne-prihlaseni-na-muni" target="_blank">${langProps['unified_login']}</a>${" "}${langProps['provided']}${" "}<a href="https://www.ics.muni.cz" target="_blank">${langProps['ics']}</a>
11+
<spring:message code="masaryk_university"/><br />
12+
<spring:message code="service"/>${" "}<a href="https://it.muni.cz/sluzby/jednotne-prihlaseni-na-muni" target="_blank"><spring:message code="unified_login"/></a>${" "}<spring:message code="provided"/>${" "}<a href="https://www.ics.muni.cz" target="_blank"><spring:message code="ics"/></a>
1213
</p>
1314
</div>
1415
</footer>

perun-oidc-server-webapp/src/main/webapp/WEB-INF/tags/muni/header.tag

+17-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
<%@ tag pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
22
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
33
<%@ taglib prefix="o" tagdir="/WEB-INF/tags/common" %>
4+
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
45
<%@ attribute name="title" required="true" %>
56
<%@ attribute name="reqURL" required="true" %>
67
<%@ attribute name="baseURL" required="true" %>
78
<%@ attribute name="samlResourcesURL" required="true" %>
89
<%@ attribute name="cssLinks" required="true" type="java.util.ArrayList<java.lang.String>" %>
910

1011
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
11-
<html class="no-js touch no-touch" lang="${langProps['other_lang']}">
12+
<spring:message code="other_lang" var="other_lang"/>
13+
<html class="no-js touch no-touch" lang="${other_lang}">
1214
<head>
13-
<meta cahrset="utf-8" />
15+
<meta charset="utf-8" />
1416
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1517
<meta name="author" content="Masarykova univerzita" />
1618

17-
<title>${langProps['unified_login']} | ${title}</title>
19+
<title><spring:message code="unified_login"/> | ${title}</title>
1820

1921
<link rel="stylesheet" type="text/css" href="https://id.muni.cz/simplesaml/module.php/muni/css/bootstrap.min.css">
2022
<link rel="stylesheet" type="text/css" href="https://id.muni.cz/simplesaml/module.php/muni/css/style-ie.css?1.2">
@@ -36,25 +38,26 @@
3638
</head>
3739

3840
<body>
39-
<c:set var="alternateURL" value="${reqURL}&lang=${langProps['other_lang']}"/>
41+
<c:set var="alternateURL" value="${reqURL}&lang=${other_lang}"/>
4042
<p class="menu-accessibility">
41-
<a title="${langProps['go_to_login_title']}" accesskey="2" href="#main">
42-
${langProps['go_to_login_text']}
43+
<a title="<spring:message code="go_to_login_title"/>" accesskey="2" href="#main">
44+
<spring:message code="go_to_login_text"/>
4345
</a>
4446
</p>
4547
<div class="header u-mb-0">
4648
<div class="row-main">
4749
<div class="header__wrap">
4850
<h1 class="header__logo">
49-
<img src="${samlResourcesURL}/module.php/${theme}/img/${langProps['img_name']}.png"
50-
width="${langProps['img_width']}" height="${langProps['img_height']}" alt="${langProps['muni_logo']}"/>
51+
<spring:message code="muni_logo" var="alt"/>
52+
<img src="${samlResourcesURL}/module.php/${theme}/img/<spring:message code="img_name"/>.png"
53+
width="<spring:message code="img_width"/>" height="<spring:message code="img_height"/>" alt="${alt}"/>
5154
</h1>
5255
<div class="header__side">
5356
<div class="menu-lang" role="navigation">
5457
<p class="menu-lang__selected">
55-
<a href="${alternateURL}" rel="alternate" hreflang="${langProps['other_lang']}"
56-
lang="${langProps['other_lang']}" class="menu-lang__selected__link">
57-
${langProps['other_language']}
58+
<a href="${alternateURL}" rel="alternate" hreflang="${other_lang}"
59+
lang="${other_lang}" class="menu-lang__selected__link">
60+
<spring:message code="other_language"/>
5861
</a>
5962
</p>
6063
</div>
@@ -63,9 +66,9 @@
6366
<div class="row-main">
6467
<ul class="menu-mobile__list">
6568
<li class="menu-mobile__item">
66-
<a href="${alternateURL}" rel="alternate" hreflang="${langProps['other_lang']}"
67-
class="menu-mobile__link menu-mobile__link--lang" lang="${langProps['other_lang']}">
68-
${langProps['other_language']}
69+
<a href="${alternateURL}" rel="alternate" hreflang="${other_lang}"
70+
class="menu-mobile__link menu-mobile__link--lang" lang="${other_lang}">
71+
<spring:message code="other_language"/>
6972
</a>
7073
</li>
7174
</ul>

0 commit comments

Comments
 (0)