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

Commit

Permalink
Merge pull request #48 from dBucik/translations
Browse files Browse the repository at this point in the history
refactor: 💡 Refactored how translations are loaded and used
  • Loading branch information
Dominik František Bučík authored Nov 30, 2021
2 parents febc9e9 + 665b45f commit 6b54337
Show file tree
Hide file tree
Showing 42 changed files with 331 additions and 428 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@

<bean id="userInfoInterceptor" class="cz.muni.ics.openid.connect.web.UserInfoInterceptor" />
<bean id="serverConfigInterceptor" class="cz.muni.ics.openid.connect.web.ServerConfigInterceptor" />
<bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang"/>
</bean>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<ref bean="localeChangeInterceptor"/>
</mvc:interceptor>
<mvc:interceptor>
<!-- Exclude APIs and other machine-facing endpoints from these interceptors -->
<mvc:mapping path="/**" />
Expand Down
22 changes: 18 additions & 4 deletions perun-oidc-server-webapp/src/main/webapp/WEB-INF/locale-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,25 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<bean id="messageSource" class="cz.muni.ics.openid.connect.config.JsonMessageSource">
<property name="baseDirectory" value="/resources/js/locale/" />
<property name="useCodeAsDefaultMessage" value="true" />
<bean id="mitreIdMessageSource" class="cz.muni.ics.openid.connect.config.JsonMessageSource">
<property name="baseDirectory" value="/resources/js/locale/"/>
<property name="useCodeAsDefaultMessage" value="true"/>
</bean>

<bean id="localeResolver" class="cz.muni.ics.openid.connect.config.ConfigurationBeanLocaleResolver" />
<bean id="defaultPerunMessageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="localization.messages"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="parentMessageSource" ref="mitreIdMessageSource"/>
<property name="useCodeAsDefaultMessage" value="false"/>
</bean>

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="file:${web.langs.customfiles.path}"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="parentMessageSource" ref="defaultPerunMessageSource"/>
<property name="useCodeAsDefaultMessage" value="false"/>
</bean>

<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver"/>

</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,33 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags/common" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<jsp:useBean id="date" class="java.util.Date" />

<div id="footer">
<footer>
<div class="container">
<div class="row">
<div class="col-md-4 logo">
<a href="http://www.cesnet.cz/">
<a href="https://www.cesnet.cz/">
<img src="${samlResourcesURL}/module.php/cesnet/res/img/logo-cesnet.png" alt="CESNET logo" style="width: 250px;">
</a>
</div>
<div class="col-md-8">
<div class="row">
<div class="col col-sm-6">
<h2>${langProps['footer_other_projects']}</h2>
<h2><spring:message code="footer_other_projects"/></h2>
<ul>
<li><a href="http://www.cesnet.cz/wp-content/uploads/2014/04/CzechLight-family_Posp%C3%ADchal.pdf">CzechLight</a></li>
<li><a href="http://www.ultragrid.cz/en">UltraGrid</a></li>
<li><a href="http://www.4kgateway.com/">4k Gateway</a></li>
<li><a href="http://shongo.cesnet.cz/">Shongo</a></li>
<li><a href="http://www.cesnet.cz/sluzby/sledovani-provozu-site/sledovani-infrastruktury/">FTAS a G3</a></li>
<li><a href="https://www.cesnet.cz/wp-content/uploads/2014/04/CzechLight-family_Posp%C3%ADchal.pdf">CzechLight</a></li>
<li><a href="https://www.ultragrid.cz/en">UltraGrid</a></li>
<li><a href="https://www.4kgateway.com/">4k Gateway</a></li>
<li><a href="https://shongo.cesnet.cz/">Shongo</a></li>
<li><a href="https://www.cesnet.cz/sluzby/sledovani-provozu-site/sledovani-infrastruktury/">FTAS a G3</a></li>
<li><a href="https://www.liberouter.org/">Librerouter</a></li>
</ul>
</div>
<div class="col col-sm-6">
<h2>${langProps['footer_helpdesk']}</h2>
<h2><spring:message code="footer_helpdesk"/></h2>
TEL: +420 224 352 994<br>
GSM: +420 602 252 531<br>
FAX: +420 224 313 211<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="o" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

