Skip to content

feat: Add ol_openedx_ai_static_translations plugin; clean up ol_openedx_course_translations#769

Open
Copilot wants to merge 5 commits intomainfrom
copilot/update-ol-openedx-ai-static-translations
Open

feat: Add ol_openedx_ai_static_translations plugin; clean up ol_openedx_course_translations#769
Copilot wants to merge 5 commits intomainfrom
copilot/update-ol-openedx-ai-static-translations

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 24, 2026

Extracts the sync_and_translate_language management command and all supporting sync infrastructure out of ol_openedx_course_translations into a new standalone ol_openedx_ai_static_translations plugin, incorporating the glossary-as-path change from PR #760.

New plugin: ol_openedx_ai_static_translations

  • Flat module layout: constants.py + utils.py at package root (vs nested utils/ in source plugin)
  • CMS-only entry point with own settings (TRANSLATIONS_GITHUB_TOKEN, TRANSLATIONS_REPO_URL, TRANSLATIONS_REPO_PATH, TRANSLATIONS_PROVIDERS, LITE_LLM_REQUEST_TIMEOUT) — uses hasattr guards so it won't clobber if old plugin is also installed
  • --glossary now takes an explicit directory path instead of a boolean flag:
    # Before (resolved glossary relative to plugin dir)
    ./manage.py cms sync_and_translate_language el --glossary
    
    # After (caller supplies path)
    ./manage.py cms sync_and_translate_language el --glossary /path/to/glossary

Cleanup in ol_openedx_course_translations

  • Deleted: management/commands/sync_and_translate_language.py, utils/command_utils.py, utils/translation_sync.py
  • Deleted: glossaries/ directory (both plugins)
  • utils/constants.py stripped to only what remaining code needs: PROVIDER_*, ENGLISH_LANGUAGE_CODE, TRANSLATABLE_ATTRS_*, NEVER_TRANSLATE_ATTRS, XML_FORMAT_ATTR
  • settings/common.py — removed TRANSLATIONS_GITHUB_TOKEN/REPO_URL/REPO_PATH; kept TRANSLATIONS_PROVIDERS and LITE_LLM_REQUEST_TIMEOUT (still used by translate_course and llm_providers)
  • pyproject.toml — removed GitPython, requests, polib (only needed by moved sync code); bumped version 0.5.1 → 0.6.0
  • README.rst — removed sync_and_translate_language section and sync-specific config entries

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Update ol_openedx_ai_static_translations with changes from PR #760 feat: Add ol_openedx_ai_static_translations plugin with PR #760 glossary path changes Mar 24, 2026
Copilot AI requested a review from asadali145 March 24, 2026 09:24
Copilot AI changed the title feat: Add ol_openedx_ai_static_translations plugin with PR #760 glossary path changes feat: Add ol_openedx_ai_static_translations plugin; clean up ol_openedx_course_translations Mar 24, 2026
@asadali145 asadali145 marked this pull request as ready for review March 27, 2026 13:04
@asadali145 asadali145 requested a review from Copilot April 13, 2026 12:03
@asadali145
Copy link
Copy Markdown
Contributor

@copilot rebase this PR

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 13, 2026

@copilot rebase this PR

Done. The branch has been rebased onto the latest main (b8f2ebb). The only conflict was in ol_openedx_course_translations/pyproject.toml — resolved by keeping the litellm==1.82.5 pin from main while retaining our version bump (0.6.0) and removal of the GitPython, requests, and polib deps. The redundant "Bump version" commit was automatically dropped since its content was already incorporated during conflict resolution.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 extracts the static translation sync/LLM translation + PR-creation workflow from ol_openedx_course_translations into a new standalone CMS-only plugin (ol_openedx_ai_static_translations), while slimming down the original course translations plugin to only the remaining course/subtitle translation functionality.

Changes:

  • Introduces ol_openedx_ai_static_translations with the sync_and_translate_language management command and supporting sync/translation utilities.
  • Removes static-sync infrastructure (command + helpers + dependencies + bundled glossaries) from ol_openedx_course_translations.
  • Updates plugin configuration/docs and bumps ol_openedx_course_translations version to 0.6.0.

Reviewed changes

