You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Thielen <da...@windward.net> on 2006/01/23 04:55:53 UTC

RE: bi-di messages and dir="RTL"?

Sending again (it's a work day now in the Middle East).

Thanks - dave

-----Original Message-----
Hi;

Ok, I use a resource file for all text and then put it in the html page
using c:out, etc. But, what about Hebrew & Arabic? They need to be marked
with dir="RTL". I can make the message <span dir="RTL">hi there</span> but
then I can't escape any text and have to make sure I have escaped things in
my messages.

And I have a feeling this could get weird where some of the text on my page
I am pulling from a database and have no idea what it's direction is.

Is there a better way?

Thanks - dave

David Thielen
www.windwardreports.com
303-499-2544


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: bi-di messages and dir="RTL"?

Posted by Paul Benedict <pa...@yahoo.com>.
If you're using a real CSS2 browser like Firefox, you can use CSS to enlarge fonts for the
language you specify:

span[lang='he'] {
font-size: 120%;
}

or maybe something as simple as:
span.rtl {
font-size: 120%;
}

That means you should output <span class="rtl">...</span>

PS: Good idea with the tag library extension. 

Paul


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: bi-di messages and dir="RTL"?

Posted by Daniel Blumenthal <da...@wordchamp.com>.
> Ok, I use a resource file for all text and then put it in the 
> html page using c:out, etc. But, what about Hebrew & Arabic? 
> They need to be marked with dir="RTL". I can make the message 
> <span dir="RTL">hi there</span> but then I can't escape any 
> text and have to make sure I have escaped things in my messages.
> 
> And I have a feeling this could get weird where some of the 
> text on my page I am pulling from a database and have no idea 
> what it's direction is.

My solution is that I have a custom tag, and the internal processing code
looks something like this:

.rtlclass {font-family:David,arial;font-size:12px;direction:rtl}

if (isRTL(myStr)) {
  out.append("<span class='rtlclass'>&rlm;");
  out.append(myStr);
  out.append("&rlm;</span>");
}

public static final boolean isRTL(final String str) {
  for (int i = 0; i < 3; i++) {
    if (str.length() == i)
      return false;

    Character.UnicodeBlock block = Character.UnicodeBlock.of(str.charAt(i));
    if (block == Character.UnicodeBlock.ARABIC ||
        block == Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_A ||
        block == Character.UnicodeBlock.ARABIC_PRESENTATION_FORMS_B ||
        block == Character.UnicodeBlock.HEBREW)
    {
      return true;
    }
  }
  return false;
}

The "&rlm;" on both sides is important because otherwise the browser *will*
screw up if you have punctuation at the end of the string.

Another thing to note is that, for some reason, all browsers tend to render
non-Latin fonts in a very teensy size.  I don't know why.  So it's a good
idea to have code to make sure that rtlclass has a bigger fontsize than you
would normally use.

Daniel




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: bi-di messages and dir="RTL"?

Posted by Paul Benedict <pa...@yahoo.com>.
David, I am not sure what the problem is. How is this any different than LTR text? You could use
<c:out escapeXml="false"> so you don't have to escape anything.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org