Alexander Wels has uploaded a new change for review.

Change subject: engine: no documentation message
......................................................................

engine: no documentation message

- Fixed minor text issue in message, replaced 'pack'
  with the word documentation to be more consistent.
- i18ned the message so they can be translated.
- Applied the branding filter to /docs
- Fixed issue where the locale in the links would have
  an underscore, while the documentation would contain
  a dash. This caused the message to popup even though
  the documentation was installed. Fixed it so it no longer
  matters if the link has an underscore or dash in it,
  both will correctly determine if the language is available.

Change-Id: Iceae0ebf671efc951522c464db1a5b2b95dd5637
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1011430
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1010743
Signed-off-by: Alexander Wels <aw...@redhat.com>
---
M 
backend/manager/modules/root/src/main/java/org/ovirt/engine/core/DocsServlet.java
M backend/manager/modules/root/src/main/webapp/WEB-INF/help/no_lang.jsp
M backend/manager/modules/root/src/main/webapp/WEB-INF/web.xml
M packaging/branding/ovirt.brand/messages.properties
4 files changed, 30 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/48/19848/1

diff --git 
a/backend/manager/modules/root/src/main/java/org/ovirt/engine/core/DocsServlet.java
 
b/backend/manager/modules/root/src/main/java/org/ovirt/engine/core/DocsServlet.java
index 32f5238..a4e8542 100644
--- 
a/backend/manager/modules/root/src/main/java/org/ovirt/engine/core/DocsServlet.java
+++ 
b/backend/manager/modules/root/src/main/java/org/ovirt/engine/core/DocsServlet.java
@@ -45,7 +45,8 @@
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
         } else if (!response.isCommitted()){ //If the response is committed, 
we have already redirected.
             boolean languagePageShown = isLangPageShown(request);
-            if (!file.equals(originalFile)) {
+            if (!file.equals(originalFile) &&
+                    
!file.getAbsolutePath().equals(replaceLocaleWithOtherLocale(originalFile.getAbsolutePath(),
 locale, locale))) {
                 //We determined that we are going to redirect the user to the 
English version URI.
                 String redirect = request.getServletPath() + 
replaceLocaleWithUSLocale(request.getPathInfo(), locale);
                 if (!languagePageShown) {
@@ -110,16 +111,19 @@
     }
 
     private String replaceLocaleWithUSLocale(String originalString, Locale 
locale) {
+        return replaceLocaleWithOtherLocale(originalString, locale, Locale.US);
+    }
+
+    private String replaceLocaleWithOtherLocale(String originalString, Locale 
searchLocale, Locale targetLocale) {
         //Create regex to match either the toString() or toLanguageTag() 
version of the locale
         //For US Locale this means: /en\-US|/en_US
         //For Brazil this means: /pt\-BR|/pt_BR
         //For Japan this means: /ja|/ja (yes I know its the same).
-        String regex = "/"+ locale.toLanguageTag().replaceAll("-", "\\\\-") + 
"|/" + locale.toString();
+        String regex = "/"+ searchLocale.toLanguageTag().replaceAll("-", 
"\\\\-") + "|/" + searchLocale.toString();
         //This will match for instance '/pt-BR/something' and turn it into 
'/en-US/something', but
-        //it will also match '/pt_BR/something' and turn it into 
/'en-US/something'
-        return originalString.replaceAll(regex, "/" + 
Locale.US.toLanguageTag());
+        //it will also match '/pt_BR/something' and turn it into 
'/en-US/something' if targetLocale is en_US.
+        return originalString.replaceAll(regex, "/" + 
targetLocale.toLanguageTag());
     }
-
     /**
      * Determines the locale based on the request passed in. It will first try 
to determine the locale
      * from the referer URI passed. If it can't determine the Locale, it will 
attempt to use the pathinfo
diff --git 
a/backend/manager/modules/root/src/main/webapp/WEB-INF/help/no_lang.jsp 
b/backend/manager/modules/root/src/main/webapp/WEB-INF/help/no_lang.jsp
index 818d4d5..d519452 100644
--- a/backend/manager/modules/root/src/main/webapp/WEB-INF/help/no_lang.jsp
+++ b/backend/manager/modules/root/src/main/webapp/WEB-INF/help/no_lang.jsp
@@ -1,10 +1,14 @@
 <%@ page language="java" contentType="text/html; charset=UTF-8" 
pageEncoding="UTF-8" session="false" %>
 <%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"; prefix="fmt" %>
 <!DOCTYPE html>
 <html>
 <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-       <title>Missing language: <c:out 
value="${requestScope['locale'].getDisplayLanguage()}" /></title>
+       <title><fmt:message key="obrand.docs.missing.title">
+                  <fmt:param 
value="${requestScope['locale'].getDisplayLanguage()}" />
+              </fmt:message>
+       </title>
        <link href="/docs/common/en-US/css/menu.css" type="text/css" 
rel="stylesheet">
 </head>
 <body>
@@ -19,11 +23,15 @@
        <div class="book">
                <div class="titlepage">
                        <div>
-                               <p>It appears that you do not have the <c:out 
value="${requestScope['locale'].getDisplayLanguage()}" /> language pack 
installed.
-                               Please have your administrator install the 
proper language.</p>
                                <p>
-                               Please click <a 
href="${requestScope['englishHref']}">here</a> for the English documentation. 
This message will
-                               only be displayed once per session.
+                                   <fmt:message 
key="obrand.docs.missing.appears">
+                                       <fmt:param 
value="${requestScope['locale'].getDisplayLanguage()}" />
+                                   </fmt:message> 
+                                   <fmt:message 
key="obrand.docs.missing.admin" />
+                               </p>
+                               <p>
+                               <a 
href="${requestScope['englishHref']}"><fmt:message 
key="obrand.docs.missing.click_here" /></a>
+                               <fmt:message 
key="obrand.docs.missing.appear_once" />
                                </p>
                        </div>
                </div>
diff --git a/backend/manager/modules/root/src/main/webapp/WEB-INF/web.xml 
b/backend/manager/modules/root/src/main/webapp/WEB-INF/web.xml
index e0ae418..09e71b1 100644
--- a/backend/manager/modules/root/src/main/webapp/WEB-INF/web.xml
+++ b/backend/manager/modules/root/src/main/webapp/WEB-INF/web.xml
@@ -189,6 +189,7 @@
   <filter-mapping>
     <filter-name>BrandingFilter</filter-name>
     <url-pattern>/ovirt-engine</url-pattern>
+    <url-pattern>/docs/*</url-pattern>
     <dispatcher>REQUEST</dispatcher>
   </filter-mapping>
 
diff --git a/packaging/branding/ovirt.brand/messages.properties 
b/packaging/branding/ovirt.brand/messages.properties
index 4b520c8..7d18527 100644
--- a/packaging/branding/ovirt.brand/messages.properties
+++ b/packaging/branding/ovirt.brand/messages.properties
@@ -62,3 +62,10 @@
 obrand.pagenotfound.page_not_found=Page not found.
 obrand.pagenotfound.link=Click here to continue.
 
+#Missing documenation page
+obrand.docs.missing.appears=It appears that you do not have the {0} 
documentation installed.
+obrand.docs.missing.admin=Please have your administrator install the proper 
documentation.
+obrand.docs.missing.click_here=Please click here for the English documentation.
+obrand.docs.missing.appear_once=This message will only be displayed once per 
session.
+obrand.docs.missing.title=Missing language: {0}
+


-- 
To view, visit http://gerrit.ovirt.org/19848
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iceae0ebf671efc951522c464db1a5b2b95dd5637
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alexander Wels <aw...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to