Articles → JavaScript → Convert English Text To Hindi Using Google API
Convert English Text To Hindi Using Google API
Steps
- First of all create a new HTML page.
- Add a reference of Google’s API on the page
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
- Add a textbox that can be used to show the conversion.
<b>English to Hindi</b> : <textarea id="transliterateTxtBox"></textarea>
- Finally add JavaScript code and specify the source and destination language
<script type="text/javascript">
google.load("elements", "1", {
packages: "transliteration"
});
function onLoad() {
var options = {
sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
destinationLanguage: [google.elements.transliteration.LanguageCode.HINDI],
shortcutKey: 'ctrl+g',
transliterationEnabled: true
};
var control =
new google.elements.transliteration.TransliterationControl(options);
control.makeTransliteratable(['transliterateTxtBox']);
}
google.setOnLoadCallback(onLoad);
</script>
Click to Enlarge