kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Extract the context_translation plugin into python_packages

Open rtibbles opened this issue 5 months ago • 1 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

Extract the in-context translation plugin from kolibri/plugins/context_translation into its own package under python_packages/. It is an internal, translation-workflow-only plugin that need not ship in the Kolibri package. The extraction is bootstrapped with kolibri plugin create (its first real use), then the existing code is moved across.

Complexity: Low Target branch: develop

Context

  • The in-tree plugin ContextTranslationPlugin sets kolibri_option_defaults — LANGUAGES=ach-ug plus Crowdin/Google-fonts CSP_HOST_SOURCES.
  • It sets django_settings that patch django.conf.locale.LANG_INFO to add the ach-ug in-context pseudo-language.
  • Its JIPTHeadHook(FrontEndBaseHeadHook) injects a static jipt.js plus Crowdin's CDN jipt.js into <head>.
  • Files: kolibri_plugin.py, option_defaults.py, settings.py, static/assets/context_translation/jipt.js (with stale committed .gz/.file_size artifacts).
  • No webpack build → the closest kolibri plugin create surface is backend-only; the head hook, static asset, settings, and option defaults are moved across, not generated.

The Change

  • Scaffold python_packages/kolibri-context-translation-plugin/ with kolibri plugin create (backend-only surface), then move the plugin's code across.
  • Carry JIPTHeadHook, option_defaults.py, and settings.py across unchanged.
  • Commit jipt.js as source.
  • Add a package build script that runs kolibri-build compress over the plugin's static/, generating .gz/.file_size at build time (matching Kolibri core).
  • Gitignore the compressed outputs.
  • Drop the stale committed .gz/.file_size.
  • Declare the kolibri.plugins entry point in the package's pyproject.toml; include-package-data ships the compressed static asset.
  • Remove kolibri/plugins/context_translation/ and its entry in the root pyproject.toml.

Acceptance Criteria

General

  • [ ] python_packages/kolibri-context-translation-plugin/ exists as a uv workspace member with its own pyproject.toml declaring the kolibri.plugins entry point.
  • [ ] A package build script runs kolibri-build compress over the plugin's static/; jipt.js is committed source, and .gz/.file_size are generated at build time, not committed.
  • [ ] kolibri/plugins/context_translation/ and its root pyproject.toml entry-point line are removed.
  • [ ] Enabling the package injects the JIPT <head> scripts; disabling removes them.
  • [ ] Enabling the package registers the ach-ug pseudo-language; disabling reverts it.
  • [ ] Enabling the package applies the LANGUAGES/CSP_HOST_SOURCES option defaults; disabling reverts them.

Testing

  • [ ] Building the package's wheel (frontend build + compress) and enabling it in a Kolibri install exposes the plugin as discoverable/enable-able and serves the compressed jipt.js.

References

  • In-tree plugin being extracted: kolibri/plugins/context_translation
  • Package-layout exemplar (backend + settings/options + static): python_packages/kolibri-oidc-client-plugin

AI usage

Drafted with Claude Code, which read the in-tree plugin and the build/publish tooling; I drove every scope decision. I verified the surface mapping and static-asset handling against the migrated exemplar packages before creating the issue.

rtibbles avatar Jul 05 '26 04:07 rtibbles

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 13 '26 02:07 rtibblesbot