Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Bilingual JSP application

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I am developing a web application in jsp in weblogic 8.1. I am trying to make it bilingual i.e english - arabic.i had created a properties file for english and arabic keywords, located in the same location where my jsp file is , and i was tried to retreive the bundle using
String lang = request.getParameter("lang");
Locale locale = null;
if(lang.equals("Arabic"))
locale = new Locale("ar","AE");
else
locale = Locale.US;
ResourceBundle bundle = ResourceBundle.getBundle("Messages",locale);
and the jsp code is
<form action="Lang.do" method="post">
<td style="font-size:12pt;color:#000099;"><b>Select Language اختيار اللغة</b></td>
<td><br>
<select name="lang">
<option value="English" selected>English
<option value="Arabic">Arabic
</select>
</td>
<td><netui:imageButton src="resources/images/go.gif"></netui:imageButton></td>
</form>
also i have created 3 files for this
Messages.properties,Messages_en_US.properties,Messages_ar_AE.properties.
However everytime i make a selection from the list i get the error message
Can't find bundle for base name Messages.properties, locale ar_AE
I urgently need to make it bilingual. Please help, and correct me if i am using the wrong approach.
Regards,
Sowmya
[ December 15, 2003: Message edited by: Bear Bibeault ]
 
Sheriff
Posts: 67592
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch Sowmya DP!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
In particular, your display name must consist of a first name followed by a last name separated by a space character. The first name may be an initial or abbreviation, but the last name cannot.
Thanks!
bear
JSP Fourm Bartender
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error is due to the fact that expected resource file is unavailable. I am not too sure but try renaming the property files as Messages.properties,Messages_en.properties,Messages_ar.properties.
Also see this.
 
