feat: add tui interactive interface to work with llm translation#1007
Closed
feat: add tui interactive interface to work with llm translation#1007
Conversation
Co-Authored-By: Becca <beccalin.8359@gmail.com>
Comment on lines
+215
to
+224
| 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") |
Member
There was a problem hiding this comment.
Suggested change
| 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) |
What about using argparse instead of sys.argv?
Comment on lines
+199
to
+205
| 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.") |
Member
There was a problem hiding this comment.
Suggested change
| 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.") |
There's a missing space at the end of the first line that causes 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.
| else: | ||
| self.notify("Failed to generate translation", severity="error") | ||
| except Exception as e: | ||
| self.notify(f"Error: {str(e)}", severity="error") |
Member
There was a problem hiding this comment.
Suggested change
| self.notify(f"Error: {str(e)}", severity="error") | |
| self.notify(f"Error: {e}", severity="error") |
The str() is not necessary here.
Comment on lines
+142
to
+148
| 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.") |
Member
There was a problem hiding this comment.
Suggested change
| 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.") |
This has the same bug (Chinesefor) as the other prompt. Since it looks duplicated, it might be better to factor it out, and reusing it in both places instead.
Collaborator
Author
|
Close it since I believe the newest Copilot Agent translation flow will be more user-friendly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new interactive translation application using the
textualframework and integrates Google Generative AI for translation tasks. It also includes updates to the dependencies in thepyproject.tomlfile.New interactive translation application:
.scripts/interactive_translate/main.py: Added a newTranslationAppclass using thetextualframework 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 dependenciestextual,powrap, andgoogle-generativeaito support the new translation application.