Skip to content

feat: construct and index Spanish Algolia objects for skills, jobs and industries - #307

Merged
marlonkeating merged 1 commit into
openedx:masterfrom
rgopalrao-sonata-png:rgopalrao/11386
Jun 2, 2026
Merged

feat: construct and index Spanish Algolia objects for skills, jobs and industries#307
marlonkeating merged 1 commit into
openedx:masterfrom
rgopalrao-sonata-png:rgopalrao/11386

Conversation

@rgopalrao-sonata-png

Copy link
Copy Markdown
Contributor

JIRA: https://2u-internal.atlassian.net/browse/ENT-11386

Re-raises and rebases #286 onto the latest master.

Summary

Implements Spanish (and extensible multi-language) localization for the Algolia jobs index. For each enabled locale in TAXONOMY_TRANSLATION_LOCALES, a duplicate set of Algolia records is created with translated names and descriptions from the existing TaxonomyTranslation model. All records (English + localized) are indexed in a single atomic operation with zero downtime.

Key Changes

taxonomy/algolia/utils.py

  • build_name_translation_maps(language_code) — builds {English name → Translated name} dicts for jobs/skills/industries using one DB query per locale (O(1) lookup during translation)
  • translate_skill_dict, translate_industries_array, translate_job_record — translation helpers that preserve schema and fall back to English when no translation exists
  • create_localized_job_records — orchestrates building translation maps and producing localized job variants
  • index_jobs_data_in_algolia — loops over TAXONOMY_TRANSLATION_LOCALES, appends localized batches before the atomic Algolia write
  • fetch_jobs_data — stamps each English record with metadata_language: 'en'

taxonomy/algolia/constants.py

  • metadata_language added to Algolia searchable attributes and customRanking
  • TAXONOMY_TRANSLATION_LOCALES = ['es'] — add more ISO codes to enable additional languages, zero code changes needed

taxonomy/tests/test_algolia_translations.py (new, 519 lines)

  • 22 tests covering all new functions; all pass ✅

Version

  • 2.4.03.0.0

Merge Checklist

  • No new migrations required (uses existing TaxonomyTranslation model)
  • Version bumped (3.0.0)
  • Changelog updated
  • All 22 tests pass
  • Rebased on latest upstream/master (68c3f24)
  • Graceful fallback to English when translation is missing

Post Merge

  • Tag pushed and new version released
  • Verify 3.0.0 on PyPI
  • PR created in course-discovery to upgrade taxonomy-connector dependency

@marlonkeating marlonkeating self-assigned this May 26, 2026

@marlonkeating marlonkeating left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed with assistance from Claude Sonnet 4.6

Comment thread taxonomy/algolia/utils.py Outdated
Comment thread taxonomy/algolia/utils.py Outdated
Comment thread taxonomy/algolia/utils.py Outdated
Comment thread taxonomy/algolia/constants.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds multi-locale (starting with Spanish) support to the Algolia jobs index by duplicating English job records into per-locale variants using TaxonomyTranslation, and indexing all languages in one atomic Algolia replace operation.

Changes:

  • Build translation lookup maps and helper translators for jobs/skills/industries; generate localized job-record variants per configured locale.
  • Stamp English records with metadata_language='en' and add language_sort_priority to enforce English-first ranking.
  • Add Algolia index settings updates and a new comprehensive test suite for translation behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
taxonomy/algolia/utils.py Adds translation map builders, record translation helpers, localized job record generation, and multi-locale indexing flow.
taxonomy/algolia/constants.py Adds metadata_language faceting and language_sort_priority custom ranking; defines enabled locales list.
taxonomy/tests/test_algolia_translations.py New tests covering translation mapping and indexing behavior across locales.
taxonomy/init.py Version bump to 3.0.0.
CHANGELOG.rst Adds 3.0.0 changelog entry for the localization/indexing feature.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread taxonomy/algolia/utils.py
Comment thread taxonomy/algolia/utils.py
Comment thread taxonomy/algolia/utils.py
Comment thread taxonomy/algolia/utils.py
Comment thread taxonomy/algolia/constants.py
@rgopalrao-sonata-png
rgopalrao-sonata-png force-pushed the rgopalrao/11386 branch 2 times, most recently from 86ed181 to 726bc7a Compare June 1, 2026 14:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 18 comments.

Comment thread taxonomy/algolia/constants.py
Comment thread taxonomy/algolia/constants.py
Comment thread taxonomy/algolia/utils.py Outdated
Comment thread taxonomy/algolia/utils.py Outdated
Comment thread taxonomy/algolia/utils.py Outdated
Comment thread taxonomy/algolia/utils.py Outdated
Comment thread taxonomy/algolia/utils.py Outdated
Comment thread taxonomy/tests/test_algolia_translations.py Outdated
Comment thread taxonomy/tests/test_algolia_translations.py Outdated
Comment thread CHANGELOG.rst
…d industries

test: improve algolia translation coverage

fix: address review comments - external_id skill keys, early return, searchable metadata_language
@marlonkeating
marlonkeating merged commit 3cb913e into openedx:master Jun 2, 2026
9 checks passed
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.

4 participants