You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by worookie <wo...@hotmail.com> on 2003/06/12 21:56:31 UTC

2 Q's about Localization

I tried to use Localization features based on Harish's demo app and encountered two problems.
In Harish's Registration demo app, there are 3 pages:

(1) index.html: static; default welcome file
(2) Registration page: dynamic; includes .html, .java, .page, .properties, etc
(3) Confirmation.html: static

I added the following localized files to the app:
- index_zh_TW.html
- Registration_zh_TW.html and Registration_zh_TW.properties
- Confirmation_zh_TW.html

I have included -Dfile.encoding=Big5 while executing my application server Tomcat 4.1.24.
Also, I use natice2ascii (as taught by MB) to covert my properties files before using them.

 The Registration page works fine. Tapestry can correctly pick up Registraion_zh_TW.html/properties files instead of Registration.html/properties files. They can also be appropriately processed and displayed if the following code block is added to Registration.java:

 public IMarkupWriter getResponseWriter(OutputStream out) {
  return new HTMLWriter("text/html;charset=Big5", out);
 }

1st problem: The index_zh_TW.html could not be automatically picked up. It always shows index.html.
Well I don't think there is any easy way to add the Localization feature to the default welcome page (index.html), so I will just live with it.


2nd problem: Although the Confirmation_zh_TW.html can be correctly picked up but it cannot be appropriately processed and displayed because maybe Tapestry somehow translates it with UTF-8 char-encoding. (I tried to add meta tag in the html file in order to tell the browser what the charset is, but had no luck.)

