Displaying French characters in GWT

329 views
Skip to first unread message

Rinku

unread,
Dec 21, 2007, 8:37:23 AM12/21/07
to Google Web Toolkit
Hi,
I want to diplay french characters in my GWT code.
I Used i18 n but not getting success to display them.
when I am using this code which is given below
it is showing FRENCH in unreadable format.
and with engilish character is working right
for example : goodbye which is given below in the properties file.
I want to use french in my labels.
how can I display the french ?

Please help me out.
Thanks in advance.

I am providing my file which I created for displaying french
characters.

1) MyConstants.properties

ageCategory = Catégorie d?âge
goodbyeWorld = Good Bye

2) MyConstants.java


import com.google.gwt.i18n.client.Constants;

public interface MyConstants extends Constants
{
String ageCategory();
String goodbyeWorld();

}

3) Simulation.gwt.xml

<module>

<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.google.gwt.i18n.I18N"/>

<!-- French language, independent of country -->
<extend-property name="locale" values="fr"/>

<!-- French language, independent of country -->
<extend-property name="locale" values="fr_FR"/>

<!-- Specify the app entry point class. -->
<entry-point class='com.capgent.client.Simulation'/>

</module>

4) ErrorMessages.java

import com.google.gwt.i18n.client.Messages;

public interface ErrorMessages extends Messages
{
String permissionDenied(int errorCode, String username);

}

5) Simulation.java

public class Simulation implements EntryPoint
{
public void onModuleLoad()
{
useMyConstants();

}

public void useMyConstants() {
MyConstants myConstants = (MyConstants)
GWT.create(MyConstants.class);
Window.alert(myConstants.ageCategory());
Window.alert(myConstants.goodbyeWorld());
}
}

6) Simulation.html

I used this meta tag in this html file.

<meta name="gwt:module" content="com.capgent.client.Simulation">
<meta name="gwt:property" name="locale" content="fr_FR">



Bob Lebel

unread,
Dec 21, 2007, 10:53:11 AM12/21/07
to Google Web Toolkit
Hi,

Your properties files are probably not using UTF-8 encoding.

L Frohman

unread,
Dec 21, 2007, 1:07:25 PM12/21/07
to Google-We...@googlegroups.com
Rinku,
You need to use encoding UTF-8 to fix this. Set the
character encoding for MyConstant.properties to UTF-8.

I think you mean
ageCategory = Catégorie d'âge
goodbyeWorld = Au revoir monde

and

MyConstant.properties

is the default file when no matching languages are found.
In your case, this means your application will only run with the French
without the <extend-property...>

MyConstants_fr.properties

will have french translations
and

MyConstants_fr_FR.properties

will have translations that are different than the
MyConstants_fr.properties -
specific to the country of France

MyConstants_fr_CA.properties

will have translations that are different than the
MyConstants_fr.properties -
specific to the country of Canada

So it should read

<!-- French language, sepcifically for France -->


<extend-property name="locale" values="fr_FR"/>

Rinku

unread,
Dec 21, 2007, 11:25:56 PM12/21/07
to Google Web Toolkit
Hi Bob,
Thanks for your help.
Can U please tell me, how can I set the UTF-8 encoding for the
properties file.

Rinku

unread,
Dec 21, 2007, 11:28:39 PM12/21/07
to Google Web Toolkit
Hi L Frohman,
Thanks for your reply.
Please tell me how can I set the encoding scheme for my porperty file.

Ian Bambury

unread,
Dec 21, 2007, 11:54:12 PM12/21/07
to Google-We...@googlegroups.com
If you're using Eclipse, you go to Window - Properties - General - Workspace
 
In HTML files, you'll need the line
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 

Ian
--------------------------------------------
 
--------------------------------------------

Rinku

unread,
Dec 22, 2007, 12:39:26 AM12/22/07
to Google Web Toolkit
Hi lan,
I am using eclipse.
My some data is coming from xml,
and in that xml, I used encoding = "windows-1252"
with this encoding xml is showing right french characters.
but with ISO-8859-1 it is not showing right output.

I am using eclipse 3.1 and in that windows-1252 encoding is not
available.
with utf-8 it is also not working.I checked in eclipse 3.3, it have
same encoding scheme.
So how can I add this encoding "windows-1252" in my eclipse.

Reinier Zwitserloot

unread,
Dec 22, 2007, 3:54:57 PM12/22/07
to Google Web Toolkit
'windows-1252' - think about it for just a moment. That won't, of
course, work on anything except 'windows'. French characters are
definitely in UTF-8; you may need a better converter (java can
probably do this, write a little app that reads in windows-1252 and
writes out UTF-8) - though that java app will only run on windows, not
on any other platform, if it runs at all. Alternatively, just write
all your files in UTF-8 right from the start.

Fred Sauer

unread,
Dec 22, 2007, 10:58:59 PM12/22/07
to Google-We...@googlegroups.com
Your JDK also comes with native2ascii which might help:

http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/native2ascii.html

Rinku

unread,
Dec 24, 2007, 12:55:50 AM12/24/07
to Google Web Toolkit
Hi Reinier,
Thanks for your help.
I changed my file encoding from windows-1252 to "UTF-8".
and now I18n is giving right output.
Thanks a lot.

Rinku

unread,
Dec 24, 2007, 12:56:19 AM12/24/07
to Google Web Toolkit
Hi Fred,
Thanks for your help.


On Dec 23, 8:58 am, "Fred Sauer" <f...@allen-sauer.com> wrote:
> Your JDK also comes with native2ascii which might help:
>
> http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/native2ascii.html
>
> --
> Fred Sauer
> f...@allen-sauer.com
Reply all
Reply to author
Forward
0 new messages