• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to set Context Input Method to specific locale (without country code)  RSS feed

 
Reyada Wolak
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
i'm using selectInputMethod(new Locale("ar", "AE")) to set the locale for my application. this works fine but the problem is that i should specify the country code as well e.g. "AE", without this it will not work e.g. new Locale("ar")
Arabic language is the same for all countries so the country is not a matter here. i don't know which country code language is installed in the user PC. i want the application to select any Arabic language installed in the user PC.
Locale.getAvailableLocales() is not giving me what i need. it gives all the supported languages in the OS but not the ones that are enabled by the user.
i ended up duplicating selectInputMethod for all the country codes i.e.:

this.getInputContext().selectInputMethod(new Locale("ar", "DZ"));
this.getInputContext().selectInputMethod(new Locale("ar", "IQ"));
this.getInputContext().selectInputMethod(new Locale("ar", "JO"));
this.getInputContext().selectInputMethod(new Locale("ar", "LB"));
this.getInputContext().selectInputMethod(new Locale("ar", "LY"));
this.getInputContext().selectInputMethod(new Locale("ar", "MA"));
this.getInputContext().selectInputMethod(new Locale("ar", "OM"));
this.getInputContext().selectInputMethod(new Locale("ar", "SD"));
this.getInputContext().selectInputMethod(new Locale("ar", "SY"));
this.getInputContext().selectInputMethod(new Locale("ar", "TN"));
this.getInputContext().selectInputMethod(new Locale("ar", "YE"));
this.getInputContext().selectInputMethod(new Locale("ar", "QA"));
this.getInputContext().selectInputMethod(new Locale("ar", "KW"));
this.getInputContext().selectInputMethod(new Locale("ar", "BH"));
this.getInputContext().selectInputMethod(new Locale("ar", "EG"));
this.getInputContext().selectInputMethod(new Locale("ar", "SA"));
this.getInputContext().selectInputMethod(new Locale("ar", "AE"));

this will pick certainly one Arabic language in the user PC.

Is there any other better way?
 
Peter Taucher
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reyada Wolak wrote:the problem is that i should specify the country code as well e.g. "AE", without this it will not work e.g. new Locale("ar")

What exactly do you mean when saying 'it will not work'? -> ItDoesntWorkIsUseless

Personally I never encountered problems using Locales without specifying the country code. Did you ever analyze the return value of method selectInputMethod()? Are you aware of it's function/implementation as stated in the docs?
-> http://java.sun.com/javase/6/docs/api/java/awt/im/InputContext.html#selectInputMethod(java.util.Locale)
 
Reyada Wolak
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it means that the input language didn't change from en_US (default locale) to ar_X
i.e. i need to specify the country code or it will not work.

the selectInputMethod() return false in case of Locale("ar"), the same as Locale("en")

there is no bug in the implementation but i need to know how do i get the enabled input language (not the list of the supported languages since i cannot select them unless the user add them from the control panel)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!