aboutsummaryrefslogtreecommitdiff
path: root/scripts/assert-translations.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-11-03 17:12:22 -0300
committerEuAndreh <eu@euandre.org>2020-11-03 17:12:22 -0300
commit8f99b1f5fc02dc2b39f312b06018e4072444e6b9 (patch)
tree729bf082877949178d951f659011ee781cc87853 /scripts/assert-translations.sh
parentStart using mdpo for translating pages (diff)
downloadeuandre.org-8f99b1f5fc02dc2b39f312b06018e4072444e6b9.tar.gz
euandre.org-8f99b1f5fc02dc2b39f312b06018e4072444e6b9.tar.xz
Initial automation of translations
Diffstat (limited to '')
-rwxr-xr-xscripts/assert-translations.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/assert-translations.sh b/scripts/assert-translations.sh
new file mode 100755
index 0000000..ce4161c
--- /dev/null
+++ b/scripts/assert-translations.sh
@@ -0,0 +1,26 @@
+#!/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'); 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" --quiet --save --po-filepath "$OUT"
+ done
+ fi
+done
+
+for f in $(find . -type f -name '*.md' | grep -v '^./vendor' | grep -v '^./_site'); do
+ l="$(grep '^lang: ..$' "$f" | awk '{print $2}')"
+ if [[ "$l" != 'en' ]]; then
+ ref="$(grep '^ref: ' "$f" | awk '{print $2}')"
+ FROM=$(find $(find . -name '*.md' -exec grep -l "^ref: $ref$" {} \;) -exec grep -l '^lang: en$' {} \;)
+ po2md "$FROM" --pofiles "locale/$l/LC_MESSAGES/$ref.po" --quiet --save "$f"
+ fi
+done