INNER CODE UNIT · Python

start_pretranslation

rignaneseleo/SlimSocial-for-Facebook · .github/scripts/crowdin_pretranslate.py:64

def start_pretranslation(language_ids):
    return api(f"/projects/{PROJECT_ID}/pre-translations", "POST",
               body={"languageIds": language_ids, "fileIds": [file_id],
                     "method": "mt", "engineId": MT_ENGINE_ID},
               ok_errors=("notSupportedByMT",))


targets = api(f"/projects/{PROJECT_ID}")["data"]["targetLanguageIds"]
pt = start_pretranslation(targets)
if pt is None:
    # The engine rejected some languages; drop them and retry with the rest.
    # (Unsupported ones keep their English fallback until translated by hand.)
    import re
    listing = re.search(r"Languages \[([^]]*)\]", LAST_ERROR or "")
    unsupported = set(listing.group(1).split(",")) if listing else set()
    targets = [t for t in targets if t not in unsupported]
    print(f"skipping {len(unsupported)} languages not supported by MT: "
          f"{sorted(unsupported)}")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…