Skip to content
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

feature: Implement Glossaries for Firestore Translate Text Extension #2254

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

Gustolandia
Copy link
Contributor

@Gustolandia Gustolandia commented Jan 14, 2025

Overview

This pull request introduces support for glossaries in the Firestore Translate Text Extension. The feature allows for domain-specific translations, ensuring certain terms remain unaltered during translation or are translated as defined in a glossary. The implementation addresses the need for unmutable names, enhancing translation accuracy and flexibility.

Changes Made

1. Glossary Integration

  • Added support for the Google Cloud Translation API's glossary feature.
  • Updated the extension's parameters to include the following:
    • GLOSSARY_ID: Allows users to specify the ID of a glossary.
    • SOURCE_LANGUAGE_CODE: Required when using a glossary to define the source language.
  • Ensured the feature respects glossary case sensitivity and added validation for glossary IDs.

2. Extension Configuration Updates

  • Modified extension.yaml to:
    • Add GLOSSARY_ID, SOURCE_LANGUAGE_CODE, and GOOGLE_APPLICATION_CREDENTIALS parameters.
    • Mark GOOGLE_APPLICATION_CREDENTIALS as type: secret for enhanced security.
    • Include detailed descriptions and links to relevant documentation (e.g., how to create a glossary).
    • Clarified that glossaries require Translation Hub to be enabled.
    • Highlighted glossary case sensitivity.

3. Codebase Enhancements

  • Updated translation logic to conditionally include glossary configurations in API requests.
  • Ensured glossaries are only applied when specified and validated.
  • Improved error handling for glossary-related operations.
    • Added logs and console output to track issues such as invalid glossary IDs or missing source language codes.
  • Ensured minimal changes to existing functionality while integrating glossaries.

4. Testing

  • Unit Tests:
    • Added new tests for glossary validation and integration:
      • Valid glossary IDs.
      • Error handling for invalid or non-existent glossaries.
      • Ensured translation requests include glossary configurations when specified.
    • Updated mocks to handle glossary-related scenarios, including errors and edge cases.
  • Manual Testing:
    • Verified glossary functionality by manually testing with Firestore documents.
    • Tested various scenarios including valid glossaries, invalid glossaries, and translations without glossaries.

5. Documentation

  • Updated README.md, PREINSTALL.md, and POSTINSTALL.md to:
    • Provide step-by-step instructions for enabling and using glossaries.
    • Include links to relevant resources (e.g., supported languages, glossary creation guide).
    • Clarify requirements such as source language specification and Translation Hub enablement.
    • Document the case-sensitive nature of glossaries.
    • Add troubleshooting tips for common glossary-related errors.

Manual Testing

Performed manual testing on a separate example app:

  • Test Scenarios:
    • Translations with and without glossaries.
    • Glossaries with case-sensitive IDs.
    • Validating that translations respect glossary definitions.
  • Results:
    • Confirmed that the source language is required when using glossaries.
    • Validated translations with various glossary setups.
    • Debugged and resolved issues related to glossary integration during testing.

Additional Notes

  • The implementation ensures backward compatibility for users not leveraging glossaries.
  • Glossary integration is limited to the Cloud Translation API and requires specific project setup.
  • Enhanced logging and error handling improve debuggability and user feedback.

Thank you for reviewing this pull request. Please feel free to provide feedback or suggest further enhancements.

fixes: #2099

@Gustolandia Gustolandia added type: feature request New feature or request extension: firestore-translate-text Related to firestore-translate-text extension labels Jan 14, 2025
@Gustolandia Gustolandia self-assigned this Jan 14, 2025
@Gustolandia Gustolandia requested a review from a team as a code owner January 14, 2025 02:01
README.md Show resolved Hide resolved
firestore-translate-text/extension.yaml Show resolved Hide resolved
firestore-translate-text/extension.yaml Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension: firestore-translate-text Related to firestore-translate-text extension type: feature request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[firestore-translate-text] Source text is translated from Latin and not English
2 participants