#!/bin/bash

#create world list form input txt file
cat *.txt  | sed 's/[^A-Za-z]/\n/g' | sort  | uniq > words.list
#translate them
for w in $(cat words.txt ); do echo  "\newglossaryentry{$w}{name=$w,description={$(trans -b $w)}}" ; done | tee glossaryo.tex
#wrap each word with \gls{}
cat outsider.tex | sed 's/\([A-Za-z]\+\)/\\gls{&}/g' >tmp && mv tmp  outsider.tex


#compile
pdflatex foo.tex && makeglossaries foo && pdflatex foo && zathura foo.pdf

