Localized texts for Admin UI

Jens Pelzetter 2020-09-22 20:07:29 +02:00
parent 732295b2fe
commit f8a0079be7
16 changed files with 239 additions and 40 deletions

View File

@ -0,0 +1,45 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.ui;
import org.libreccm.l10n.GlobalizationHelper;
import java.util.Locale;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mvc.locale.LocaleResolver;
import javax.mvc.locale.LocaleResolverContext;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class MvcLocaleResolver implements LocaleResolver {
@Inject
private GlobalizationHelper globalizationHelper;
@Override
public Locale resolveLocale(final LocaleResolverContext context) {
return globalizationHelper.getNegotiatedLocale();
}
}

View File

@ -0,0 +1,79 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.ui.admin;
import org.libreccm.l10n.GlobalizationHelper;
import java.util.AbstractMap;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
@Named("AdminMessages")
public class AdminMessages extends AbstractMap<String, String> {
@Inject
private GlobalizationHelper globalizationHelper;
private ResourceBundle messages;
@PostConstruct
private void init() {
messages = ResourceBundle.getBundle(
AdminConstants.ADMIN_BUNDLE,
globalizationHelper.getNegotiatedLocale()
);
}
public String getMessage(final String key) {
if (messages.containsKey(key)) {
return messages.getString(key);
} else {
return "???key???";
}
}
public String get(final String key) {
return getMessage(key);
}
@Override
public Set<Entry<String, String>> entrySet() {
return messages
.keySet()
.stream()
.collect(
Collectors.toMap(key -> key, key-> messages.getString(key))
)
.entrySet();
}
}

View File

