Hi,
I would like to know how to change the default selected language of the keyboard depending of the current language of the site. I.e when a user switch to another language, the keyboard will switch to the current language. Is it possible?

Comments

joflizn’s picture

Fixed it by doing:
- inside the .module file

function google_virtual_keyboard_init() {
global $language;
// some code
drupal_add_js(array('google_virtual_keyboard' => array('lang' => $language->language)), 'setting');
// some code

- then use the new setting value inside the .js file to load the keyboard according to the language:

Drupal.behaviors.google_virtual_keyboard = function (context) {
// some code
kblang = Drupal.settings.google_virtual_keyboard.lang;
  //Enable Google Virtual Keyboard
	if (kblang == 'es') {
	  keyboard = new google.elements.keyboard.Keyboard([google.elements.keyboard.LayoutCode.SPANISH],ids);
	} else if (kblang == 'fr') {
	  keyboard = new google.elements.keyboard.Keyboard([google.elements.keyboard.LayoutCode.FRENCH],ids);
	} else {
	  keyboard = new google.elements.keyboard.Keyboard([google.elements.keyboard.LayoutCode.ENGLISH],ids);
	}
});

There's surely a more elegant way to do this but for me it works.

skj’s picture

A good job. I am wondering whether it would be possible to show the keys on the keyboard in the language of the keyboard. eg: would like to have french alphabets on the keys when I select French language.

confiz’s picture

Yes keys will be displayed in the same language as you selected. You can change language from Site Configuration > Google Virtual Keyboard.

Thanks.

skj’s picture

Thanks for your fast response. But somehow the keyboard displayed on my screen always comes up with English letters on the keys. It does show a title over the keyboard in the selected language. Further if it is possible to show a separate key guide along with the keyboard, that would be great too.