Skip to content
Snippets Groups Projects
Commit d0482512 authored by CaTasTrOOf's avatar CaTasTrOOf Committed by Pierre-Jean CHANCELLIER
Browse files

Script verify i18 n

parent a66bd23b
No related branches found
No related tags found
1 merge request!12Script verify i18 n
#!/bin/bash
# Color for echo
RED='\e[31m'
GREEN='\e[32m'
BLUE='\e[34m'
UNDERLINE='\e[4m'
BOLD='\e[1m'
NC='\e[0m'
if ! command -v jq &> /dev/null
then
echo -e "${RED}I require jq but it's not installed."
echo -e "${BOLD}${GREEN}See informations here : ${NC}${BLUE}${UNDERLINE}https://stedolan.github.io/jq/download/${NC}"
echo -e "${RED}We can't check if you have put all i18n keys in JSON files${NC}"
exit 0
else
$(git rev-parse --show-toplevel)/utils/findMissingI18nKeys.sh
FINDING_MISSING_KEYS=$?
echo -e "$BLUE$FINDING_MISSING_KEYS$NC"
if [ $FINDING_MISSING_KEYS -ne 0 ]; then
echo -e "${RED}You must to complete all i18n keys used in pages${NC}"
git st i18n/locales/*.json
exit $FINDING_MISSING_KEYS
fi
fi
exit 0
......@@ -89,3 +89,7 @@ sw.*
# Vim swap files
*.swp
# Script generated files
*.missing
keysUsed
\ No newline at end of file
......@@ -4,11 +4,16 @@
This project needs NodeJS v16
In order to use the hooks, this project needs :
- jq ([Site pour le download](https://stedolan.github.io/jq/download/))
## Contribute
```bash
$ git clone https://git.duniter.org/paidge/wotwizard-ui.git
$ cd wotwizard-ui
$ git config --local core.hooksPath .githooks/
$ nvm use 16
$ git checkout -b my-branch
$ npm install
......
......@@ -12,8 +12,8 @@
"developpeurs": "Développeurs :",
"graphql": "API grahQL",
"participants": "Liste des participants au projet :",
"title": "À propos",
"testeurs": "Testeurs :",
"title": "À propos",
"traducteurs": "Traducteurs :"
},
"aurevoir": "Au revoir à",
......@@ -83,8 +83,8 @@
"title": "Mes favoris",
"use": "Mes favoris uniquement"
},
"futuremembers": "Futures entrées",
"futureexits": "Futures sorties",
"futuremembers": "Futures entrées",
"infos": "Informations",
"inout": "Entrées et sorties de la toile de confiance des 2 derniers jours",
"inpreparation": "En préparation",
......@@ -168,8 +168,8 @@
"pardate": "Prévisions par date",
"parmembre": "Prévisions par membres",
"period": {
"title": "Période de recherche",
"desc": "Sélectionnez le nombre de jours souhaités"
"desc": "Sélectionnez le nombre de jours souhaités",
"title": "Période de recherche"
},
"title": "Prévisions"
},
......
#!/bin/bash
# Color for echo
RED='\e[31m'
GREEN='\e[32m'
NC='\e[0m'
TMP_FILE=temp
KEY_FILE=keysUsed
# Get all used keys in Vue files
grep --include=\*.vue --exclude=\*template.vue -roE -e "\\\$(t|tc)\((\"|')([a-zA-Z.]*)(\"|')(, [a-zA-Z._]*){0,1}\)" . > $TMP_FILE
sed -i -e "s/'/\"/" $TMP_FILE
sed -i -e "s/'/\"/" $TMP_FILE
sed -i -E -e 's/\..*:\$(t|tc)\("([a-zA-Z.]*).*$/\2/' $TMP_FILE
# Remove duplicates keys
sort $TMP_FILE | uniq > $KEY_FILE
# Verify all i18n files
FILES="i18n/locales/*.json"
RETURN_CODE=0
for f in $FILES
do
echo -e "Processing ${GREEN}$f${NC} file..."
tmp=$(mktemp)
while read key; do
# Verify if key exists
jq -e ".$key" $f > /dev/null
status=$?
# If not, create it
if [ $status -ne 0 ]
then
echo -e "create ${RED}$key${NC} in file ${GREEN}$f${NC}"
value=$(jq -e ".$key" i18n/locales/fr.json)
if [ "$value" == "null" ]
then
filter=".$key = \"TO_TRANSLATE\""
else
filter=".$key = $value"
fi
jq --sort-keys "$filter" $f > "$tmp" && mv "$tmp" $f
RETURN_CODE=$((RETURN_CODE+1))
fi
done < $KEY_FILE
done
rm $KEY_FILE $TMP_FILE
# Return 0 if no key was created, or number of keys added
exit $RETURN_CODE
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment