Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language support is broken #569

Open
acidjunk opened this issue Mar 16, 2024 · 0 comments
Open

Language support is broken #569

acidjunk opened this issue Mar 16, 2024 · 0 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@acidjunk
Copy link
Collaborator

acidjunk commented Mar 16, 2024

When a language file exists in the orchestrator: the core doesn't see or use it.

Not sure if that's a bug in core or in the example app.

As a workaround: I'm now using a "translations" endpoint in the example app.

from pathlib import Path
from typing import Dict
import site

import structlog
from fastapi import Query
from fastapi.routing import APIRouter

from orchestrator.services.translations import _deep_merge_dict, _load_translations_file, Translations

from settings import settings

logger = structlog.get_logger(__name__)


router = APIRouter()

def generate_translations(language: str) -> Translations:
    orchestrator_core_path = Path(site.getsitepackages()[0]) / "orchestrator" / "workflows" / "translations"
    core_translations = _load_translations_file(language, orchestrator_core_path)
    user_translations = _load_translations_file(language, settings.TRANSLATIONS_DIR if settings.TRANSLATIONS_DIR else Path(__file__).parent.parent.parent.parent / "translations")
    return _deep_merge_dict(core_translations, user_translations)


@router.get("/{language}", response_model=dict)
def get_translations(language: str) -> Dict[str, str]:
    translations = generate_translations(language)

    return translations

As it's actually not possible to re-add an already existing endpoint I had to apply this dirty hack in the main:

from orchestrator import OrchestratorCore
from orchestrator.cli.main import app as core_cli
from orchestrator.settings import AppSettings

import products  # noqa: F401  Side-effects
import workflows  # noqa: F401  Side-effects
from api.api_v1.api import api_router

app = OrchestratorCore(base_settings=AppSettings())

if __name__ == "__main__":
    core_cli()
else:
    app.register_graphql()
    # remove the existing translation endpoint, so we can override it:
    app.router.routes = [route for route in app.router.routes if not route.__dict__["path"] == "/api/translations/{language}"]
    app.include_router(api_router, prefix="/api")

NOTE The v2 GUI: configures a lot of endpoint stuff in configuration.ts -> but the translations endpoint can't be configured there. @ricardovdheijden / @DutchBen

@pboers1988 pboers1988 transferred this issue from workfloworchestrator/example-orchestrator Mar 18, 2024
@hanstrompert hanstrompert added the bug Something isn't working label Mar 3, 2025
@Mark90 Mark90 added the good first issue Good for newcomers label Mar 5, 2025
@saket-geant saket-geant self-assigned this Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants