SmoothCriminel
SmoothCriminel

Reputation: 367

Struts2 + Internationalization + Arabic + English + {RTL or LTR}

I am still struggling with formatting (LTR or RTL) the output with respect to language English or Arabic.

Lets take simple one tag of "struts-tag" library:

<s:textfield key="_do._toTime" value="00:00" maxlength="5"/>

Now I want that when locale is "English" it should print "LTR" but when locale is "Arabic" it should print "RTL".

I read some where that its possible but couldn't find any concrete example that how to achieve this?

Any idea?

BR SC

Upvotes: 1

Views: 1082

Answers (1)

Steven Benitez
Steven Benitez

Reputation: 11055

I see that you were on the right track in your previous question: Struts2 + Internationalization + Java

The easiest way to adapt BalusC's example is to add a getDirection() method to your action which returns either "ltr" or "rtl".

public String getDirection() {
    return getText("this.direction");
}

Then, in your JSP:

<html dir="${action.direction}">

That will trigger the getDirection() method on your action, which will return the value of this.direction in your bundle.

Upvotes: 0

Related Questions