Mahesh Patil wrote:
>
> Hi,
>
> I want to write an application in which I want to display html text( and
> html controls ) in different languages. Basically an application using
> Servlets which has multilingual support. The user is allowed to select any
> language and then all displayed pages will be in that language. Does
> anybody have an Idea, how to do it ???? I want to support almost all
> languages........Please reply even if you know a bit about this.
> Thanks
> Mahesh
 Your servlets should display text in this way:
----------------------------------
  import java.io.*;
  import java.util.*;
  import java.text.*;
  import javax.servlet.*;
  import javax.servlet.http.*;

  public class Kod extends HttpServlet
  {
   public void doGet (HttpServletRequest request,
                      HttpServletResponse response)
                      throws ServletException, IOException
    {
     Locale deflocale = Locale.getDefault();
     ResourceBundle texts = ResourceBundle.getBundle("Textfile",deflocale);
     response.setContentType("text/html;charset=UTF-8");
     PrintWriter out = response.getWriter();
     out.println("<HTML><BODY>");
     out.println(texts.getString("idtext")+"< BR>");
     out.println("</BODY></HTML>");
     out.close();
  }
----------------------------------

Then make a file "Textfile.txt" with content like this:

--------------Textfile.txt--------------------
idtext=Default text if no locale specified
----------------------------------------------

and one file for each locale you want to use:

--------------Textfile_en_US.txt--------------
idtext=Text for US english
----------------------------------------------
--------------Textfile_cs_CZ.txt--------------
idtext=Text pro cestinu v Cechach a na Morave
----------------------------------------------

Then translate all files to UNICODE:
native2ascii -encoding ISO-8859-1 Textfile.txt Textfile.properties
native2ascii -encoding ISO-8859-1 Textfile_en_US.txt Textfile_en_US.properties
native2ascii -encoding Cp1250 Textfile_cs_CZ.txt Textfile_cs_CZ.properties

So you will have *.properties file for each locale.
Then just specify some specific locale instead of default
locale in the ResourceBundle.getBundle() method.

Martin
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   INET, a.s.                          Mgr. Martin Kuba
Kralovopolska 139                  e-mail: [EMAIL PROTECTED]
  601 12 Brno                      WWW: http://www.inet.cz/~makub/
 Czech Republic                    tel: +420-5-41242414/33
--------------------------------------------------------------------
PGP fingerprint = D8 57 47 E5 36 D2 C1 A1  C3 48 B2 59 00 58 42 27
 http://wwwkeys.cz.pgp.net:11371/pks/lookup?op=index&search=makub
--------------------------------------------------------------------

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to