import gradio as gr, pathlib, tempfile from translate_xlf import translate_xlf def translate(file, target): tmp_in = tempfile.NamedTemporaryFile(delete=False, suffix=".xlf") tmp_in.write(file.read()); tmp_in.flush() out = pathlib.Path(tmp_in.name).with_stem(f"{tmp_in.name}_{target}") translate_xlf(tmp_in.name, target, out) return out demo = gr.Interface(fn=translate, inputs=[gr.File(label="Fichier XLF"), gr.Textbox(label="Langue cible", value="fr")], outputs=gr.File()) demo.launch()