<c:if test="${empty scopes}">
<p>${langProps['no_scopes']}</p>
<p><spring:message code="no_scopes"/></p>
</c:if>
<c:if test="${not empty scopes}">
<ul id="perun-table_with_attributes" class="perun-attributes">
<c:forEach var="scope" items="${scopes}">
<c:set var="scopeValue" value="${langProps[scope.value]}"/>
<c:if test="${empty fn:trim(scopeValue)}">
<c:set var="scopeValue" value="${scope.value}"/>
</c:if>
<spring:message code="${scope.value}" var="scope_value_txt"/>
<c:set var="singleClaim" value="${fn:length(claims[scope.value]) eq 1}" />
<li class="scope-item scope_${fn:escapeXml(scope.value)} ${' '} ${fn:length(claims[scope.value]) eq 0 ? 'hidden' : ''}">
<div class="row">
Expand All @@ -22,24 +20,21 @@
<input class="mt-0 mr-half" type="checkbox" name="scope_${ fn:escapeXml(scope.value) }" checked="checked"
id="scope_${fn:escapeXml(scope.value)}" value="${fn:escapeXml(scope.value)}">
</div>
<h2 class="perun-attrname <c:out value="${classes['perun-attrname.h2.class']}"/>">
<h2 class="perun-attrname ${classes['perun-attrname.h2.class']}">
<label for="scope_${fn:escapeXml(scope.value)}"
class="<c:out value="${classes['perun-attrname.h2.class']}"/>">${scopeValue}</label>
class="${classes['perun-attrname.h2.class']}">${scope_value_txt}</label>
</h2>
</div>
<div class="perun-attrcontainer col-sm-7">
<span class="perun-attrvalue">
<ul class="perun-attrlist <c:out value="${classes['perun-attrcontainer.ul.class']}"/>">
<ul class="perun-attrlist ${classes['perun-attrcontainer.ul.class']}/>">
<c:forEach var="claim" items="${claims[scope.value]}">
<c:choose>
<c:when test="${not singleClaim}">
<li class="subclaim subclaim_${fn:escapeXml(claim.key)}">
<c:set var="claimKey" value="${langProps[claim.key]}"/>
<c:if test="${empty fn:trim(claimKey)}">
<c:set var="claimKey" value="${claim.key}"/>
</c:if>
<spring:message code="${claim.key}" var="claimKey"/>
<h3 class="visible-xs-block visible-sm-inline-block visible-md-inline-block
visible-lg-inline-block <c:out value="${classes['perun-attrlist.h3.class']}"/>">
visible-lg-inline-block ${classes['perun-attrlist.h3.class']}">
${claimKey}:
</h3>
<c:if test="${claim.value.getClass().name eq 'java.util.ArrayList'}">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
<%@ tag pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="o" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>

<div class="row">
<div class="col-sm-6">
<div id="yesform">
<button id="yesbutton" name="yes" type="submit" class="btn btn-success btn-lg btn-block btn-primary"
onclick="$('#user_oauth_approval').attr('value', true);">
<span>${langProps['yes']}</span>
<span><spring:message code="yes"/></span>
</button>
</div>
</div>
<div class="col-sm-6">
<div>
<button id="nobutton" name="no" type="submit" class="btn btn-lg btn-default btn-block btn-no"
onclick="$('#user_oauth_approval').attr('value', false);">
<span>${langProps['no']}</span>
<span><spring:message code="no"/></span>
</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags/common" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<jsp:useBean id="date" class="java.util.Date" />