QUESTION: How to tell Tapestry to process a html file (that doesn't have a corresponding java file) using a specific char-encoding?

Thanks.

Rookie

Re: 2 Q's about Localization

Posted by worookie <wo...@hotmail.com>.
> >     Problem 2: If you have -Dfile.encoding=Big5, just let your pages be
> > encoded in Big5 -- it will work fine, I believe -- simpler for you that
> way
> > as well.
> >
>
> Mmm... sorry that it doesn't work.
>
> The Confirmation_zh_TW.html (which is a Tapestry web component with only
the
> html file(s)) was saved in Big5 char-encoding.
>
> The command I used to startup Tomcat is:
>
C:\j2sdk1.4.1_02\bin\java.exe -jar -Duser.dir="D:\Tomcat4" -Dfile.encoding=B
> ig5 "D:\Tomcat4\bin\bootstrap.jar" start
>
> On the browser, I tested all possible View->Encoding's to view the page.
>

Sorry, please ignore the previous line.

On the browser, I have to manually switch View->Encoding from UTF8 to Big5
in order to correctly view the contents.
The only way that I know to force the browser to automatically use Big5
encoding is by adding the getResponseWriter(...) method in the java code for
the corresponding web component. Adding something like:
<meta http-equiv="Content-Type" content="text/html; charset=big5">
will cause the html template file not being parsed correctly.
Since the Confirmation page componet doesn't have a java file, so I don't
know what to do.


Re: 2 Q's about Localization

Posted by worookie <wo...@hotmail.com>.
Many thanks to Harish and MB for your clarifications on the roles of
different html files.

----- Original Message -----
From: "Mindbridge" <mi...@yahoo.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, June 12, 2003 1:19 PM
Subject: Re: 2 Q's about Localization


> Hi,
>
> (sorry if there is duplication with another post, got delayed)
>
>     Problem 1: index.html will not be rendered through Tapestry, but is
> directly returned by the web server/servlet container (since index.html is
> the default page to display if there is nothing after the URL). Because of
> this, it will not be localized in the Tapestry way. One thing you could do
> is make your app to be served by default by the Tapestry servlet. In that
> case you will get the Tapestry page 'Home' rendered by default instead of
> index.html. Just rename index.html (and localized variants) to Home.html,
> set up the default response to go through Tapestry, and you will be all
set.

Thanks. I'll try it.

>     Problem 2: If you have -Dfile.encoding=Big5, just let your pages be
> encoded in Big5 -- it will work fine, I believe -- simpler for you that
way
> as well.
>

Mmm... sorry that it doesn't work.

The Confirmation_zh_TW.html (which is a Tapestry web component with only the
html file(s)) was saved in Big5 char-encoding.

The command I used to startup Tomcat is:
C:\j2sdk1.4.1_02\bin\java.exe -jar -Duser.dir="D:\Tomcat4" -Dfile.encoding=B
ig5 "D:\Tomcat4\bin\bootstrap.jar" start

On the browser, I tested all possible View->Encoding's to view the page.

>     (btw, you may also try to leave your property files in Big5 if you
have
> that file encoding defined and see if that works -- I am not 100% sure it
> won't. If it does not, native2ascii will always work for the property
> files).

Sorry that "native2ascii" is a must-have. I have tried all kinds of
combinations of approaches, and my conculsion is that "native2ascii" is the
only solution so far.

Thank you.
Regards,
Rookie

>
> Best regards,
> -mb
>
>
> ----- Original Message -----
> From: "worookie" <wo...@hotmail.com>
> To: "Tapestry users" <ta...@jakarta.apache.org>
> Sent: Thursday, June 12, 2003 10:56 PM
> Subject: 2 Q's about Localization
>
>
> I tried to use Localization features based on Harish's demo app and
> encountered two problems.
> In Harish's Registration demo app, there are 3 pages:
>
> (1) index.html: static; default welcome file
> (2) Registration page: dynamic; includes .html, .java, .page, .properties,
> etc
> (3) Confirmation.html: static
>
> I added the following localized files to the app:
> - index_zh_TW.html
> - Registration_zh_TW.html and Registration_zh_TW.properties
> - Confirmation_zh_TW.html
>
> I have included -Dfile.encoding=Big5 while executing my application server
> Tomcat 4.1.24.
> Also, I use natice2ascii (as taught by MB) to covert my properties files
> before using them.
>
>  The Registration page works fine. Tapestry can correctly pick up
> Registraion_zh_TW.html/properties files instead of
> Registration.html/properties files. They can also be appropriately
processed
> and displayed if the following code block is added to Registration.java:
>
>  public IMarkupWriter getResponseWriter(OutputStream out) {
>   return new HTMLWriter("text/html;charset=Big5", out);
>  }
>
> 1st problem: The index_zh_TW.html could not be automatically picked up. It
> always shows index.html.
> Well I don't think there is any easy way to add the Localization feature
to
> the default welcome page (index.html), so I will just live with it.
>
>
> 2nd problem: Although the Confirmation_zh_TW.html can be correctly picked
up
> but it cannot be appropriately processed and displayed because maybe
> Tapestry somehow translates it with UTF-8 char-encoding. (I tried to add
> meta tag in the html file in order to tell the browser what the charset
is,
> but had no luck.)
>
> QUESTION: How to tell Tapestry to process a html file (that doesn't have a
> corresponding java file) using a specific char-encoding?
>
> Thanks.
>
> Rookie


Re: 2 Q's about Localization

Posted by Mindbridge <mi...@yahoo.com>.
Hi,

(sorry if there is duplication with another post, got delayed)

    Problem 1: index.html will not be rendered through Tapestry, but is
directly returned by the web server/servlet container (since index.html is
the default page to display if there is nothing after the URL). Because of
this, it will not be localized in the Tapestry way. One thing you could do
is make your app to be served by default by the Tapestry servlet. In that
case you will get the Tapestry page 'Home' rendered by default instead of
index.html. Just rename index.html (and localized variants) to Home.html,
set up the default response to go through Tapestry, and you will be all set.

    Problem 2: If you have -Dfile.encoding=Big5, just let your pages be
encoded in Big5 -- it will work fine, I believe -- simpler for you that way
as well.

    (btw, you may also try to leave your property files in Big5 if you have
that file encoding defined and see if that works -- I am not 100% sure it
won't. If it does not, native2ascii will always work for the property
files).

Best regards,
-mb


----- Original Message ----- 
From: "worookie" <wo...@hotmail.com>
To: "Tapestry users" <ta...@jakarta.apache.org>
Sent: Thursday, June 12, 2003 10:56 PM
Subject: 2 Q's about Localization


I tried to use Localization features based on Harish's demo app and
encountered two problems.
In Harish's Registration demo app, there are 3 pages:

(1) index.html: static; default welcome file
(2) Registration page: dynamic; includes .html, .java, .page, .properties,
etc
(3) Confirmation.html: static

I added the following localized files to the app:
- index_zh_TW.html
- Registration_zh_TW.html and Registration_zh_TW.properties
- Confirmation_zh_TW.html

I have included -Dfile.encoding=Big5 while executing my application server
Tomcat 4.1.24.
Also, I use natice2ascii (as taught by MB) to covert my properties files
before using them.

 The Registration page works fine. Tapestry can correctly pick up
Registraion_zh_TW.html/properties files instead of
Registration.html/properties files. They can also be appropriately processed
and displayed if the following code block is added to Registration.java:

 public IMarkupWriter getResponseWriter(OutputStream out) {
  return new HTMLWriter("text/html;charset=Big5", out);
 }

1st problem: The index_zh_TW.html could not be automatically picked up. It
always shows index.html.
Well I don't think there is any easy way to add the Localization feature to
the default welcome page (index.html), so I will just live with it.


2nd problem: Although the Confirmation_zh_TW.html can be correctly picked up
but it cannot be appropriately processed and displayed because maybe
Tapestry somehow translates it with UTF-8 char-encoding. (I tried to add
meta tag in the html file in order to tell the browser what the charset is,
but had no luck.)

QUESTION: How to tell Tapestry to process a html file (that doesn't have a
corresponding java file) using a specific char-encoding?

Thanks.

Rookie


Re: 2 Q's about Localization

Posted by Harish Krishnaswamy <hk...@comcast.net>.
I would like to clarify a couple of things.

1. The index.html is just a html file (not a Tapestry component, becuase
it is outside the servlet context).
2. The Confirmation.html is a Tapestry Page component like the
Registration Page even though it doesn't have a specification and a Java
class.

I am sorry I don't have an answer to your localization question. I'll
leave that to the gurus;)

