| Dec | JAN | Feb |
| 03 | ||
| 2025 | 2026 | 2027 |
COLLECTED BY
Collection: Save Page Now
To see all available qualifiers, see our documentation.
Sign in /textual framework and integrates Google Generative AI for translation tasks. It also includes updates to the dependencies in the pyproject.toml file.
New interactive translation application:
●.scripts/interactive_translate/main.py: Added a new TranslationApp class using the textual framework to provide an interactive UI for translating PO files. The application supports navigation through entries, accepting translations, generating translations using Google Generative AI, and saving changes.
Dependency updates:
●.scripts/pyproject.toml: Added new dependencies textual, powrap, and google-generativeai to support the new translation application.
Sorry, something went wrong.
" data-pjax="true" class="Link--secondary markdown-title" href="/web/20260103075334/https://github.com/python/python-docs-zh-tw/pull/1007/commits/6ce73cdfe199711d652ebbc0f0127f67a4379691">feat: add tui interactive interface to work with llm translation
6ce73cd
Co-Authored-By: Becca <beccalin.8359@gmail.com>ezio-melotti reviewed
| def main(po_file_path: str): | ||
| app = TranslationApp(Path(po_file_path)) | ||
| app.run() | ||
|
|
||
| if __name__ == "__main__": | ||
| import sys | ||
| if len(sys.argv) > 1: | ||
| main(sys.argv[1]) | ||
| else: | ||
| print("Please provide a PO file path") |
| def main(po_file_path: str): | |
| app = TranslationApp(Path(po_file_path)) | |
| app.run() | |
| if __name__ == "__main__": | |
| import sys | |
| if len(sys.argv) > 1: | |
| main(sys.argv[1]) | |
| else: | |
| print("Please provide a PO file path") | |
| def main(po_file_path: str): | |
| app = TranslationApp(po_file_path) | |
| app.run() | |
| if __name__ == "__main__": | |
| import argparse | |
| desc = 'TUI for LLM translations' | |
| parser = argparse.ArgumentParser(description=desc) | |
| parser.add_argument('po_file_path', type=Path, | |
| help='Path to the PO file to translate') | |
| args = parser.parse_args() | |
| main(args.po_file_path) |
argparse instead of sys.argv?
Sorry, something went wrong.
| prompt = ("Translate the following Python documentation into Traditional Chinese" | ||
| f"for {self.po_file_path}:{entry.occurrences} with message {entry.msgid[1]}. Ensure " | ||
| "that the translation is accurate and uses appropriate technical terminology. The" | ||
| " output must be in Traditional Chinese. Pay careful attention to context, idiomatic" | ||
| " expressions, and any specialized vocabulary related to Python programming. Maintain " | ||
| "the structure and format of the original documentation as much as possible to ensure" | ||
| " clarity and usability for readers.") |
| prompt = ("Translate the following Python documentation into Traditional Chinese" | |
| f"for {self.po_file_path}:{entry.occurrences} with message {entry.msgid[1]}. Ensure " | |
| "that the translation is accurate and uses appropriate technical terminology. The" | |
| " output must be in Traditional Chinese. Pay careful attention to context, idiomatic" | |
| " expressions, and any specialized vocabulary related to Python programming. Maintain " | |
| "the structure and format of the original documentation as much as possible to ensure" | |
| " clarity and usability for readers.") | |
| prompt = ("Translate the following Python documentation into Traditional Chinese " | |
| f"for {self.po_file_path}:{entry.occurrences} with message {entry.msgid[1]}. Ensure " | |
| "that the translation is accurate and uses appropriate technical terminology. The " | |
| "output must be in Traditional Chinese. Pay careful attention to context, idiomatic " | |
| "expressions, and any specialized vocabulary related to Python programming. Maintain " | |
| "the structure and format of the original documentation as much as possible to ensure " | |
| "clarity and usability for readers.") |
Chinesefor to be merged together. While I was at it I made the spacing of the other lines consistent, by moving all the spaces at the end of the sentences.
Sorry, something went wrong.
| else: | ||
| self.notify("Failed to generate translation", severity="error") | ||
| except Exception as e: | ||
| self.notify(f"Error: {str(e)}", severity="error") |
| self.notify(f"Error: {str(e)}", severity="error") | |
| self.notify(f"Error: {e}", severity="error") |
str() is not necessary here.
Sorry, something went wrong.
| prompt = ("Translate the following Python documentation into Traditional Chinese" | ||
| f"for {self.po_file_path}:{entry.occurrences} with message {entry.msgid}. Ensure " | ||
| "that the translation is accurate and uses appropriate technical terminology. The" | ||
| " output must be in Traditional Chinese. Pay careful attention to context, idiomatic" | ||
| " expressions, and any specialized vocabulary related to Python programming. Maintain " | ||
| "the structure and format of the original documentation as much as possible to ensure" | ||
| " clarity and usability for readers.") |
| prompt = ("Translate the following Python documentation into Traditional Chinese" | |
| f"for {self.po_file_path}:{entry.occurrences} with message {entry.msgid}. Ensure " | |
| "that the translation is accurate and uses appropriate technical terminology. The" | |
| " output must be in Traditional Chinese. Pay careful attention to context, idiomatic" | |
| " expressions, and any specialized vocabulary related to Python programming. Maintain " | |
| "the structure and format of the original documentation as much as possible to ensure" | |
| " clarity and usability for readers.") | |
| prompt = ("Translate the following Python documentation into Traditional Chinese " | |
| f"for {self.po_file_path}:{entry.occurrences} with message {entry.msgid}. Ensure " | |
| "that the translation is accurate and uses appropriate technical terminology. The " | |
| "output must be in Traditional Chinese. Pay careful attention to context, idiomatic " | |
| "expressions, and any specialized vocabulary related to Python programming. Maintain " | |
| "the structure and format of the original documentation as much as possible to ensure " | |
| "clarity and usability for readers.") |
Chinesefor) as the other prompt. Since it looks duplicated, it might be better to factor it out, and reusing it in both places instead.
Sorry, something went wrong.
|
Close it since I believe the newest Copilot Agent translation flow will be more user-friendly. |
Sorry, something went wrong.
ezio-melotti
Successfully merging this pull request may close these issues.