Copilot reviewed 26 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/ol_openedx_course_translations/README.rst Removes static translation sync command documentation/config from the course translations plugin.
src/ol_openedx_course_translations/pyproject.toml Removes sync-only dependencies and bumps plugin version.
src/ol_openedx_course_translations/ol_openedx_course_translations/utils/constants.py Trims constants to only those needed for remaining course translation features.
src/ol_openedx_course_translations/ol_openedx_course_translations/utils/command_utils.py Deletes shared command utilities that were only used by the extracted sync command.
src/ol_openedx_course_translations/ol_openedx_course_translations/settings/common.py Removes static-sync repo/token settings from the course translations plugin settings.
src/ol_openedx_course_translations/ol_openedx_course_translations/glossaries/machine_learning/ar.txt Removes bundled glossary content from the course translations plugin.
src/ol_openedx_course_translations/ol_openedx_course_translations/glossaries/machine_learning/de.txt Removes bundled glossary content from the course translations plugin.
src/ol_openedx_course_translations/ol_openedx_course_translations/glossaries/machine_learning/el.txt Removes bundled glossary content from the course translations plugin.
src/ol_openedx_course_translations/ol_openedx_course_translations/glossaries/machine_learning/es.txt Removes bundled glossary content from the course translations plugin.
src/ol_openedx_course_translations/ol_openedx_course_translations/glossaries/machine_learning/es_419.txt Removes bundled glossary content from the course translations plugin.
src/ol_openedx_course_translations/ol_openedx_course_translations/glossaries/machine_learning/fr.txt Removes bundled glossary content from the course translations plugin.
src/ol_openedx_course_translations/ol_openedx_course_translations/glossaries/machine_learning/ja.txt Removes bundled glossary content from the course translations plugin.
src/ol_openedx_course_translations/ol_openedx_course_translations/glossaries/machine_learning/pt_BR.txt Removes bundled glossary content from the course translations plugin.
src/ol_openedx_course_translations/ol_openedx_course_translations/glossaries/machine_learning/ru.txt Removes bundled glossary content from the course translations plugin.
src/ol_openedx_ai_static_translations/setup.cfg Adds plugin-local tooling config (isort/pytest) consistent with other plugins in this repo.
src/ol_openedx_ai_static_translations/README.rst Adds documentation for the new static translations plugin and its management command.
src/ol_openedx_ai_static_translations/pyproject.toml Defines packaging metadata and dependencies for the new plugin.
src/ol_openedx_ai_static_translations/ol_openedx_ai_static_translations/utils.py Houses extracted sync/translation helpers (validation/config/glossary/PO+JSON sync logic).
src/ol_openedx_ai_static_translations/ol_openedx_ai_static_translations/settings/cms.py Adds CMS-only plugin settings entry point.
src/ol_openedx_ai_static_translations/ol_openedx_ai_static_translations/settings/init.py Provides default settings with hasattr guards to avoid clobbering.
src/ol_openedx_ai_static_translations/ol_openedx_ai_static_translations/management/commands/sync_and_translate_language.py Implements the extracted sync_and_translate_language management command.
src/ol_openedx_ai_static_translations/ol_openedx_ai_static_translations/management/commands/init.py Adds management command package marker.
src/ol_openedx_ai_static_translations/ol_openedx_ai_static_translations/management/init.py Adds management package marker.
src/ol_openedx_ai_static_translations/ol_openedx_ai_static_translations/constants.py Adds constants required for static translation syncing/formatting.
src/ol_openedx_ai_static_translations/ol_openedx_ai_static_translations/apps.py Registers the plugin as a CMS-only Django app via Open edX plugin settings.
src/ol_openedx_ai_static_translations/ol_openedx_ai_static_translations/init.py Adds package marker and short description.
src/ol_openedx_ai_static_translations/LICENSE.txt Adds plugin-local license file.
src/ol_openedx_ai_static_translations/CHANGELOG.rst Adds plugin-local changelog scaffold.
Comments suppressed due to low confidence (1)

src/ol_openedx_ai_static_translations/ol_openedx_ai_static_translations/management/commands/sync_and_translate_language.py:53

  • The command’s --provider argument restricts choices to (openai, gemini, mistral) but uses TRANSLATIONS_PROVIDERS['default_provider'] as the default. If that setting is configured as deepl (common for course translations), argparse will fail even when the user doesn’t pass --provider. Consider only setting the argparse default when it’s in the allowed choices (or include deepl if supported, or validate in handle instead of using choices).

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

@asadali145 asadali145 force-pushed the copilot/update-ol-openedx-ai-static-translations branch from c042ea0 to 877eccb Compare April 13, 2026 12:30
completion_kwargs = dict(base_kwargs)
completion_kwargs["model"] = model

if api_key:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Provider-specific model prefixing in configure_litellm_for_provider is skipped when api_key is None, which can occur with implicit credential discovery, causing incorrect API routing.
Severity: LOW

Suggested Fix

Move the model prefixing logic for Gemini and Mistral providers outside of the if api_key: block. This ensures the model name is always correctly formatted, regardless of how the API key is provided or discovered.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location:
src/ol_openedx_ai_static_translations/ol_openedx_ai_static_translations/utils.py#L184

Potential issue: The function `configure_litellm_for_provider` only adds the required
`gemini/` or `mistral/` prefix to the model name if an `api_key` is explicitly passed.
In scenarios where authentication relies on implicit credential discovery (e.g., Google
credential files) and `api_key` is `None`, the prefix is not added. This can cause
LiteLLM to route requests to an unintended service, such as Vertex AI instead of the
Gemini API, leading to incorrect API usage.

@asadali145 asadali145 requested review from arslanashraf7 and removed request for asadali145 April 14, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants