Android Support

Integrating Swalekh on Android

Swalekh supports Android devices with a mobile-optimized experience. To enable transliteration and keyboard features on Android, use the following integration steps:

Integration Example

let lang = "hi";
let mode = "phonetic";
let keyboardEnabled = false;
 
let userAgent = navigator.userAgent;
let isMobile = /android|webos|mobile/i.test(userAgent);
let isIOS = /iPhone|iPad|iPod/i.test(userAgent);
const validationKey = "YOUR-VALIDATION-KEY";
 
const loadSwalekh = async () => {
	await window.initSwalekh({
		validationKey,
		optional: {
			theme: "light",
			dictionaryEnabled: false,
			isMobile: isMobile && !isIOS
		},
		creds: {
			identifier: ['#swalekh-textarea3','#swalekh-textarea4','#swalekh-container1','#swalekh-container2' ,"#editor"],
			lang: 'hi',
			mode: 'phonetic',
			modeToggle:true,
			langToggle:true,
		}
	});
}
 
window.addEventListener('load', function () {
	loadSwalekh();
	document.querySelector('#langSelect').addEventListener('change', function (e) {
		window.trigger_lang_change(e.target.value);
	})
	document.querySelector('#keyboardCheckbox').addEventListener('change', function (e) {
		keyboardEnabled = e.target.checked;
		window.trigger_mode_change(keyboardEnabled ? "keyboard" : "phonetic");
	})
	// window.unloadSwalekh();
});

Instructions

  1. Detect Android: The code checks for Android devices and enables mobile-specific features.
  2. Initialization: Use window.initSwalekh with the required options and credentials.
  3. Language and Mode Toggle: Users can switch language and input mode using UI controls.
  4. Keyboard Support: The keyboard can be enabled or disabled for phonetic or native input.

For more details, refer to the main Swalekh documentation or contact support.