<div id="footer">
Expand All @@ -18,27 +19,32 @@
<div class="col-md-8">
<div class="row">
<div class="col col-sm-6">
<h2>${langProps['footer_other_links']}</h2>
<h2><spring:message code="footer_other_links"/></h2>
<ul>
<li>
<a target="_blank" href="${langProps['einfra_link']}">${langProps['einfra_name']}</a>
<spring:message code="einfra_link" var="einfra_link"/>
<a target="_blank" href="${einfra_link}"><spring:message code="einfra_name"/></a>
</li>
<li>
<a target="_blank" href="${langProps['cesnet_link']}">${langProps['cesnet_name']}</a>
<spring:message code="einfra_link" var="cesnet_link"/>
<a target="_blank" href="${cesnet_link}"><spring:message code="cesnet_name"/></a>
</li>
<li>
<a target="_blank" href="${langProps['cerit_link']}">${langProps['cerit_name']}</a>
<spring:message code="cerit_link" var="cerit_link"/>
<a target="_blank" href="${cerit_link}"><spring:message code="cerit_name"/></a>
</li>
<li>
<a target="_blank" href="${langProps['it4i_link']}">${langProps['it4i_name']}</a>
<spring:message code="it4i_link" var="it4i_link"/>
<a target="_blank" href="${it4i_link}"><spring:message code="it4i_name"/></a>
</li>
<li>
<a target="_blank" href="${langProps['data_processing_link']}">${langProps['data_processing_name']}</a>
<spring:message code="data_processing_link" var="data_processing_link"/>
<a target="_blank" href="${data_processing_link}"><spring:message code="data_processing_name"/></a>
</li>
</ul>
</div>
<div class="col col-sm-6">
<h2>${langProps['footer_helpdesk']}</h2>
<h2><spring:message code="footer_helpdesk"/></h2>
TEL: +420 234 680 222<br>
GSM: +420 602 252 531<br>
<a href="mailto:[email protected]">[email protected]</a>
Expand All @@ -48,9 +54,9 @@
</div>
<div class="row">
<div class="col col-sm-12 copyright">
&copy; 2021 | <a target="_blank" href="${langProps['einfra_link']}">${langProps['einfra_name']}</a>
&copy; 2021 | <a target="_blank" href="${einfra_link}"><spring:message code="einfra_name"/></a>
<%-- USABLE FROM 2022 --%>
<%--&copy; 2021-<fmt:formatDate value="${date}" pattern="yyyy" /> | <a target="_blank" href="${langProps['einfra_link']}">${langProps['einfra_name']}</a>--%>
<%--&copy; 2021-<fmt:formatDate value="${date}" pattern="yyyy" /> | <a target="_blank" href="<spring:message code="einfra_link"/>"><spring:message code="einfra_name"/></a>--%>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ tag pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>

</div>
Expand All @@ -7,8 +8,8 @@
<footer class="footer">
<div class="row-main">
<p class="footer__copyrights">
${langProps['masaryk_university']}<br />
${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>
<spring:message code="masaryk_university"/><br />
<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>
</p>
</div>
</footer>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<%@ tag pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="o" tagdir="/WEB-INF/tags/common" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ attribute name="title" required="true" %>
<%@ attribute name="reqURL" required="true" %>
<%@ attribute name="baseURL" required="true" %>
<%@ attribute name="samlResourcesURL" required="true" %>
<%@ attribute name="cssLinks" required="true" type="java.util.ArrayList<java.lang.String>" %>

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

<title>${langProps['unified_login']} | ${title}</title>
<title><spring:message code="unified_login"/> | ${title}</title>

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

<body>
<c:set var="alternateURL" value="${reqURL}&lang=${langProps['other_lang']}"/>
<c:set var="alternateURL" value="${reqURL}&lang=${other_lang}"/>
<p class="menu-accessibility">
<a title="${langProps['go_to_login_title']}" accesskey="2" href="#main">
${langProps['go_to_login_text']}
<a title="<spring:message code="go_to_login_title"/>" accesskey="2" href="#main">
<spring:message code="go_to_login_text"/>
</a>
</p>
<div class="header u-mb-0">
<div class="row-main">
<div class="header__wrap">
<h1 class="header__logo">
<img src="${samlResourcesURL}/module.php/${theme}/img/${langProps['img_name']}.png"
width="${langProps['img_width']}" height="${langProps['img_height']}" alt="${langProps['muni_logo']}"/>
<spring:message code="muni_logo" var="alt"/>
<img src="${samlResourcesURL}/module.php/${theme}/img/<spring:message code="img_name"/>.png"
width="<spring:message code="img_width"/>" height="<spring:message code="img_height"/>" alt="${alt}"/>
</h1>
<div class="header__side">
<div class="menu-lang" role="navigation">
<p class="menu-lang__selected">
<a href="${alternateURL}" rel="alternate" hreflang="${langProps['other_lang']}"
lang="${langProps['other_lang']}" class="menu-lang__selected__link">
${langProps['other_language']}
<a href="${alternateURL}" rel="alternate" hreflang="${other_lang}"
lang="${other_lang}" class="menu-lang__selected__link">
<spring:message code="other_language"/>
</a>
</p>
</div>
Expand All @@ -63,9 +66,9 @@
<div class="row-main">
<ul class="menu-mobile__list">
<li class="menu-mobile__item">
<a href="${alternateURL}" rel="alternate" hreflang="${langProps['other_lang']}"
class="menu-mobile__link menu-mobile__link--lang" lang="${langProps['other_lang']}">
${langProps['other_language']}
<a href="${alternateURL}" rel="alternate" hreflang="${other_lang}"
class="menu-mobile__link menu-mobile__link--lang" lang="${other_lang}">
<spring:message code="other_language"/>
</a>
</li>
</ul>
Expand Down
Loading

0 comments on commit 6b54337

Please sign in to comment.