Skip to content

feat: added command and models for pre-population of spanish content#1117

Merged
irfanuddinahmad merged 11 commits into
iahmad/algolia-spanishfrom
iahmad/spanish-content
Dec 15, 2025
Merged

feat: added command and models for pre-population of spanish content#1117
irfanuddinahmad merged 11 commits into
iahmad/algolia-spanishfrom
iahmad/spanish-content

Conversation

@irfanuddinahmad

Copy link
Copy Markdown
Contributor

This pull request introduces a new system for pre-computing and storing Spanish translations of content metadata, improving Algolia indexing performance by avoiding inline translation API calls. It adds a new ContentTranslation model, migration, management command for batch translation, and updates the indexing logic to use pre-computed translations when available. The admin interface and utility functions are also updated to support these changes.

Content Translation Model and Database Migration

  • Adds a new ContentTranslation model to store pre-computed translations for each ContentMetadata object, including translated fields, language code, and a source hash for change detection. Includes a migration to create this model and its indexes. [1] [2]

Translation Management and Utilities

  • Introduces a management command (populate_spanish_translations.py) to batch-translate content metadata, store results in ContentTranslation, and support options for force, batch size, language, and dry run.
  • Adds a compute_source_hash utility function to detect changes in source content and avoid unnecessary re-translation.

Algolia Indexing Pipeline Updates

  • Updates the Algolia indexing pipeline to use pre-computed Spanish translations from ContentTranslation when available, falling back to inline translation only if necessary. The function signature for create_spanish_algolia_object is updated to accept the source object for translation lookup. [1] [2] [3]

Admin Interface Enhancements

  • Registers the new ContentTranslation model in the Django admin with appropriate list, filter, and search fields for easier management and visibility. [1] [2]

Logging Improvements

  • Adds logging to translation and indexing utilities to improve observability and debugging of the translation workflow. [1] [2] [3]

These changes together enable more efficient and reliable Spanish content indexing, with improved admin and operational support.

Post-review

  • Squash commits into discrete sets of changes
  • Ensure that once the changes have been deployed to stage, prod is manually deployed

@irfanuddinahmad irfanuddinahmad merged commit 449cd43 into iahmad/algolia-spanish Dec 15, 2025
6 checks passed
@irfanuddinahmad irfanuddinahmad deleted the iahmad/spanish-content branch December 15, 2025 19:20
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.

1 participant