OCEANAI / app /event_handlers /languages.py
DmitryRyumin's picture
Summary
2d3271b
raw
history blame
1.84 kB
"""
File: languages.py
Author: Elena Ryumina and Dmitry Ryumin
Description: Selected language event handlers for Gradio app.
License: MIT License
"""
import gradio as gr
# Importing necessary components for the Gradio app
from app.description import DESCRIPTIONS
from app.description_steps import STEP_1
from app.config import config_data
from app.components import (
files_create_ui,
dropdown_create_ui,
)
def event_handler_languages(languages, files):
if languages.lower() == "english":
lang_id = 0
choices = config_data.Settings_LANGUAGES_EN
elif languages.lower() == "russian":
lang_id = 1
choices = config_data.Settings_LANGUAGES_RU
else:
lang_id = 0
choices = config_data.Settings_LANGUAGES_EN
return (
gr.Markdown(value=DESCRIPTIONS[lang_id]),
gr.HTML(value=STEP_1[lang_id]),
gr.Image(
value=config_data.StaticPaths_IMAGES + config_data.Images_LANGUAGES[lang_id]
),
dropdown_create_ui(
label=None,
info=None,
choices=choices,
value=choices[lang_id],
visible=True,
show_label=False,
elem_classes="dropdown-language-container",
),
gr.Tab(config_data.Labels_APP_LABEL[lang_id]),
gr.Tab(config_data.Labels_ABOUT_APP_LABEL[lang_id]),
gr.Tab(config_data.Labels_ABOUT_AUTHORS_LABEL[lang_id]),
gr.Tab(config_data.Labels_REQUIREMENTS_LABEL[lang_id]),
files_create_ui(
value=files,
label="{} ({})".format(
config_data.OtherMessages_VIDEO_FILES[lang_id],
", ".join(config_data.Settings_SUPPORTED_VIDEO_EXT),
),
file_types=[f".{ext}" for ext in config_data.Settings_SUPPORTED_VIDEO_EXT],
),
)