from deep_translator import GoogleTranslator import gradio as gr # 100+ tillar ro'yxati tillar = [ 'uzbek', 'english', 'russian', 'french', 'german', 'arabic', 'turkish', 'spanish', 'italian', 'japanese', 'korean', 'chinese (simplified)', 'chinese (traditional)', 'hindi', 'portuguese', 'ukrainian', 'kazakh', 'kyrgyz', 'tajik', 'turkmen', 'polish', 'indonesian', 'malay', 'greek', 'swedish', 'norwegian', 'finnish', 'dutch', 'czech', 'serbian', 'vietnamese', 'bengali', 'thai', 'lithuanian', 'latvian', 'estonian', 'romanian', 'gujarati', 'punjabi', 'armenian', 'hebrew', 'pashto', 'persian', 'urdu', 'somali', 'zulu', 'swahili', 'afrikaans', 'tatar', 'yoruba', 'kinyarwanda', 'tamil', 'telugu', 'kannada', 'nepali', 'marathi', 'sinhala', 'lao', 'burmese', 'mongolian', 'haitian creole', 'icelandic', 'irish', 'bosnian', 'croatian', 'slovak', 'slovenian', 'macedonian', 'albanian', 'georgian', 'welsh', 'luxembourgish', 'yiddish', 'basque', 'galician', 'maltese', 'maori', 'samoan', 'tongan', 'hausa', 'igbo', 'amharic', 'azerbaijani', 'kurdish' ] def tarjima(matn, src_lang, tgt_lang): if src_lang == tgt_lang: return "⚠️ Manba va tarjima tillari bir xil bo‘lmasligi kerak." try: result = GoogleTranslator(source=src_lang, target=tgt_lang).translate(matn) return result except Exception as e: return f"❌ Xato: {e}" gr.Interface( fn=tarjima, inputs=[ gr.Textbox(label="✍️ Matn kiriting"), gr.Dropdown(choices=tillar, value="uzbek", label="🔤 Qaysi tildan"), gr.Dropdown(choices=tillar, value="english", label="🔠 Qaysi tilga") ], outputs="text", title="🌍 O‘zbek Tarjimon — 100+ til" ).launch()