Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

.\scripts\Windows\starter.ps1
if ($LASTEXITCODE -ne 0) {
    exit $LASTEXITCODE
}

if (-not (Test-Path '.env'))
{
    Write-Warning ".env file not found. Exiting without running Docker steps."
    exit 0
}

Write-Host "Checking placeholders in PO files..." -ForegroundColor Magenta
docker compose exec app poetry run python manage.py check_translated -l en-GB -l ar-AR -l cs-CZ -l da-DK -l de-DE -l en-US -l es-ES -l fr-FR -l hi-IN -l it-IT -l ja-JP -l kk-KZ -l nl-NL -l pl-PL -l pt-BR -l ro-RO -l ru-RU -l zh-hans -a core -a geo -a payments -a vibes_auth -a blog -a root
if ($LASTEXITCODE -ne 0) {
    exit $LASTEXITCODE
}
Write-Host "PO files have no placeholder issues!" -ForegroundColor Green

Write-Host "Compiling PO files into MO files..." -ForegroundColor Magenta
docker compose exec app poetry run python manage.py compilemessages -l en_GB -l ar_AR -l cs_CZ -l da_DK -l de_DE -l en_US -l es_ES -l fr_FR -l hi_IN -l it_IT -l ja_JP -l kk_KZ -l nl_NL -l pl_PL -l pt_BR -l ro_RO -l ru_RU -l zh_Hans
if ($LASTEXITCODE -ne 0) {
    exit $LASTEXITCODE
}
Write-Host "Compiled successfully!" -ForegroundColor Green
