Spaces:
Running
Running
Daryl Lim Claude Opus 4.6 (1M context) commited on
Commit ·
be7cb6a
1
Parent(s): 459c8a5
refactor: extract _format_info helper for info string
Browse filesSingle source of truth for the hint and character count template,
used by both the initial textbox info and the change handler.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
app.py
CHANGED
|
@@ -86,8 +86,12 @@ def translate(
|
|
| 86 |
return result
|
| 87 |
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
def _update_char_count(text: str) -> dict:
|
| 90 |
-
return gr.update(info=
|
| 91 |
|
| 92 |
|
| 93 |
def _translate_with_loading(
|
|
@@ -115,7 +119,7 @@ def _build_demo() -> gr.Blocks:
|
|
| 115 |
lines=6,
|
| 116 |
show_label=False,
|
| 117 |
buttons=["clear"],
|
| 118 |
-
info=
|
| 119 |
)
|
| 120 |
with gr.Column():
|
| 121 |
target_language = gr.Dropdown(
|
|
|
|
| 86 |
return result
|
| 87 |
|
| 88 |
|
| 89 |
+
def _format_info(char_count: int) -> str:
|
| 90 |
+
return f"Press Ctrl+Enter to apply · {char_count} / 2,000"
|
| 91 |
+
|
| 92 |
+
|
| 93 |
def _update_char_count(text: str) -> dict:
|
| 94 |
+
return gr.update(info=_format_info(len(text)))
|
| 95 |
|
| 96 |
|
| 97 |
def _translate_with_loading(
|
|
|
|
| 119 |
lines=6,
|
| 120 |
show_label=False,
|
| 121 |
buttons=["clear"],
|
| 122 |
+
info=_format_info(0),
|
| 123 |
)
|
| 124 |
with gr.Column():
|
| 125 |
target_language = gr.Dropdown(
|