Skip to content

Commit fed1f3b

Browse files
Copilotasadali145
andcommitted
Apply PR #760 glossary path changes to ol_openedx_ai_static_translations
Co-authored-by: asadali145 <52656433+asadali145@users.noreply.github.com> Agent-Logs-Url: https://github.com/mitodl/open-edx-plugins/sessions/eaab10e1-8468-4675-9118-cd9b1fdac54e
1 parent feae6ed commit fed1f3b

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

src/ol_openedx_ai_static_translations/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Usage
4343
./manage.py cms sync_and_translate_language el
4444
4545
# With specific provider and model
46-
./manage.py cms sync_and_translate_language el --provider openai --model gpt-5.2 --glossary
46+
./manage.py cms sync_and_translate_language el --provider openai --model gpt-5.2 --glossary /path/to/glossary
4747
4848
License
4949
*******

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Usage:
55
./manage.py cms sync_and_translate_language el
66
./manage.py cms sync_and_translate_language el \\
7-
--provider openai --model gpt-4-turbo --glossary
7+
--provider openai --model gpt-4-turbo --glossary /path/to/glossary
88
"""
99

1010
import json
@@ -27,7 +27,6 @@
2727
from django.core.management.base import BaseCommand, CommandError
2828
from litellm import completion
2929

30-
import ol_openedx_ai_static_translations.utils as utils_module
3130
from ol_openedx_ai_static_translations.constants import (
3231
HTTP_CREATED,
3332
HTTP_NOT_FOUND,
@@ -733,11 +732,13 @@ def add_arguments(self, parser):
733732
)
734733
parser.add_argument(
735734
"--glossary",
736-
action="store_true",
737-
default=False,
738-
help="Use glossary from plugin glossaries folder. "
739-
"Looks for {plugin_dir}/glossaries/machine_learning/{iso_code}.txt "
740-
"(uses --iso-code when given, else lang code).",
735+
dest="glossary",
736+
required=False,
737+
default=None,
738+
help=(
739+
"Path to glossary directory. Should contain language-specific "
740+
"files (e.g. {iso_code}.txt)."
741+
),
741742
)
742743
parser.add_argument(
743744
"--batch-size",
@@ -1066,16 +1067,16 @@ def fallback_template() -> str:
10661067
return templates_by_count.get(num_categories) or fallback_template()
10671068

10681069
def _load_glossary(self, options: dict, iso_code: str) -> dict[str, Any]:
1069-
"""Load glossary if enabled. Uses ISO code for file lookup.
1070+
"""Load glossary from directory. Uses ISO code for file lookup.
10701071
10711072
iso_code is already normalized (e.g. es_419). Tries {iso_code}.txt first,
10721073
then {iso_code with underscores→hyphens}.txt (e.g. es-419.txt) if not found.
10731074
"""
1074-
if not options.get("glossary", False):
1075+
glossary_dir = options.get("glossary")
1076+
if not glossary_dir:
10751077
return {}
10761078

1077-
utils_file = Path(utils_module.__file__)
1078-
base_dir = utils_file.parent / "glossaries" / "machine_learning"
1079+
base_dir = Path(glossary_dir)
10791080
candidates = [
10801081
base_dir / f"{iso_code}.txt",
10811082
base_dir / f"{iso_code.replace('_', '-')}.txt",

0 commit comments

Comments
 (0)