Skip to main content

How to support multi-language in mainMenu

10 replies [Last post]
yt7589
Offline
Joined: 2008-05-06
Points: 0

If I change the demo button text to other language such as chinese it will display nothing under the button icon. For example: If I change the first demo text from "Themes" to "主题", the second one from "Rendering" to "渲染" then it will display nothing under the button icon. Who know how to display chinese words in the mainMenu?

By the way I had put the text in the locale.properties file and get them by the Resource.localize() method. I can use this method to display chinese words in the form titile.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
yt7589
Offline
Joined: 2008-05-06
Points: 0

By using the java decompile tool JAD. I found that if I comment this line:
g.setFont(s.getFont());
in the LookAndFeel.setFG() function. It can display chinese words now. By reading the source code I found that each alphabet or digit was represented by a image. The chinese words didn't have the corresponding image. Is this the reason why I couldn't display chinese words under button icon?

chen

Hi,
The bitmap fonts needs to contain the Chinese characters, what you need
to do is to open the resource editor tool and make sure the font you use
contains the relevant characters.
Simply recreate the font and in the Charset textfield enter the chars.

Regards,
Chen

lwuit-users@mobileandembedded.org wrote:
> By using the java decompile tool JAD. I found that if I comment this line:
> g.setFont(s.getFont());
> in the LookAndFeel.setFG() function. It can display chinese words now. By reading the source code I found that each alphabet or digit was represented by a image. The chinese words didn't have the corresponding image. Is this the reason why I couldn't display chinese words under button icon?
> [Message sent by forum member 'yt7589' (yt7589)]
>
> http://forums.java.net/jive/thread.jspa?messageID=279320
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

chen

Hi,
In a second thought, using our bitmap fonts for Chinese(or any language
with too many charcters such as Japanese or Korean ) may consume all the
memory you have, therefore I recommend to use the system fonts(this can
be done from code and from the resource editor as well).

Regards,
Chen

chen wrote:
> Hi,
> The bitmap fonts needs to contain the Chinese characters, what you
> need to do is to open the resource editor tool and make sure the font
> you use contains the relevant characters.
> Simply recreate the font and in the Charset textfield enter the chars.
>
> Regards,
> Chen
>
>
> lwuit-users@mobileandembedded.org wrote:
>> By using the java decompile tool JAD. I found that if I comment this
>> line:
>> g.setFont(s.getFont());
>> in the LookAndFeel.setFG() function. It can display chinese words
>> now. By reading the source code I found that each alphabet or digit
>> was represented by a image. The chinese words didn't have the
>> corresponding image. Is this the reason why I couldn't display
>> chinese words under button icon?
>> [Message sent by forum member 'yt7589' (yt7589)]
>>
>> http://forums.java.net/jive/thread.jspa?messageID=279320
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
>> For additional commands, e-mail: users-help@lwuit.dev.java.net
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

javatai
Offline
Joined: 2005-06-21
Points: 0

But how do I know the default font from J2ME VM ?
From System Property ?

Anson

chenf
Offline
Joined: 2008-04-29
Points: 0

Create the system font yourself for ex:

Label l = new Label("System Font");
l.getStyle().setFont(Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_MEDIUM));

You can also declare Components default Styles from the ResourceEditor

Regards,
Chen

javatai
Offline
Joined: 2005-06-21
Points: 0

I am facing the same problems with simplified chinese in Button object.
It seems I have to find out the default chinese font and defined in LookandFeel ?

Regards
Anson

Shai Almog

Hi Anson,
You are using a theme with a bitmap font (e.g. the Java Theme), since
a bitmap font has characters encoded into it you must either encode
these characters into the font or use a system font.
Both of these tasks are very easy to accomplish in the resource
editor or using the Ant task.

Thanks,
Shai.

> I am facing the same problems with simplified chinese in Button
> object.
> It seems I have to find out the default chinese font and defined in
> LookandFeel ?
>
> Regards
> Anson
> [Message sent by forum member 'javatai' (javatai)]
>
> http://forums.java.net/jive/thread.jspa?messageID=283927
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

javatai
Offline
Joined: 2005-06-21
Points: 0

Hi,Shai:
thanks for your answer, That's mean If I use how many of chinese characters, I have to write it into the resource file.
Is that right?
Or, If I setup the system default font, I don't have to write all the characters for resource file.

ex:
font logicalName="SansSerif" size="20" charset=" ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-我愛你......"
Regards
Anson

www.i3g.com.tw

Message was edited by: javatai

Message was edited by: javatai

Shai Almog

Exactly right.
You can do this in the resource editor as well (using the charset
option).
Obviously for CJK this might be an issue in terms of the amount of
characters, the more characters you add more memory will be consumed
by the font.

Thanks,
Shai.

> Hi,Shai:
> thanks for your answer, That's mean If I use how many of chinese
> characters, I have to write it into the resource file.
> Is that right?
> Or, If I setup the system default font, I don't have to write all
> the characters for resource file.
>
> ex:
>
>
> Regards
> Anson
>
> www.i3g.com.tw
> [Message sent by forum member 'javatai' (javatai)]
>
> http://forums.java.net/jive/thread.jspa?messageID=283973
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

javatai
Offline
Joined: 2005-06-21
Points: 0

Dear Shai:
I solved !!
I Love LWUIT
Thank you!!

Regards
Anson Tai