import gradio as gr # # Define a list of word and translation pairs word_translations = [ {"word":"kupovati","image_url":"","translation":"buy","link":"https://sh.wiktionary.org/wiki/kupovati"}, {"word":"misliti","image_url":"","translation":"to think","link":"https://sh.wiktionary.org/wiki/misliti"}, {"word":"sjediti","image_url":"", "translation":"sit","link":"https://sh.wiktionary.org/wiki/sjediti"}, {"word":"jesti","image_url":"","translation":"to eat","link":"https://sh.wiktionary.org/wiki/jesti"}, {"word":"biti","image_url":"","translation":"be","link":"https://sh.wiktionary.org/wiki/biti"}, {"word":"voziti se","image_url":"","translation":"to drive","link":"https://sh.wiktionary.org/wiki/voziti"}, {"word":"letjeti","image_url":"","translation":"fly","link":"https://sh.wiktionary.org/wiki/letjeti"}, {"word":"živjeti","image_url":"","translation":"to live","link":"https://sh.wiktionary.org/wiki/"}, {"word":"trčati","image_url":"","translation":"run","link":"https://sh.wiktionary.org/wiki/trčati"}, {"word":"obožavati","image_url":"","translation":"worship","link":"https://sh.wiktionary.org/wiki/obožavati"}, {"word":"uživati","image_url":"","translation":"to enjoy","link":"https://sh.wiktionary.org/wiki/uživati"}, {"word":"buditi se","image_url":"","translation":"Wake up","link":"https://sh.wiktionary.org/wiki/buditi"}, {"word":"skuhati","image_url":"","translation":"cook","link":"https://sh.wiktionary.org/wiki/skuhati"}, {"word":"slušati","image_url":"","translation":"listen","link":"https://sh.wiktionary.org/wiki/slušati"}, {"word":"opuštati","image_url":"","translation":"relax","link":"https://sh.wiktionary.org/wiki/opuštati"}, {"word":"doručkovati","image_url":"","translation":"have breakfast","link":"https://sh.wiktionary.org/wiki/doručkovati"}, {"word":"ne biti","image_url":"","translation":"not to be","link":"https://sh.wiktionary.org/wiki/biti"}, {"word":"slaviti","image_url":"","translation":"celebrate","link":"https://sh.wiktionary.org/wiki/slaviti"}, {"word":"željeti","image_url":"","translation":"want","link":"https://sh.wiktionary.org/wiki/željeti"}, {"word":"ne voljeti","image_url":"","translation":"dislike","link":"https://sh.wiktionary.org/wiki/voljeti"}, {"word":"brisati","link":"https://sh.wiktionary.org/wiki/brisati","image_url":"","translation":"",}, {"word":"kihati","link":"https://sh.wiktionary.org/wiki/kihati","image_url":"","translation":"",}, {"word":"zavezati","link":"https://sh.wiktionary.org/wiki/zavezati","image_url":"","translation":"",}, {"word":"plakati","link":"https://sh.wiktionary.org/wiki/plakati","image_url":"","translation":"",}, {"word":"disati","link":"https://sh.wiktionary.org/wiki/disati","image_url":"","translation":"",}, {"word":"pomicati","link":"https://sh.wiktionary.org/wiki/pomicati","image_url":"","translation":"",}, {"word":"lagati","link":"https://sh.wiktionary.org/wiki/lagati","image_url":"","translation":"",}, {"word":"mazati","link":"https://sh.wiktionary.org/wiki/mazati","image_url":"","translation":"",}, {"word":"mahati","link":"https://sh.wiktionary.org/wiki/mahati","image_url":"","translation":"",}, {"word":"skakati","link":"https://sh.wiktionary.org/wiki/skakati","image_url":"","translation":"",}, {"word":"pisati","link":"https://sh.wiktionary.org/wiki/pisati","image_url":"","translation":"",}, {"word":"mirisati","link":"https://sh.wiktionary.org/wiki/mirisati","image_url":"","translation":"",}, {"word":"dizati","link":"https://sh.wiktionary.org/wiki/dizati","image_url":"","translation":"",}, {"word":"puhati","link":"https://sh.wiktionary.org/wiki/puhati","image_url":"","translation":"",}, {"word":"stizati","link":"https://sh.wiktionary.org/wiki/stizati","image_url":"","translation":"",}, ] # Initialize an index to keep track of the current word current_index = 0 # Function to display the current word and translation def display_word(): global current_index word_translation = word_translations[current_index] current_index = (current_index + 1) % len(word_translations) display_html = f"Word: {word_translation['word']}
" display_html += f"Translation: {word_translation['translation']}
" display_html += f"

" display_html += f"
" return display_html # Create a Gradio interface iface = gr.Interface( fn=display_word, live=True, title="Practise Words Croatian Verbs App", description="Click 'Next' to view the next word and translation.", inputs=[], outputs=["html"], layout="vertical" ) # Start the Gradio interface iface.launch()