• Post Reply Bookmark Topic Watch Topic
  • New Topic

Bilingual support in Java  RSS feed

 
Ash Kondhalkar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We are supporting a bilingual application(English and Arabic). User can change some setting in a system tray so that he can enter data from keyboard in either of the language.
I want to restrict/validate user from entering English characters in Arabic field or vice versa.
Is there a way I can know what characters are getting inputed from keyboard? Are they English or Arabic? So that I can validate the input.

Kindly provide some suggestions.

Cheers
Ashwin
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
English text would for the most part use ASCII or ISO-8859-1, so the characters entered would have values between 0 and 255. I'm not familair with how you enter Arabic text, but in a Java string it would have higher values (because of the Unicode encoding) - that's how you can tell them apart.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Is there a way I can know what characters are getting inputed from keyboard? Are they English or Arabic?

You are going to struggle to find a fool proof way of doing this. For example is this text English or Arabic: "78978789789" ? My point is you can guess based on the Unicode value of the String, but this will fail when encounter characters shared between English and Arabic.

I'm not sure why you need to stop English being entered when the application expects Arabic and viceversa. Can you explain why this is a problem?
 
Ash Kondhalkar
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf and Paul,

Thank you for your replies. Our customer's requirement is,user should only enter arabic in Arabic textfield and vice versa. So we need to do this.

Actually after going through JDK, I have found out the way! JDK provides a class "Character.UnicodeBlock", which provides constants for different langauges e.g ARABIC, BASIC_LATIN etc and also a method as "of". This method returns the unicode block of a character passed to it. So using this constant and a method I am in position to restrict user from entering non arabic characters in Arabi textfield!

Regards
Ashwin
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!