build_i18n.sh (859B)
1 #!/usr/bin/env bash 2 3 set -eu 4 5 # FIXME: test wp is even available as a command ... 6 7 # Check for required version. 8 WPCLI_VERSION=$(wp cli version | cut -f2 -d' ') 9 if [ ${WPCLI_VERSION:0:1} -lt "2" -o ${WPCLI_VERSION:0:1} -eq "2" -a ${WPCLI_VERSION:2:1} -lt "1" ]; 10 then 11 echo "WP-CLI version 2.1.0 or greater is required to make JSON translation files" 12 exit 1 13 fi 14 15 # HELPERS. 16 GREEN='\033[0;32m' 17 GREY='\033[0;38m' 18 NC='\033[0m' # No Color 19 UNDERLINE_START='\e[4m' 20 UNDERLINE_STOP='\e[0m' 21 22 # Substitute JS source references with build references. 23 for T in $(find languages -name "*.pot") 24 do 25 echo -e "\n${GREY}${UNDERLINE_START}Fixing references for: ${T}${UNDERLINE_STOP}${NC}" 26 sed \ 27 -e 's/ resources\/js\/frontend\/[^:]*:/ assets\/frontend\/blocks.js:/gp' \ 28 "$T" | uniq > "$T-build" 29 30 rm "$T" 31 mv "$T-build" "$T" 32 echo -e "${GREEN}Done${NC}" 33 done