Lipi Lekhika API Reference

Including The Script in body Tag

This library is Jquery dependent, So you must include Jquery. Next you should include the script tag somewhere in the body(before initialization).
Like this <script src="https://get.lipilekhika.com/main"></script>
You Can also Download this file and then load it.

Supported Elements

Lipi Lekhika Supports the Following Elements :-

  • input(type:text)
  • Textarea
  • Contenteditable Elements like div or span (iframe not supported)
  • To know the Supported Langugaes refer to Main Site.

    Initialization

    1st Method (Recommended)

    In this Method add class "Lipi-LekhikA" to a Element.

    <textarea class="Lipi-LekhikA"></textarea>
    Like this You can also use it for input, editable span and div.
    And then Execute this $.lipi_lekhika();. This Function Enables Lipi Lekhika for all supported Elements with the class Lipi-Lekhika.
    If you have a dynamic web page in which new elements are crwated and if you want to add Lipi Lekhika into those new Elements then there would be two ways :-
    1 - After creating those Elements call the function $.lipi_lekhika();
    2 - You can also set a time interval in which it will add Lipi Lekhika to newly created elements. $.lipi_lekhika(time);. Here Time is in seconds.

    2st Method
    Sytax:- JqueryElementReference.lipi_lekhika_add();
    The Element Reference must be of Jquery and not JavaScript. i.e. $("").
    <input type="text" id="input_tag">
    OR
    <textarea id="textarea"></textarea>
    OR
    <div id="editable_div" contenteditable="true"></div>

    Now initialise Lipi Lekhika for these Elements like this :-
    $("#input_tag").lipi_lekhika_add();
    OR
    $("#textarea").lipi_lekhika_add();
    OR
    $("#editable_div").lipi_lekhika_add();


    lipi_lekhika_add also supports initalization by adding attributes to HTML element(tags) like this :-
    $("#input_tag").lipi_lekhika_add(true);
    $("#textarea").lipi_lekhika_add(true);
    $("#editable_div").lipi_lekhika_add(true);

    These would add the attributes required directly to the tag instead of registering through JavaScript.

    3rd Method
    In this method the events have to be manually set up. Register These Events in html as inline or in JavaScript.
    oninput : LipiLekhikA.mukhya($(this), event);
    onkeydown : लिपि.clear(event);

    If you add The Class "Lipi-LekhikA-Off" to a element then the Lipi Lekhika would be currently disabled. Remove it to Enable again.

    Setting Language and Other Things

    These Functions should be called after Initializing Lipi Lekhika

  • LipiLekhikA.set_lang_and_state(language, callback, state) :- This Function is necessary to be called after Inialization.This function sets the language and state of Lipi Lekhika. The state could be true or false respectively corresponding to On and Off, by default its Off.The Callback will be executed when the language is loaded successfully.
  • LipiLekhikA.karya :- Setting this true would turn On and false would turn off Lipi Lekhika.
  • LipiLekhikA.sahayika_usage :- Its value could be set true or false.If true then Lekhan Sahayika would display and if false then not.
  • LipiLekhikA.usage_table_link(lang) :- This Function would return the Link for the Usage Table of the provided Language.
  • LipiLekhikA.add_font(language) :- This Would load the fonts for Sharada as LipiFont1, Modi as LipiFont2, Brahmi as LipiFont3, Siddham as LipiFont4 and Granth as LipiFont5. You can add these font names in font family of these element where you want to display these Langugaes.
  • LipiLekhikA.hide()/show() :- Use this Statement to hide or show the Lekhan Sahayika.
  • LipiLekhikA.set_interface_lang(language) :- By default the Instructions Language is set to English (which is hidden by default). You can set the Interface(which is minimal) Language it to Hindi, Tamil, Telugu, Bengali, Kannada and Sanskrit.You MUST call it after Initializing Lipi Lekhika.

  • If you want to use load resources offline
    If you want to implement this in JavaScript App Offline you will need to set लिपि.sanchit="location";
    Here, location is of the folder where you have stored the json files required. Download the Download the JSON files from here, and store it in that folder.
    This will make the files to be loaded from custom location instead of default online location.This must be initialized before calling LipiLekhikA.set_lang_and_state(language, callback, state)
    While loading the fonts through LipilekhikA.add_font(lang, fonts_folder).  Here, by default fonts_folder is set to a online Location of folder containing the fonts for Additional Languages menitioned.
    To use it offline Download the fonts and pass the location of folder in the argumnent.
    In the same way to get the link of images of Usage Table through LipiLekhikA.usage_table_link(lang, image_folder). Download the Images here and pass the folder loaction in arguments. If not passed images will have their default online location.

    InterConversions

    Lipi Lekhika also provides a Lipi Parivartak API to convert one Script to another.

    Syntx :- LipiLekhikA.antarparivartan(value to convert, from, to, is_inner_html=false)

    Include the Languages which you are interconverting, through the given sytax
    LipiLekhikA.load_lang(lang);
    Here from and to are the Langugaes involved. Set is_inner_html to true is you want convert innerHTML by preserving the tags inside and only converting text.
    Type Text between #^ and ^# to avoid conversion.
    This was the method to do conversions on the client's device itself. There is also a way to use Web API on https://api.lipilekhika.com/convert
    You can make requests via POST and GET(through url query).
    Example through GET request : url : https://api.lipilekhika.com/convert?from=Sanskrit&to=Telugu&text=नमस्कारम्
    The Response Text should be నమస్కారమ్

    Example through POST : url : https://api.lipilekhika.com/convert
    Request JSON body : {"from": "Sanskrit", "to": "Telugu", "text": "नमस्कारम्"}
    The Response Text should be నమస్కారమ్
    Go here to Test the Lipi Lekhika API using POST. Inspect the Page to see the JS Source Code and format (beutify) it.

    Limits of Web API

  • TimeOut limit is 10s.
  • Maximum size of the arguments can be only upto 16 KB.
  • Do not use this method for long conversions. In this case prefer doing it on the client's device (1st method) or your server.

  • Names of Supported Langugaes and the codes used for Them

    Names Codes
    Hindi Hindi
    Bengali Bengali
    Telugu Telugu
    Tamil Tamil
    Tamil Extended Tamil-Extended
    Marathi Marathi
    Gujarati Gujarati
    Malayalam Malayalam
    Sinhala Sinhala
    Kannada Kannada
    Odia Oriya
    Konkani Konkani
    Assamese Assamese
    Sanskrit Sanskrit
    Nepali Nepali
    Punjabi Punjabi
    Urdu Urdu
    Kashmiri Kashmiri

    See An Example of Lipi Lekhika API Usage along with Source Code Here.

    Example of API Usage

    See the Pen Lipi Lekhika API Usage Example by Shubham Anand gupta (@shubham-anand-gupta) on CodePen.