Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Set the default language based on Accept-Language
Browse files
app.py
CHANGED
@@ -497,9 +497,17 @@ with gr.Blocks() as demo_submission:
|
|
497 |
submission_result,
|
498 |
)
|
499 |
|
|
|
500 |
# Main demo
|
501 |
|
502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
503 |
def update_language(language: str) -> gr.Markdown:
|
504 |
if language == "🇺🇸 EN":
|
505 |
return gr.Markdown(value=INTRODUCTION_TEXT)
|
@@ -541,6 +549,7 @@ with gr.Blocks(css=custom_css, css_paths="style.css", theme=gr.themes.Base()) as
|
|
541 |
)
|
542 |
gr.HTML(BOTTOM_LOGO)
|
543 |
|
|
|
544 |
language.change(
|
545 |
fn=update_language,
|
546 |
inputs=language,
|
|
|
497 |
submission_result,
|
498 |
)
|
499 |
|
500 |
+
|
501 |
# Main demo
|
502 |
|
503 |
|
504 |
+
def set_default_language(request: gr.Request) -> gr.Dropdown:
|
505 |
+
if request.headers["Accept-Language"].split(",")[0].lower().startswith("ja"):
|
506 |
+
return gr.Dropdown(value="🇯🇵 JP")
|
507 |
+
else:
|
508 |
+
return gr.Dropdown(value="🇺🇸 EN")
|
509 |
+
|
510 |
+
|
511 |
def update_language(language: str) -> gr.Markdown:
|
512 |
if language == "🇺🇸 EN":
|
513 |
return gr.Markdown(value=INTRODUCTION_TEXT)
|
|
|
549 |
)
|
550 |
gr.HTML(BOTTOM_LOGO)
|
551 |
|
552 |
+
demo.load(fn=set_default_language, outputs=language)
|
553 |
language.change(
|
554 |
fn=update_language,
|
555 |
inputs=language,
|