wordpress-website-lifecycle/check-installation/wp-invalid-lang.sh
2025-04-19 05:15:35 +02:00

23 lines
637 B
Bash
Executable file

#!/bin/bash
#
# Find WordPress translations not matching the core's available languages.
#
# VERSION :0.1.2
# DEPENDS :apt-get install wget jq
WP_ORG_CORE_TRANSLATIONS="https://api.wordpress.org/translations/core/1.0/"
set -e
LANGS_REGEXP="en_US|$(wget -q -O- "$WP_ORG_CORE_TRANSLATIONS" | jq -r '."translations" | map(."language") | join("|")'
while read -r MO; do
MO_LANG="$(basename "$MO")"
MO_LANG="${MO_LANG##*-}"
MO_LANG="${MO_LANG%.mo}"
if grep -q -x -E "$LANGS_REGEXP" <<<"$MO_LANG"; then
continue
fi
echo "Unknown language code: ${MO}" 1>&2
done < <(find . -type f -name "*.mo")