Sowmya Dhilip
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Yash,
Thanks for the suggestion, i relocated the files to WEB-INF/classes and it picked up the keys from there, but it does not display the fonts in arabic.
if i open the properties file in notepad, it displays the key values in arabic, but not when i open it in weblogic workshop.
the approach i am using is as follows.
<%
String lang = request.getParameter("lang");
System.out.println(lang);
if(lang==null)
{
session.setAttribute("currPage","Login");

%>
<html>
<head>
<title>
Dubai Municipality - Login
</title>
</head>
<body background="/DubaiM/resources/images/bg_logo1.gif" bgproperties="fixed" style="font-family:times new roman;">
<jsp:include page="Header.jsp" />
<br><br><br><br>
<center>
<table bgcolor=#CAE1FF cellspacing=1 width=320 style="border-style ouble;border-width:2px;border-color:#000099;" bordercolor=darkblue border="1">
<netui:form action="login" tagId="login" >
<tr>
<th colspan="3" align=center><font size = +1 style="color:#000099;">FileNet System</font></th>
<tr>
<tr>
<td><font style="color:#000099;">
<b>User Name</b>
</font></td><td>
<netui:textBox tagId="user_name" dataSource="{actionForm.user_name}"></netui:textBox>
</td>
<td rowspan="3" align="center">
<netui:image src="/DubaiM/resources/images/key.gif" align="center"></netui:image>
</td>
</tr>
<tr>
<td><font style="color:#000099;">
<b>Password</b>
</font></td>
<td>
<netui:textBox tagId="password" dataSource="{actionForm.password}" password="true"></netui:textBox>
</td>
</tr>
<tr>
<td align=center colspan=2>
<netui:button type="submit" value="Login" action="login" tagId="login" style="background-color:#cae1ff;font-size:13pt;color:#000099;"></netui:button>
  
<netui:button type="reset" value="Clear" action="login" tagId="reset" style="background-color:#cae1ff;font-size:13pt;color:#000099;"></netui:button>
</td>
</tr>
</netui:form>
</table></center>
<br>
<center><b><font size="+4" color="#000099" style="color:#000099;">Dubai Municipality</font></b>
<br>

<table width="300">
<tr>
<form action="Login.jsp" method="post">
<td style="font-size:12pt;color:#000099;"><b>Select Language  اختيار اللغة</b></td>
<td><br>
<select name="lang">
<option value="English" selected>English
<option value="Arabic">Arabic
</select>
</td>
<td><netui:imageButton src="resources/images/go.gif"></netui:imageButton></td>
</form>
</tr>
</table></center>
<br>
<jsp:include page="Footer.jsp" />
</body>
</html>
<%
}
else
{
session.setAttribute("currPage","Login");
Locale locale = null;
if(lang.equals("Arabic"))
//locale = Locale.getDefault();
locale = new Locale("ar","AE");
else
locale = Locale.US;
session.putValue("mylocale",locale);
ResourceBundle bundle = ResourceBundle.getBundle("Messages",locale);

%>
<html>
<head>
<title>
Dubai Municipality - Login
</title>
</head>
<body background="/DubaiM/resources/images/bg_logo1.gif" bgproperties="fixed" style="font-family:times new roman;" >
<jsp:include page="Header.jsp" />
<br><br><br><br>
<center>
<table bgcolor=#CAE1FF cellspacing=1 width=320 style="border-style ouble;border-width:2px;border-color:#000099;" bordercolor=darkblue border="1">
<netui:form action="login" tagId="login">
<tr>
<th colspan="3" align=center><font size = +1 style="color:#000099;">FileNet System</font></th>
<tr>
<tr>
<td><font style="color:#000099;">
<b><%= bundle.getString("username")%></b>
</font></td>
<td>
<netui:textBox tagId="user_name" dataSource="{actionForm.user_name}"></netui:textBox>
</td>
<td rowspan="3" align="center">
<netui:image src="/DubaiM/resources/images/key.gif" align="center"></netui:image>
</td>
</tr>
<tr>
<td><font style="color:#000099;">
<b><%= bundle.getString("password")%></b>
</font></td>
<td>
<netui:textBox tagId="password" dataSource="{actionForm.password}" password="true"></netui:textBox>
</td>
</tr>
<tr>
<td align=center colspan=2>
<netui:button type="submit" value="Login" action="login" tagId="login" style="background-color:#cae1ff;font-size:13pt;color:#000099;"></netui:button>
  
<netui:button type="reset" value='<%= bundle.getString("Clear")%>' action="login" tagId="reset" style="background-color:#cae1ff;font-size:13pt;color:#000099;"></netui:button>
</td>
</tr>
</netui:form>
</table></center>
<br>
<center><b><font size="+4" color="#000099" style="color:#000099;">Dubai Municipality</font></b>
<br>

<table width="300">
<tr>
<td style="font-size:12pt;color:#000099;"><b>Select Language  اختيار اللغة</b></td>
<td><br>
<form action="Login.jsp" method="post">
<select name="lang">
<option value="English">English
<option value="Arabic" selected>Arabic
</select>
</form>
</td>
<td><netui:imageButton src="resources/images/go.gif"></netui:imageButton></td>
</tr>
</table></center>
<br>
<jsp:include page="Footer.jsp" />
</body>
</html>
<%
}
%>
in arabic all text is from right to left, how can i change the alignment in one place rather than doing it for individual controls.
regards,
sowmya
 
Yash Sharma
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's because the unicode text in the properties file must be in "/u" format. Use the native2ascii tool that comes with JDK (jskdir/bin). Run this tool and it would generate the requisite file for you.

Also have a look at this
web page.
 
Sowmya Dhilip
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I tried the native2ascii cmd but i am still getting the same thing like this ,
�����… ���„�…���������… for user name
�ƒ�„�…�� ���„���� for password
what do i do.
Regards
 
Sowmya Dhilip
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
GEE thanks a ton,
it worked, my application is now bilingual
regards,
sowmya
 
The government thinks you are too stupid to make your own lightbulb choices. But this tiny ad thinks you are smart:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic