openedx / edx-django-utils

edX utilities for Django Application development.
https://edx.readthedocs.io/projects/edx-django-utils/en/latest/
Apache License 2.0
26 stars 20 forks source link

feat: Provide i18n `atlas pull` for Django apps (IDAs) plugins | FC-0012 #380

Open OmarIthawi opened 9 months ago

OmarIthawi commented 9 months ago

This module could feature an atlas_pull_by_module function which can be extracted from the edx-platform repository to benefit other IDAs (Python micro-services).

def atlas_pull_by_modules(module_names, locale_root, pull_options):
    """
    Atlas pull translations by module name instead of repository name.
    """
    atlas_pull_args = [
        # Asterisk (*) is used instead of the repository name because it's not known at runtime.
        # The `--expand-glob` option is used to expand match any repository name that has the right module name.
        f'translations/*/{module_name}/conf/locale:{module_name}'
        for module_name in module_names
    ]
    subprocess.run(
        args=['atlas', 'pull', '--expand-glob', *pull_options, *atlas_pull_args],
        check=True,
        cwd=locale_root,
    )

Other classes such as BaseAtlasPullCommand can be extracted to this repository to make the edx-platform less of a monolith while allowing other IDAs to have a pull_plugin_translations Django command:

Related

FC-0012 Project

This issue was reported during the FC-0012 project which implements the Translation Infrastructure update OEP-58.