# Maintainer: Guillaume ALAUX <guillaume@archlinux.org>

pkgname=mythes-fr
pkgver=2.3
pkgrel=4
pkgdesc="French thesaurus"
arch=('any')
url="https://www.dicollecte.org/"
license=('LGPL')
optdepends=('libmythes: offers thesaurus library functions')
source=("https://www.dicollecte.org/download/fr/thesaurus-v${pkgver}.zip")
md5sums=('0bfb1c5188bf19237885ee2cf2793edc')

package() {
  install -Dm644 thes_fr.idx ${pkgdir}/usr/share/mythes/th_fr_FR_v2.idx
  install -Dm644 thes_fr.dat ${pkgdir}/usr/share/mythes/th_fr_FR_v2.dat

  pushd "${pkgdir}"/usr/share/mythes/
  fr_FR_aliases="fr_BE fr_CA fr_CH fr_LU"
  for lang in ${fr_FR_aliases}; do
        ln -s th_fr_FR_v2.idx "th_"${lang}"_v2.idx"
        ln -s th_fr_FR_v2.dat "th_"${lang}"_v2.dat"
  done
  popd

  # the symlinks
  install -dm755 "${pkgdir}"/usr/share/myspell/dicts
  pushd "${pkgdir}"/usr/share/myspell/dicts
    for file in "${pkgdir}"/usr/share/mythes/*; do
      ln -s /usr/share/mythes/$(basename ${file}) .
    done
  popd

  # docs
  install -Dm644 README_thes_fr.txt \
                "${pkgdir}"/usr/share/doc/${pkgname}/README_th_fr_FR_v2.txt
}
