Skip to content

Conversation

hemanth5055
Copy link
Contributor

@hemanth5055 hemanth5055 commented Oct 17, 2025

Pull Request Description:
This PR updates the translation endpoint to make Gemini return both the translated code and the detected source language in a structured, parseable format.

Changes Made

  • Modified handleTranslate function to update the LLM prompt and enforce XML-like tags:

    <TranslatedLanguage>...</TranslatedLanguage>
    <SourceLanguage>...</SourceLanguage>
  • Implemented regex parsing to extract both translation and sourceLanguage from the model’s response.

  • Removed the need for a separate language detection call.

  • Maintained analytics update for translation tracking.

Benefits

  • Reduces API calls by integrating language detection and translation in one request.
  • Provides a consistent, easily parseable response format.
  • Improves latency and simplifies client-side handling.

Testing

  • Verified response structure for multiple languages.
  • Confirmed accurate parsing using regex patterns.
  • Checked that analytics updates still function correctly.

🔖 Related Issue

Fixes #52

@dineshsutihar dineshsutihar self-requested a review October 21, 2025 16:53
@dineshsutihar dineshsutihar added enhancement New feature or request performance improves performance AI feature/issues related to Artificial Intelligence hacktoberfest hacktoberfest-accepted labels Oct 21, 2025
Copy link
Collaborator

@dineshsutihar dineshsutihar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work! 🎉

@dineshsutihar dineshsutihar merged commit b5c20fe into StructZ:develop Oct 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI feature/issues related to Artificial Intelligence enhancement New feature or request hacktoberfest hacktoberfest-accepted performance improves performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat:Combine Translation and Language Detection in Gemini API Response

2 participants