@ -67,7 +67,7 @@ public class ApplicationsPage implements AdminPage {
@Override
public String getIcon() {
return "journals";
return "puzzle";
}
@Override

View File

@ -66,7 +66,7 @@ public class SitesPage implements AdminPage {
@Override
public String getIcon() {
return "bookshelf";
return "collection";
}
@Override

View File

@ -23,7 +23,9 @@ import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mvc.Controller;
import javax.mvc.MvcContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@ -36,6 +38,9 @@ import javax.ws.rs.Path;
@Path("/systeminformation")
public class SystemInformationController {
@Inject
private MvcContext mvc;
@GET
@Path("/")
@AuthorizationRequired

View File

@ -4,13 +4,22 @@
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="applications" />
<ui:param name="title" value="System Information" />
<ui:param name="title" value="#{AdminMessages['applications.label']}" />
<ui:define name="breadcrumb">
<li class="breadcrumb-item active">
#{AdminMessages['applications.label']}
</li>
</ui:define>
<ui:define name="main">
<div class="container">
<h1>Applications</h1>
<h1>#{AdminMessages['applications.label']}</h1>
<p>Placeholder</p>
</div>
</ui:define>
</ui:composition>
</html>

View File

@ -4,13 +4,22 @@
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="categories" />
<ui:param name="title" value="Categories" />
<ui:param name="title" value="#{AdminMessages['categories.label']}" />
<ui:define name="breadcrumb">
<li class="breadcrumb-item active">
#{AdminMessages['categories.label']}
</li>
</ui:define>
<ui:define name="main">
<div class="container">
<h1>Categories</h1>
<h1>#{AdminMessages['categories.label']}</h1>
<p>Placeholder</p>
</div>
</ui:define>
</ui:composition>
</html>

View File

@ -44,6 +44,16 @@
</ul>
</div>
</nav>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="#{request.contextPath}/@admin/">
#{AdminMessages['breadcrumbs.start']}
</a>
</li>
<ui:insert name="breadcrumb"></ui:insert>
</ol>
</nav>
</header>
<main>
<ui:insert name="main"></ui:insert>

View File

@ -4,13 +4,22 @@
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="configuration" />
<ui:param name="title" value="Configuration" />
<ui:param name="title" value="#{AdminMessages['configuration.label']}" />
<ui:define name="breadcrumb">
<li class="breadcrumb-item active">
#{AdminMessages['configuration.label']}
</li>
</ui:define>
<ui:define name="main">
<div class="container">
<h1>Configuration</h1>
<h1>#{AdminMessages['configuration.label']}</h1>
<p>Placeholder</p>
</div>
</ui:define>
</ui:composition>
</html>

View File

@ -4,13 +4,19 @@
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="/" />
<ui:param name="title" value="Dashboard" />
<ui:param name="title" value="#{AdminMessages['dashboard.label']}" />
<ui:define name="breadcrumb">
</ui:define>
<ui:define name="main">
<div class="container">
<h1>LibreCCM Admin Dashboard</h1>
<h1>#{AdminMessages['dashboard.label']}</h1>
<p>Placeholder</p>
</div>
</ui:define>
</ui:composition>
</html>

View File

@ -4,13 +4,22 @@
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="imexport" />
<ui:param name="title" value="Import/Export" />
<ui:param name="title" value="#{AdminMessages['imexport.label']}" />
<ui:define name="breadcrumb">
<li class="breadcrumb-item active">
#{AdminMessages['imexport.label']}
</li>
</ui:define>
<ui:define name="main">
<div class="container">
<h1>Import/Export</h1>
<h1>#{AdminMessages['imexport.label']}</h1>
<p>Placeholder</p>
</div>
</ui:define>
</ui:composition>
</html>

View File

@ -4,13 +4,23 @@
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="sites" />
<ui:param name="title" value="Sites" />
<ui:param name="title" value="#{AdminMessages['sites.label']}" />
<ui:define name="breadcrumb">
<li class="breadcrumb-item active">
#{AdminMessages['sites.label']}
</li>
</ui:define>
<ui:define name="main">
<div class="container">
<h1>Sites</h1>
<h1>#{AdminMessages['sites.label']}</h1>
<p>Placeholder</p>
</div>
</ui:define>
</ui:composition>
</html>

View File

@ -4,11 +4,21 @@
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="systeminformation" />
<ui:param name="title" value="System Information" />
<ui:param name="title"
value="#{AdminMessages['systeminformation.label']}"
/>
<ui:define name="breadcrumb">
<li class="breadcrumb-item active">
#{AdminMessages['systeminformation.label']}
</li>
</ui:define>
<ui:define name="main">
<div class="container">
<h1>System Information</h1>
<h1>#{AdminMessages['systeminformation.label']}</h1>
<ul class="nav nav-tabs"
id="systeminformation-tabs"
role="tablist">
@ -20,7 +30,7 @@
role="tab"
aria-controls="ccminfo"
aria-selected="true">
LibreCCM System Information
#{AdminMessages['systeminformation.tabs.libreccm.label']}
</a>
</li>
<li class="nav-item" role="presentation">
@ -31,7 +41,7 @@
role="tab"
aria-controls="javainfo"
aria-selected="false">
Java System Properties
#{AdminMessages['systeminformation.tabs.java.label']}
</a>
</li>
</ul>
@ -42,7 +52,7 @@
role="tabpanel"
aria-labelled="LibreCCM System Information Tab"
>
<h2>LibreCCM System Information</h2>
<h2>AdminMessages['systeminformation.tabs.libreccm.label']</h2>
<dl>
<c:forEach items="#{SystemInformationModel.ccmSystemInformation}"
var="prop">
@ -58,7 +68,7 @@
role="tabpanel"
aria-labelled="Java System Properties Tab"
>
<h2>Java System Properties</h2>
<h2>#{AdminMessages['systeminformation.tabs.java.label']}</h2>
<dl>
<c:forEach items="#{SystemInformationModel.javaSystemProperties}"
var="prop">
@ -70,23 +80,6 @@
</dl>
</div>
</div>
<!--
<ul class="nav nav-tabs" id="myTab" role="tablist">
<li class="nav-item" role="presentation">
<a class="nav-link active" id="home-tab" data-toggle="tab" href="#home" role="tab" aria-controls="home" aria-selected="true">Home</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="profile-tab" data-toggle="tab" href="#profile" role="tab" aria-controls="profile" aria-selected="false">Profile</a>
</li>
<li class="nav-item" role="presentation">
<a class="nav-link" id="contact-tab" data-toggle="tab" href="#contact" role="tab" aria-controls="contact" aria-selected="false">Contact</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab">...</div>
<div class="tab-pane fade" id="profile" role="tabpanel" aria-labelledby="profile-tab">...</div>
<div class="tab-pane fade" id="contact" role="tabpanel" aria-labelledby="contact-tab">...</div>
</div>-->
</div>
</ui:define>
</ui:composition>

View File

@ -4,13 +4,22 @@
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="usersgroupsroles" />
<ui:param name="title" value="Users/Groups/Roles" />
<ui:param name="title" value="#{AdminMessages['usersgroupsroles.label']}" />
<ui:define name="breadcrumb">
<li class="breadcrumb-item active">
#{AdminMessages['usersgroupsroles.label']}
</li>
</ui:define>
<ui:define name="main">
<div class="container">
<h1>Users/Groups/Roles</h1>
<h1>#{AdminMessages['usersgroupsroles.label']}</h1>
<p>Placeholder</p>
</div>
</ui:define>
</ui:composition>
</html>

View File

@ -14,3 +14,6 @@ sites.label=Sites
sites.description=Manage sites
usersgroupsroles.label=Users/Groups/Roles
usersgroupsroles.description=Manage users, groups and roles
systeminformation.tabs.libreccm.label=LibreCCM System Information
systeminformation.tabs.java.label=Java System Properties
breadcrumbs.start=LibreCCM Admin

View File

@ -5,7 +5,7 @@ applications.description=Verwalten der Anwendungsinstanzen
imexport.label=Import/Export
categories.label=Kategorien
categories.description=Verwaltung der Kategorien
configuration.label=Configuration
configuration.label=Konfguration
configuration.description=Bearbeiten der Konfiguration
dashboard.label=Dashboard
dashboard.description=Provides access to all applications
@ -14,3 +14,6 @@ sites.label=Sites
sites.description=Sites verwalten
usersgroupsroles.label=Benutzer*innen/Gruppen/Rollen
usersgroupsroles.description=Verwaltungen von Benutzer*innen, Gruppen und Rollen
systeminformation.tabs.libreccm.label=LibreCCM System Informationen
systeminformation.tabs.java.label=Java System Properties
breadcrumbs.start=LibreCCM Admin