Localisation updates from https://translatewiki.net. #419
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Translation | |
on: push | |
jobs: | |
regex-json-verification: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Verify Regex and JSON | |
run: | | |
# Run regex verification | |
source_keys=() | |
while IFS= read -r match | |
do | |
# Extract the desired part from the match using awk | |
clean_match=$(echo "$match" | awk -F "['\"]" '{print $2}') | |
source_keys+=("$clean_match") | |
done < <(grep -r -P -o "(?<=§\()['\"]([\w-]+)['\"]" .) | |
if [ ${#source_keys[@]} -gt 0 ] | |
then | |
echo "Regex pattern found in code." | |
else | |
echo "Regex pattern not found." | |
exit 1 | |
fi | |
# Verify JSON keys | |
json_keys=($(jq -r 'keys[]' translations/en.json)) | |
if [ ${#json_keys[@]} -gt 0 ] | |
then | |
echo "JSON source found." | |
else | |
echo "JSON source not found." | |
exit 1 | |
fi | |
#Matching keys | |
MISMATCH_FOUND=false | |
for source_key in "${source_keys[@]}" | |
do | |
KEY_FOUND=false | |
for json_key in "${json_keys[@]}" | |
do | |
if [ "$json_key" = "$source_key" ] | |
then | |
KEY_FOUND=true | |
break | |
fi | |
done | |
if [ "$KEY_FOUND" = false ] | |
then | |
echo "Key ${source_key} is not defined" | |
MISMATCH_FOUND=true | |
fi | |
done | |
if [ "$MISMATCH_FOUND" = true ] | |
then | |
echo "Some asked JSON keys were not found." | |
exit 1 | |
else | |
echo "All asked JSON keys were found." | |
fi | |
#Inverse matching | |
UNUSED_KEYS=false | |
for json_key in "${json_keys[@]}" | |
do | |
KEY_FOUND=false | |
for source_key in "${source_keys[@]}" | |
do | |
if [ "$json_key" = "$source_key" ] | |
then | |
KEY_FOUND=true | |
break | |
fi | |
done | |
if [ "$KEY_FOUND" = false ] | |
then | |
echo "Key ${json_key} is not used" | |
UNUSED_KEYS=true | |
fi | |
done | |
if [ "$UNUSED_KEYS" = true ] | |
then | |
echo "Some JSON keys were not been used." | |
exit 1 | |
else | |
echo "All JSON keys were been used." | |
fi |