slub.team team mailing list archive
-
slub.team team
-
Mailing list archive
-
Message #00271
[Merge] lp:~zeutschel/goobi-production/bug-1020522 into lp:goobi-production
Matthias Ronge has proposed merging lp:~zeutschel/goobi-production/bug-1020522 into lp:goobi-production with lp:~zeutschel/goobi-production/bug-1020966 as a prerequisite.
Requested reviews:
Saxon State Library Team (slub.team)
Related bugs:
Bug #1020522 in Goobi.Production: "improve behaviour of language switch"
https://bugs.launchpad.net/goobi-production/+bug/1020522
For more details, see:
https://code.launchpad.net/~zeutschel/goobi-production/bug-1020522/+merge/113572
This branch provides an improved language handling:
− Languages are represented by their native names (e.g. Deutsch, English, Español, …)
− Available languages listed are those configured in faces-config.xml
− Per default, Goobi.Production starts up with the best matching language depending on the user’s preferred language settings in the web browser.
− Alternatively, a start-up language can be configured in GoobiConfig.properties.
--
https://code.launchpad.net/~zeutschel/goobi-production/bug-1020522/+merge/113572
Your team Saxon State Library Team is requested to review the proposed merge of lp:~zeutschel/goobi-production/bug-1020522 into lp:goobi-production.
=== modified file 'WEB-INF/faces-config.xml'
--- WEB-INF/faces-config.xml 2011-12-20 08:07:09 +0000
+++ WEB-INF/faces-config.xml 2012-07-05 13:08:30 +0000
@@ -30,9 +30,8 @@
<application>
<locale-config>
<default-locale>en</default-locale>
- <supported-locale>de</supported-locale>
- <supported-locale>en</supported-locale>
- <supported-locale>es</supported-locale>
+ <supported-locale>de</supported-locale>
+ <supported-locale>en</supported-locale>
</locale-config>
</application>
=== modified file 'config/GoobiConfig.properties'
--- config/GoobiConfig.properties 2012-05-02 12:02:23 +0000
+++ config/GoobiConfig.properties 2012-07-05 13:08:30 +0000
@@ -67,7 +67,7 @@
# Application title
ApplicationHeaderTitle=Goobi
ApplicationTitle=Goobi 1.6.5
-ApplicationTitleStyle=font-size:17; font-family:verdana; color: white;
+ApplicationTitleStyle=font-size:17px; font-family:verdana; color: white;
# Application website
ApplicationWebsiteUrl=http://gdz.goobi.org/
@@ -79,6 +79,11 @@
ApplicationImpressumMsg=impressumText
ApplicationIndividualHeader=<table><tr><td><a style="color:white" target="_blank" href="http://gdz.sub.uni-goettingen.de/">Webseite des GDZ</a></td></tr><tr><td><a style="color:white" target="_blank" href="http://wiki.goobi.org/">Goobi Wiki</a></td></tr></table>
+# Start-up language: If not set, Goobi.Production will start up with the
+# language best matching the user’s Accept-Languages HTTP Request header.
+# You can override this behaviour by setting a default language here:
+#language.force-default=en
+
# -----------------------------------
# Security settings
# -----------------------------------
=== modified file 'css/default.css'
--- css/default.css 2011-12-20 08:07:09 +0000
+++ css/default.css 2012-07-05 13:08:30 +0000
@@ -77,12 +77,14 @@
}
.layoutKopf {
- color: #434387;
border-style: solid;
border-width: 1px;
border-color: #0083e2;
background-color: #B3D4EF;
}
+.layoutKopf, .layoutKopf a{
+ color: white;
+}
.layoutFuss {
border-style: solid;
@@ -727,3 +729,24 @@
}
.monthYearRowClass{
}
+
+/*
+ ------------------------------------------------------------
+ Language switch
+ ------------------------------------------------------------
+*/
+.languageSwitch span:before {
+ content: "•";
+ padding: 0 4px;
+ font-weight: normal;
+}
+.languageSwitch span:first-child:before {
+ content: "";
+ padding: 0;
+}
+.languageSwitch a:hover {
+ color: white;
+}
+.languageSwitch .currentLanguage {
+ font-weight: bold;
+}
=== modified file 'newpages/Main.jsp'
--- newpages/Main.jsp 2011-12-20 08:07:09 +0000
+++ newpages/Main.jsp 2012-07-05 13:08:30 +0000
@@ -32,6 +32,7 @@
#########################################--%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<f:view locale="#{SpracheForm.locale}">
<%@include file="inc/head.jsp"%>
=== removed file 'newpages/inc/box_Kopf.jsp'
--- newpages/inc/box_Kopf.jsp 2012-04-24 13:22:01 +0000
+++ newpages/inc/box_Kopf.jsp 1970-01-01 00:00:00 +0000
@@ -1,100 +0,0 @@
-<%@ page session="false" contentType="text/html;charset=utf-8"%>
-<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
-<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
-<%@ taglib uri="http://jsftutorials.net/htmLib" prefix="htm"%>
-<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="x"%>
-
-<%--
- ~ This file is part of the Goobi Application - a Workflow tool for the support of
- ~ mass digitization.
- ~
- ~ Visit the websites for more information.
- ~ - http://gdz.sub.uni-goettingen.de
- ~ - http://www.goobi.org
- ~ - http://launchpad.net/goobi-production
- ~
- ~ This program is free software; you can redistribute it and/or modify it under
- ~ the terms of the GNU General Public License as published by the Free Software
- ~ Foundation; either version 2 of the License, or (at your option) any later
- ~ version.
- ~
- ~ This program is distributed in the hope that it will be useful, but WITHOUT ANY
- ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- ~ PARTICULAR PURPOSE. See the GNU General Public License for more details. You
- ~ should have received a copy of the GNU General Public License along with this
- ~ program; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
- ~ Suite 330, Boston, MA 02111-1307 USA
- --%>
-
-<%-- =====================
- ====================== --%>
-<h:form style="width:100%;margin:0px;#{HelperForm.applicationHeaderBackground}" id="headform">
- <h:graphicImage value="#{HelperForm.applicationLogo}" />
-
- <h:commandLink action="#{SpracheForm.SpracheUmschalten}" id="lang1"
- style="position:absolute;top:15px;right:100px;margin:0px;"
- title="deutsche Version">
- <h:graphicImage value="/newpages/images/flag_de_ganzklein.gif" />
- <f:param name="locale" value="de_DE" />
- </h:commandLink>
- <h:commandLink action="#{SpracheForm.SpracheUmschalten}" id="lang2"
- style="position:absolute;top:15px;right:65px;margin:0px"
- title="english version">
- <h:graphicImage value="/newpages/images/flag_en_ganzklein.gif" />
- <f:param name="locale" value="en_GB" />
- </h:commandLink>
- <h:commandLink action="#{SpracheForm.SpracheUmschalten}" id="lang3"
- style="position:absolute;top:15px;right:30px;margin:0px" rendered="true"
- title="russian version">
- <h:graphicImage value="/newpages/images/flag_ru_ganzklein.gif" />
- <f:param name="locale" value="ru_RU" />
- </h:commandLink>
-
-</h:form>
-
-
-<%-- =====================
-
-<htm:table width="100%" styleClass="layoutKopf"
- style="#{HelperForm.applicationHeaderBackground}" cellpadding="0"
- cellspacing="0" border="0">
- <htm:tr valign="top">
- <htm:td width="20%" >
- <h:graphicImage value="#{HelperForm.applicationLogo}" />
- </htm:td>
- <htm:td valign="middle" align="center">
-
- <h:outputText style="#{HelperForm.applicationTitleStyle}"
- value="#{HelperForm.applicationTitle}" />
-
- <htm:noscript>
- <h:outputText style="color: red;font-weight: bold;"
- value="#{msgs.keinJavascript}" />
- </htm:noscript>
-
- </htm:td>
- <htm:td valign="middle" width="20%" align="right" style="padding:3px">
- <h:form style="margin:0px">
- <h:panelGrid columns="3">
- <h:commandLink action="#{SpracheForm.SpracheUmschalten}"
- title="deutsche Version">
- <h:graphicImage value="/newpages/images/flag_de_ganzklein.gif" />
- <f:param name="locale" value="de_DE" />
- </h:commandLink>
- <h:commandLink action="#{SpracheForm.SpracheUmschalten}"
- title="english version">
- <h:graphicImage value="/newpages/images/flag_en_ganzklein.gif" />
- <f:param name="locale" value="en_GB" />
- </h:commandLink>
- <h:commandLink action="#{SpracheForm.SpracheUmschalten}"
- rendered="true" title="russian version">
- <h:graphicImage value="/newpages/images/flag_ru_ganzklein.gif" />
- <f:param name="locale" value="ru_RU" />
- </h:commandLink>
- </h:panelGrid>
- </h:form>
- </htm:td>
- </htm:tr>
-</htm:table>
- ====================== --%>
-
=== modified file 'newpages/inc/tbl_Kopf.jsp'
--- newpages/inc/tbl_Kopf.jsp 2012-07-05 13:08:30 +0000
+++ newpages/inc/tbl_Kopf.jsp 2012-07-05 13:08:30 +0000
@@ -73,25 +73,31 @@
</htm:td>
- <htm:td valign="top" align="right" style="padding: 3 3 0 0">
+ <htm:td valign="middle" align="right" style="padding-right: 3px">
<h:form style="margin:0px" id="headform">
- <h:commandLink action="#{SpracheForm.SpracheUmschalten}" id="lang1"
- title="deutsche Version">
- <h:graphicImage value="/newpages/images/flag_de_ganzklein.gif" />
- <f:param name="locale" value="de" />
- </h:commandLink>
- <h:commandLink action="#{SpracheForm.SpracheUmschalten}" id="lang2"
- title="english version">
- <h:graphicImage value="/newpages/images/flag_en_ganzklein.gif" />
- <f:param name="locale" value="en" />
- </h:commandLink>
- <h:commandLink action="#{SpracheForm.SpracheUmschalten}" id="lang3"
- rendered="false" title="russian version">
- <h:graphicImage value="/newpages/images/flag_ru_ganzklein.gif" />
- <f:param name="locale" value="ru" />
- </h:commandLink>
- <htm:br/>
+
+ <%-- First call to h:commandLink renders an <input type="hidden" name="autoScroll" />
+ element surrounded by new line characters which would result in additional white
+ space after the first link. This empty link will fix that problem: --%>
+ <h:commandLink/>
+
+ <htm:div styleClass="languageSwitch">
+ <x:dataList var="availableLanguage" value="#{SpracheForm.supportedLocales}">
+ <htm:span styleClass="alterLanguage" rendered="#{not availableLanguage.selected}">
+ <h:commandLink action="#{SpracheForm.SpracheUmschalten}"
+ title="#{availableLanguage.displayLanguageTranslated}">
+ <f:param name="locale" value="#{availableLanguage.id}" />
+ <h:outputText value="#{availableLanguage.displayLanguageSelf}" />
+ </h:commandLink>
+ </htm:span>
+ <htm:span styleClass="currentLanguage" rendered="#{availableLanguage.selected}"
+ title="#{availableLanguage.displayLanguageTranslated}">
+ <h:outputText value="#{availableLanguage.displayLanguageSelf}"/>
+ </htm:span>
+ </x:dataList>
+ </htm:div>
+
<%-- logout --%>
<h:commandLink action="#{LoginForm.Ausloggen}" id="logout2"
rendered="#{LoginForm.myBenutzer != null}"
=== modified file 'pages/Metadaten2oben.jsp'
--- pages/Metadaten2oben.jsp 2012-07-05 13:08:30 +0000
+++ pages/Metadaten2oben.jsp 2012-07-05 13:08:30 +0000
@@ -90,6 +90,7 @@
<h:outputText />
</h:panelGrid>
</htm:td>
+<%--
<htm:td width="105px" align="right" valign="middle"
style="padding:3px">
<x:inputText rendered="false" id="treeReload" forceId="true" />
@@ -120,6 +121,7 @@
<f:param name="ziel" value="Metadaten2rechts" />
</h:commandLink>
</htm:td>
+--%>
</htm:tr>
</htm:table>
</htm:td>
=== modified file 'src/de/sub/goobi/forms/SpracheForm.java'
--- src/de/sub/goobi/forms/SpracheForm.java 2012-07-05 13:08:30 +0000
+++ src/de/sub/goobi/forms/SpracheForm.java 2012-07-05 13:08:30 +0000
@@ -22,10 +22,16 @@
package de.sub.goobi.forms;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import java.util.Locale;
+import java.util.Map;
import javax.faces.context.FacesContext;
+import de.sub.goobi.config.ConfigMain;
import de.sub.goobi.helper.Helper;
/**
@@ -33,23 +39,73 @@
* user in the running application
*/
public class SpracheForm {
- private Locale locale;
/**
- * The constructor of this class sets the locale to the first available
- * value and loads the required MessageBundle
+ * The constructor of this class loads the required MessageBundle
*/
public SpracheForm() {
- while (FacesContext.getCurrentInstance().getApplication()
- .getSupportedLocales().hasNext()) {
- locale = (Locale) FacesContext.getCurrentInstance()
- .getApplication().getSupportedLocales().next();
- break;
+ String p = ConfigMain.getParameter("language.force-default");
+ if(p != null && p.length() > 0){
+ FacesContext.getCurrentInstance().getViewRoot().setLocale(new Locale(p));
}
- FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
}
/**
+ * The function getSupportedLocales() returns a list of maps, each
+ * representing one locale configured in the faces-config.xml file. Each of
+ * the maps will contain the fields
+ *
+ * id − the locale’s ID String, e.g. “fr” or
+ * “en_GB”
+ *
+ * displayLanguageSelf − the name of the language in the
+ * language itself, e.g. “English”,
+ * “Deutsch”, “français”, “español”,
+ * “русский”, “日本語”, …
+ *
+ * It’s a good practice to identify a language in its own spelling, since
+ * this will be most likely what a speaker of that language will recognize.
+ * See also: http://www.cs.tut.fi/~jkorpela/flags.html
+ * Note that capitalisation is subject to the respective language. If the
+ * language is unknown, the id will be returned.
+ *
+ * displayLanguageTranslated − the name of the language in the
+ * currently selected language, e.g., if
+ * the current language is English:
+ * “English”, “German”, “French”, …
+ *
+ * This is just a nice feature because the language names are provided by
+ * Java; and it’s used in the mouse-over titles, so you can find out what
+ * e.g. “हिंदी” means, even if you don’t have a clue of the glyphs used. If
+ * no translations are available, this will fall back to English.
+ *
+ * selected − whether this is the current language
+ *
+ * This can be used for a sophisticated layout.
+ *
+ * @return a list of maps, each with the fields “id”, “displayName” and
+ * “selected”
+ */
+ public List<Map<String, Object>> getSupportedLocales() {
+ List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
+ Locale currentDisplayLanguage = FacesContext.getCurrentInstance().getViewRoot().getLocale();
+ @SuppressWarnings("unchecked") // It seems we have an old Faces API, Faces 2.1’s getSupportedLocales() returns Iterator<Locale> → TODO: Update JSF API
+ Iterator<Locale> localesIterator = FacesContext.getCurrentInstance().getApplication().getSupportedLocales();
+ while (localesIterator.hasNext()) {
+ Locale supportedLocale = localesIterator.next();
+ if (supportedLocale.getLanguage().length() > 0) {
+ Map<String, Object> translation = new HashMap<String, Object>();
+ translation.put("id", supportedLocale.toString());
+ translation.put("displayLanguageSelf", supportedLocale.getDisplayLanguage(supportedLocale));
+ translation.put("displayLanguageTranslated", supportedLocale.getDisplayLanguage(currentDisplayLanguage));
+ translation.put("selected", Boolean.valueOf(supportedLocale.equals(currentDisplayLanguage)));
+ result.add(translation);
+ }
+ }
+ return result;
+ }
+
+ /**
* The procedure switchLanguage is used to alter the application’s interface
* language.
*
@@ -59,6 +115,7 @@
*/
public void switchLanguage(String langCodeCombined) {
String[] languageCode = langCodeCombined.split("_");
+ Locale locale = null;
if (languageCode.length == 2) {
locale = new Locale(languageCode[0], languageCode[1]);
} else {
@@ -81,6 +138,6 @@
}
public Locale getLocale() {
- return locale;
+ return FacesContext.getCurrentInstance().getViewRoot().getLocale();
}
}
Follow ups