change link in translation to match file name

This commit is contained in:
rick 2023-01-17 23:22:37 +01:00
parent a16178d86e
commit 14c26b8a23
Signed by: Rick
GPG key ID: 4A6223D66294EB20
2 changed files with 32 additions and 1 deletions

View file

@ -113,7 +113,7 @@ fi
mkdir $target
for l in $(ls $files)
for l in $(ls -d $files/*/ | cut -d\/ -f2)
do
generate_header lang/$l/header.link
echo "Create folder $l in $target..."
@ -158,6 +158,31 @@ do
done
done
echo "Header links translation..."
mapfile translateHeader < lang/links.config
langs=${translateHeader[0]}
nbLang=$(echo "$langs" | grep -c "|")
for (( i=1; i<${#translateHeader[@]}; i++ ))
do
# pour chaque langue
for j in $(seq 0 $nbLang)
do
currentLang=$(echo ${translateHeader[0]} | cut -d\| -f$(( $j + 1 )) | tr -d " ")
currentFile=$(echo ${translateHeader[$i]} | cut -d\| -f$(( $j + 1 )) | tr -d " ")
# on doit modifier son lien de traduction
for k in $(seq 0 $nbLang)
do
[[ $k -eq $j ]] && continue
lang=$(echo ${translateHeader[0]} | cut -d\| -f$(( $k + 1 )) | tr -d " ")
file=$(echo ${translateHeader[$i]} | cut -d\| -f$(( $k + 1 )) | tr -d " ")
sed -i -e "s/href=\"\/$lang\/.*\.html/href=\"\/$lang\/$file.html/" www/$currentLang/$currentFile.html
done
done
done
echo "Copy $annexes in $target..."
cp -t $target -r $annexes

6
lang/links.config Normal file
View file

@ -0,0 +1,6 @@
fr |en
apropos |about
autres |others
copaings|friends
ou |where
projets |projects