You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by hn...@apache.org on 2023/08/23 12:11:53 UTC
[myfaces-tobago] branch tobago-5.x updated: fix(localization): severity names and aria label
This is an automated email from the ASF dual-hosted git repository.
hnoeth pushed a commit to branch tobago-5.x
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
The following commit(s) were added to refs/heads/tobago-5.x by this push:
new fed0446892 fix(localization): severity names and aria label
fed0446892 is described below
commit fed044689200a471dbacbc947233902b8dc1f6a2
Author: Henning Noeth <hn...@apache.org>
AuthorDate: Wed Aug 23 13:06:08 2023 +0200
fix(localization): severity names and aria label
* add localization for severity names
* refactor display of multiple messages for components to fit better with localization
* add localization for alert close buttons
* use Aria.LABEL instead of Aria.ACTIVEDESCENDANT because of the current Bootstrap example
* add localization for navigation toggle
Issue: TOBAGO-2247
---
.../internal/renderkit/renderer/BarRenderer.java | 3 +-
.../renderer/DecorationPositionRendererBase.java | 37 ++++++++++------------
.../renderkit/renderer/MessagesRenderer.java | 3 +-
.../tobago/context/TobagoResourceBundle.properties | 6 ++++
.../context/TobagoResourceBundle_de.properties | 6 ++++
.../context/TobagoResourceBundle_es.properties | 6 ++++
6 files changed, 38 insertions(+), 23 deletions(-)
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/BarRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/BarRenderer.java
index efb36a8891..a7cbf63715 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/BarRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/BarRenderer.java
@@ -32,6 +32,7 @@ import org.apache.myfaces.tobago.renderkit.html.HtmlButtonTypes;
import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
import org.apache.myfaces.tobago.renderkit.html.HtmlRoleValues;
import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.ResourceUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import javax.faces.component.UIComponent;
@@ -141,7 +142,7 @@ public class BarRenderer<T extends AbstractUIBar> extends RendererBase<T> {
writer.writeAttribute(DataAttributes.TARGET, "#" + navbarId, true);
writer.writeAttribute(Arias.EXPANDED, Boolean.FALSE.toString(), false);
writer.writeAttribute(Arias.CONTROLS, navbarId, false);
- writer.writeAttribute(Arias.LABEL, "Toggle navigation", false);
+ writer.writeAttribute(Arias.LABEL, ResourceUtils.getString(facesContext, "bar.toggleNavigation"), false);
writer.startElement(HtmlElements.SPAN);
writer.writeClassAttribute(BootstrapClass.NAVBAR_TOGGLER_ICON);
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecorationPositionRendererBase.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecorationPositionRendererBase.java
index accb64c6f4..1822d093bd 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecorationPositionRendererBase.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/DecorationPositionRendererBase.java
@@ -115,7 +115,7 @@ public abstract class DecorationPositionRendererBase<T extends UIComponent & Sup
switch (messagePosition) {
case buttonLeft:
final CssItem buttonColor = BootstrapClass.buttonColor(severity);
- encodePopover(writer, buttonColor, Icons.EXCLAMATION_LG, getTitle(messages), message, tabIndex);
+ encodePopover(writer, buttonColor, Icons.EXCLAMATION_LG, getTitle(facesContext, messages), message, tabIndex);
break;
case textTop:
final CssItem feedback = BootstrapClass.feedbackColor(severity);
@@ -150,7 +150,7 @@ public abstract class DecorationPositionRendererBase<T extends UIComponent & Sup
switch (messagePosition) {
case buttonRight:
final CssItem buttonColor = BootstrapClass.buttonColor(severity);
- encodePopover(writer, buttonColor, Icons.EXCLAMATION_LG, getTitle(messages), message, tabIndex);
+ encodePopover(writer, buttonColor, Icons.EXCLAMATION_LG, getTitle(facesContext, messages), message, tabIndex);
break;
case tooltip:
final CssItem tooltip = BootstrapClass.tooltipColor(severity);
@@ -203,12 +203,17 @@ public abstract class DecorationPositionRendererBase<T extends UIComponent & Sup
protected abstract void encodeEndField(FacesContext facesContext, T component) throws IOException;
- private String getTitle(final List<FacesMessage> messages) {
+ private String getTitle(FacesContext facesContext, final List<FacesMessage> messages) {
int fatalCount = 0;
int errorCount = 0;
int warningCount = 0;
int informationCount = 0;
+ final String fatal = ResourceUtils.getString(facesContext, "severity.fatal");
+ final String error = ResourceUtils.getString(facesContext, "severity.error");
+ final String warn = ResourceUtils.getString(facesContext, "severity.warn");
+ final String info = ResourceUtils.getString(facesContext, "severity.info");
+
for (final FacesMessage message : messages) {
if (FacesMessage.SEVERITY_FATAL.equals(message.getSeverity())) {
fatalCount++;
@@ -225,8 +230,7 @@ public abstract class DecorationPositionRendererBase<T extends UIComponent & Sup
if (messages.size() > 1) {
if (fatalCount > 0) {
- stringBuilder.append(fatalCount);
- stringBuilder.append(" Fatal");
+ stringBuilder.append(fatal).append(" (").append(fatalCount).append(")");
if (errorCount + warningCount + informationCount > 0) {
stringBuilder.append(", ");
@@ -234,11 +238,7 @@ public abstract class DecorationPositionRendererBase<T extends UIComponent & Sup
}
if (errorCount > 0) {
- stringBuilder.append(errorCount);
- stringBuilder.append(" Error");
- if (errorCount > 1) {
- stringBuilder.append("s");
- }
+ stringBuilder.append(error).append(" (").append(errorCount).append(")");
if (warningCount + informationCount > 0) {
stringBuilder.append(", ");
@@ -246,11 +246,7 @@ public abstract class DecorationPositionRendererBase<T extends UIComponent & Sup
}
if (warningCount > 0) {
- stringBuilder.append(warningCount);
- stringBuilder.append(" Warning");
- if (warningCount > 1) {
- stringBuilder.append("s");
- }
+ stringBuilder.append(warn).append(" (").append(warningCount).append(")");
if (informationCount > 0) {
stringBuilder.append(", ");
@@ -258,18 +254,17 @@ public abstract class DecorationPositionRendererBase<T extends UIComponent & Sup
}
if (informationCount > 0) {
- stringBuilder.append(informationCount);
- stringBuilder.append(" Information");
+ stringBuilder.append(info).append(" (").append(informationCount).append(")");
}
} else {
if (fatalCount == 1) {
- stringBuilder.append("Fatal");
+ stringBuilder.append(fatal);
} else if (errorCount == 1) {
- stringBuilder.append("Error");
+ stringBuilder.append(error);
} else if (warningCount == 1) {
- stringBuilder.append("Warning");
+ stringBuilder.append(warn);
} else if (informationCount == 1) {
- stringBuilder.append("Information");
+ stringBuilder.append(info);
}
}
return stringBuilder.toString();
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/MessagesRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/MessagesRenderer.java
index a7b21e6db2..824a743f47 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/MessagesRenderer.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/MessagesRenderer.java
@@ -31,6 +31,7 @@ import org.apache.myfaces.tobago.renderkit.html.HtmlElements;
import org.apache.myfaces.tobago.renderkit.html.HtmlInputTypes;
import org.apache.myfaces.tobago.renderkit.html.HtmlRoleValues;
import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.apache.myfaces.tobago.util.ResourceUtils;
import org.apache.myfaces.tobago.webapp.TobagoResponseWriter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -96,7 +97,7 @@ public class MessagesRenderer<T extends AbstractUIMessages> extends RendererBase
writer.writeAttribute(HtmlAttributes.TYPE, HtmlButtonTypes.BUTTON);
writer.writeClassAttribute(BootstrapClass.BTN_CLOSE);
writer.writeAttribute(DataAttributes.DISMISS, "alert", false);
- writer.writeAttribute(Arias.ACTIVEDESCENDANT, "Close", false); // todo: i18n
+ writer.writeAttribute(Arias.LABEL, ResourceUtils.getString(facesContext, "alert.close"), false);
writer.endElement(HtmlElements.BUTTON);
}
diff --git a/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle.properties b/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle.properties
index 403a664a2d..a1cb457232 100644
--- a/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle.properties
+++ b/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle.properties
@@ -17,6 +17,8 @@ object.noframe=Your user agent does not support frames or is currently configure
However, you may visit the related document manually:
page.noscript=This site requires JavaScript, but JavaScript is currently not activated in your browser. \
To enable JavaScript you may consult your browsers the documentation.
+alert.close=Close
+bar.toggleNavigation=Toggle navigation
sheet.ascending=Ascending
sheet.descending=Descending
sheet.first=First Page
@@ -43,3 +45,7 @@ date.today=Today
date.cancel=Cancel
date.clear=Clear
date.week=Week
+severity.fatal=Fatal
+severity.error=Error
+severity.warn=Warning
+severity.info=Information
diff --git a/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle_de.properties b/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle_de.properties
index 64d7c5457d..0d87cc47d6 100644
--- a/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle_de.properties
+++ b/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle_de.properties
@@ -16,6 +16,8 @@
object.noframe=Ihr Browser stellt keine Frames dar. Den Inhalt k\u00F6nnen Sie hier erreichen:
page.noscript=Diese Seite ben\u00F6tigt JavaScript, allerdings ist JavaScript in Ihrem Browser derzeit deaktiviert. \
Um JavaScript zu aktivieren, lesen Sie ggf. die Anleitung Ihres Browsers.
+alert.close=Schlie�en
+bar.toggleNavigation=Navigation umschalten
sheet.ascending=aufsteigend sortiert
sheet.descending=absteigend sortiert
sheet.first=erste Seite
@@ -42,3 +44,7 @@ date.today=Heute
date.cancel=Abbrechen
date.clear=L\u00F6schen
date.week=Woche
+severity.fatal=Fatal
+severity.error=Fehler
+severity.warn=Warnung
+severity.info=Information
diff --git a/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle_es.properties b/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle_es.properties
index 4a13c86172..92a33c6465 100644
--- a/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle_es.properties
+++ b/tobago-core/src/main/resources/org/apache/myfaces/tobago/context/TobagoResourceBundle_es.properties
@@ -17,6 +17,8 @@ object.noframe=Tu navegador no soporta frames o est\u00E1 configurado para no de
Como sea, puedes visitar el documento relacionado:
page.noscript=Esta p\u00E1gina requiere JavaScript, pero JavaScript no se activa actualmente en su navegador. \
Para permitir JavaScript usted puede consultar la documentaci\u00F3n del navegador.
+alert.close=Cerrar
+bar.toggleNavigation=Alternar navegaci\u00F3n
sheet.ascending=Ascendente
sheet.descending=Descendente
sheet.first=Primera P\u00E1gina
@@ -43,3 +45,7 @@ date.today=Hoy
date.cancel=Cancelar
date.clear=Borrar
date.week=Semana
+severity.fatal=Fatal
+severity.error=Error
+severity.warn=Advertencia
+severity.info=informaci\u00F3n