-
-
Notifications
You must be signed in to change notification settings - Fork 83
use google translator v2 #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Reviewer's Guide by SourceryThis pull request introduces a Sequence diagram for the translate commandsequenceDiagram
participant User
participant Client
participant Translator
User->>Client: /translate <target_lang> <text>
Client->>Translator: translate(text, targetlang)
alt Translation successful
Translator-->>Client: Translation Result
Client-->>User: Translated text
else Translation error
Translator-->>Client: Error message
Client-->>User: Error message
end
Sequence diagram for the tr_inline functionsequenceDiagram
participant User
participant Client
participant Translator
User->>Client: InlineQuery: <target_lang> <text>
Client->>Translator: detect(text)
Translator-->>Client: Source Language
Client->>Translator: translate(text, sourcelang, targetlang)
alt Translation successful
Translator-->>Client: Translation Result
Client-->>User: Translated text
else Translation error
Translator-->>Client: Error message
Client-->>User: Error message
end
Updated class diagram for TranslatorclassDiagram
class Translator {
- base_url: str
- headers: dict
+ __init__(base_url: str)
+ detect(text: str) dict
+ translate(text: str, sourcelang: str, targetlang: str) dict
}
note for Translator "Handles translation tasks using an external API."
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Sunda001 - I've reviewed your changes and found some issues that need to be addressed.
Blocking issues:
- The password 'rahasia' is hardcoded in the headers. (link)
Overall Comments:
- Consider using environment variables or a configuration file to manage the
base_url
andheaders
in theTranslator
class. - The inline query handler uses
translation.text
even when the translate function returns an error; it should use thetext
variable instead.
Here's what I looked at during the review
- 🟡 General issues: 2 issues found
- 🔴 Security: 1 blocking issue
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Summary by Sourcery
Refactor the translation functionality to use a new Google Translate API (v2) via an external service. This change includes creating a
Translator
class to handle API requests and error handling, and updating the translate command and inline query to use the new API.