aboutsummaryrefslogblamecommitdiff
path: root/scripts/extract-translations.sh
blob: b0f70ed443fc6f14de5bc447db6341afba7863b4 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                                                                                                      
                                                                         


        
#!/usr/bin/env bash
set -Eeuo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
cd ../

TRANSLATIONS=(pt fr eo)

for f in $(find . -type f -name '*.md' | grep -v '^./vendor' | grep -v '^./_site' | grep -v '^./drafts/' | grep -v './templates/'); do
  file_lang="$(grep '^lang: ..$' "$f" | awk '{print $2}')"
  if [[ "$file_lang" = 'en' ]]; then
    for l in "${TRANSLATIONS[@]}"; do
      OUT="locale/$l/LC_MESSAGES/${f%.md}.po"
      mkdir -p "$(dirname "$OUT")"
      md2po "$f" --include-codeblocks --quiet --save --po-filepath "$OUT"
    done
  fi
done