#!/usr/bin/env python3
"""Compile .po files in languages/ to .mo using polib."""
from pathlib import Path

import polib

ROOT = Path(__file__).resolve().parents[1]
DOMAIN = "etchenet-reviews-for-google-business"
LANG = ROOT / "languages"

for loc in ("es_ES", "fr_FR"):
    po_path = LANG / f"{DOMAIN}-{loc}.po"
    if not po_path.exists():
        continue
    po = polib.pofile(str(po_path))
    mo_path = LANG / f"{DOMAIN}-{loc}.mo"
    po.save_as_mofile(str(mo_path))
    print(f"Wrote {mo_path}")
