Alexander Wels has uploaded a new change for review.

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

engine: no documentation message

- 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: Ic70eb10eb0264857568028f8307df4408dd36922
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1011430
Signed-off-by: Alexander Wels <aw...@redhat.com>
---
M 
backend/manager/modules/root/src/main/java/org/ovirt/engine/core/DocsServlet.java
1 file changed, 9 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/05/20105/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


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic70eb10eb0264857568028f8307df4408dd36922
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