abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r600234 - /incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Template.java
Date Sun, 02 Dec 2007 04:22:50 GMT
Author: jmsnell
Date: Sat Dec  1 20:22:49 2007
New Revision: 600234

URL: http://svn.apache.org/viewvc?rev=600234&view=rev
Log:
Tweak the bidi formatted output of the template so that the arg is always displayed in logical
order (LTR).

Modified:
    incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Template.java

Modified: incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Template.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Template.java?rev=600234&r1=600233&r2=600234&view=diff
==============================================================================
--- incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Template.java
(original)
+++ incubator/abdera/java/trunk/dependencies/i18n/src/main/java/org/apache/abdera/i18n/templates/Template.java
Sat Dec  1 20:22:49 2007
@@ -79,20 +79,26 @@
       pattern = replace(
         pattern, 
         token, 
-        "{" + forDisplay(token) + "}");
+        forDisplay(token));
     }
     return CharUtils.bidiLRM(pattern);
   }
   
   private static String forDisplay(String token) {
-    //return token.replaceAll("([^{}|]*)", "\u200E$1\u200E");
     String[] splits = token.split("\\|");
-    String d = "";
-    for (String s : splits) {
-      if (d.length() > 0) d+= "|";
-      d += CharUtils.bidiLRM(s);
+    StringBuilder buf = new StringBuilder();
+    buf.append('{');
+    if (splits.length == 1) {
+      buf.append(CharUtils.bidiLRM(splits[0]));
+    } else {
+      buf.append(splits[0]);
+      buf.append('|');
+      buf.append(CharUtils.bidiLRO(splits[1]));
+      buf.append('|');
+      buf.append(CharUtils.bidiLRM(splits[2]));
     }
-    return d;
+    buf.append('}');
+    return buf.toString();
   }
   
   /**
@@ -221,7 +227,7 @@
    StringBuilder buf = new StringBuilder();
    buf.append("Template:");
    buf.append('\n');
-   buf.append("\t"+pattern);
+   buf.append("\t"+getPatternForDisplay());
    buf.append('\n');
    buf.append('\n');
    buf.append(" Variables:");



Mime
View raw message