INNER CODE UNIT · Python

load_langs

blokadaorg/blokada · .github/scripts/translation_coverage.py:40

def load_langs():
    """Parse the langs.js module the same way scripts/translate.py does."""
    text = LANGS_JS.read_text(encoding="utf-8").replace("export default ", "")
    data = json.loads(text)
    return data["langs"], data.get("langs-arb", {})


def load_json(path):
    """Load a translation file, or None if missing/unparseable (best-effort)."""
    try:
        with open(path, encoding="utf-8") as f:
            return json.load(f)
    except FileNotFoundError:
        return None
    except (json.JSONDecodeError, OSError) as e:
        warn(f"could not read {path.name}: {e}; treating as uncovered")
        return None

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…