#!/usr/bin/env bash set -Eeuo pipefail cd "$(dirname "${BASH_SOURCE[0]}")" cd ../ for f in $(find _tils -type f -name '*.md' | grep -v '^./vendor/' | grep -v '^./_site/' | grep -v './drafts/' | grep -v './templates/'); do l="$(grep '^lang: ..$' "$f" | awk '{print $2}')" if [[ "$l" != 'en' ]]; then ref="$(grep '^ref: ' "$f" | awk '{print $2}')" # shellcheck disable=2046 FROM=$(find $(find . -name '*.md' -exec grep -l "^ref: $ref$" {} \;) -exec grep -l '^lang: en$' {} \;) po2md "$FROM" --pofiles "locale/$l/LC_MESSAGES/${FROM%.md}.po" --quiet --save "$f" fi done