#!/bin/sh

GUIDE="The_Official_Raspberry_Pi_Beginners_Guide_5th_Edition.pdf"

FRGUIDE="Le_guide_officiel_du_debutant_Raspberry_Pi_5th_ed.pdf"
DEGUIDE="Das_offizielle_Raspberry_Pi-Handbuch_fur_Einsteiger_5th_ed.pdf"
ITGUIDE="La_guida_introduttiva_ufficiale_Raspberry_Pi_5th_ed.pdf"
ESGUIDE="La_guia_oficial_de_Raspberry_Pi_para_principiantes_5th_ed.pdf"
PTGUIDE="Guia_Oficial_Raspberry_Pi_para_Iniciantes_5th_ed.pdf"

LANG=$(echo $LC_ALL | cut -c 1-2)

if [ "$LANG" = "fr" ] && [ -e /usr/share/userguide/$FRGUIDE ] ; then
    GUIDE=$FRGUIDE
elif [ "$LANG" = "de" ] && [ -e /usr/share/userguide/$DEGUIDE ] ; then
    GUIDE=$DEGUIDE
elif [ "$LANG" = "it" ] && [ -e /usr/share/userguide/$ITGUIDE ] ; then
    GUIDE=$ITGUIDE
elif [ "$LANG" = "es" ] && [ -e /usr/share/userguide/$ESGUIDE ] ; then
    GUIDE=$ESGUIDE
elif [ "$LANG" = "pt" ] && [ -e /usr/share/userguide/$PTGUIDE ] ; then
    GUIDE=$PTGUIDE
fi

xdg-open /usr/share/userguide/$GUIDE