-Harish

worookie wrote:

>I tried to use Localization features based on Harish's demo app and encountered two problems.
>In Harish's Registration demo app, there are 3 pages:
>
>(1) index.html: static; default welcome file
>(2) Registration page: dynamic; includes .html, .java, .page, .properties, etc
>(3) Confirmation.html: static
>
>I added the following localized files to the app:
>- index_zh_TW.html
>- Registration_zh_TW.html and Registration_zh_TW.properties
>- Confirmation_zh_TW.html
>
>I have included -Dfile.encoding=Big5 while executing my application server Tomcat 4.1.24.
>Also, I use natice2ascii (as taught by MB) to covert my properties files before using them.
>
> The Registration page works fine. Tapestry can correctly pick up Registraion_zh_TW.html/properties files instead of Registration.html/properties files. They can also be appropriately processed and displayed if the following code block is added to Registration.java:
>
> public IMarkupWriter getResponseWriter(OutputStream out) {
>  return new HTMLWriter("text/html;charset=Big5", out);
> }
>
>1st problem: The index_zh_TW.html could not be automatically picked up. It always shows index.html.
>Well I don't think there is any easy way to add the Localization feature to the default welcome page (index.html), so I will just live with it.
>
>
>2nd problem: Although the Confirmation_zh_TW.html can be correctly picked up but it cannot be appropriately processed and displayed because maybe Tapestry somehow translates it with UTF-8 char-encoding. (I tried to add meta tag in the html file in order to tell the browser what the charset is, but had no luck.)
>
>QUESTION: How to tell Tapestry to process a html file (that doesn't have a corresponding java file) using a specific char-encoding?
>
>Thanks.
>
>Rookie
>
>  
>