Skip to content

i18n support for choices in gr.CheckboxGroup #11611

@freinold

Description

@freinold
  • I have searched to see if a similar issue already exists.

Is your feature request related to a problem? Please describe.

gr.CheckboxGroup supports i18n for the label and info attributes, but the choices don't work currently.
You can repro with the following code:

import gradio as gr


def main() -> None:
    i18n: gr.I18n = gr.I18n(
        en={
            "input_text": "Input Text",
            "formatting_options": "Formatting Options",
            "select_formatting": "Select Formatting Options",
            "bold": "Bold",
            "italic": "Italic",
        }
    )

    def demo_fn(input: str, format: list[str]) -> str:
        if "bold" in format:
            input = f"**{input}**"
        if "italic" in format:
            input = f"_{input}_"
        return input

    demo: gr.Interface = gr.Interface(
        fn=demo_fn,
        inputs=[
            gr.Textbox(label=i18n("input_text")),
            gr.CheckboxGroup(
                label=i18n("formatting_options"),
                choices=[
                    (i18n("bold"), "bold"),
                    (i18n("italic"), "italic"),
                ],
                info=i18n("select_formatting"),
            ),
        ],
        outputs=gr.Markdown(),
    )

    demo.launch(server_name="localhost", i18n=i18n)


if __name__ == "__main__":
    main()

Describe the solution you'd like
All parts of the component should support i18n, including choices.

Additional context

Screenshot:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions