Skip to content

Conversation

@sajidurdev
Copy link
Contributor

Summary of Changes:

1. Language Detection Module:

  • Used Franc as a replacement module for language detection, instead of langdetect.

2. Refactored Language Detection Logic:

  • Adapted the procedure in detecting the language to utilize franc (prompt for enhanced precision.

3. Variable Renaming:

  • They renamed detectedLangCode into detectedLang to follow consistency and clarity.

4. Error Handling Improvement:

  • Error handling when transcribing with franc.

5. Removed Translate Call for Prompt:

  • Removed unnecessary English translation of the prompt and reduced the steps involved in the process.

6. Consistent Async/Await:

  • Made sure that the async/await was applied uniformly for the asynchronous operations in the entire code.

7. Modularized Code:

  • Incorporated distinct duties (translateText, and makeApiRequest) for greater modularity.

8. Error Handling for API Requests:

  • Improved error handling when processing failed API requests.

9. Improved Comments:

  • Updated or additional clarifying comments about what each function accomplishes, plus flow of the code.

10. Function Renaming:

  • Rename the res variable to translatedPrompt for ease of understanding.

Code optimization encompassed modularization, having unique functions for translation and API queries, frequent usage of ‘async/await’ for improved readability, and thorough exception handling. By switching from ’langdetect’ to franc, language detection became smoother and more accurate. These adjustments are made to make this translation module more practical and sustainable.
Copy link
Contributor

@npmnishantsharma npmnishantsharma left a comment

Choose a reason for hiding this comment

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

  1. Franc is an ejs module for which you have to configure it
  2. Language code of franc are different from translate-google

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants