# Template file for 'libreoffice-dictionaries'
pkgname=libreoffice-dictionaries
version=25.2.1.2
revision=1
build_style=meta
hostmakedepends="mythes perl"
short_desc="Libre Office Dictionaries"
maintainer="Đoàn Trần Công Danh <congdanhqx@gmail.com>"
license="GPL-3.0-or-later"
homepage="https://www.libreoffice.org/"
distfiles="https://download.documentfoundation.org/libreoffice/src/${version%.*}/${pkgname}-${version}.tar.xz"
# distfiles="https://download.nus.edu.sg/mirror/tdf/libreoffice/src/${version%.*}/${pkgname}-${version}.tar.xz"
# distfiles="https://mirrors.nju.edu.cn/tdf/libreoffice/src/${version%.*}/${pkgname}-${version}.tar.xz"
checksum=10ecf3a02bed8ef72c167552c65d23e484181c6b657d668c47dc9e2c735e5375

depends="hunspell-af hyphen-af
 hunspell-an
 hunspell-ar mythes-ar
 hunspell-be hyphen-be
 hunspell-bg hyphen-bg mythes-bg
 hunspell-bn
 hunspell-bo
 hunspell-br
 hunspell-bs
 hunspell-ca_ES hyphen-ca mythes-ca
 hunspell-ckb
 hunspell-cs hyphen-cs mythes-cs
 hunspell-da_DK hyphen-da mythes-da
 hunspell-de hyphen-de mythes-de
 hunspell-el_GR hyphen-el
 hunspell-en virtual?hunspell-en_GB hyphen-en mythes-en
 hunspell-eo hyphen-eo mythes-eo
 hunspell-es hyphen-es mythes-es
 hunspell-et hyphen-et
 hunspell-fa
 hunspell-fr_FR hyphen-fr mythes-fr
 hunspell-gd
 hunspell-gl hyphen-gl mythes-gl
 hunspell-gu
 hunspell-gug mythes-gug
 hunspell-he
 hunspell-hi
 hunspell-hr hyphen-hr
 hunspell-hu hyphen-hu mythes-hu
 hunspell-id hyphen-id mythes-id
 hunspell-is hyphen-is mythes-is
 hunspell-it_IT hyphen-it_IT mythes-it_IT
 hunspell-kmr
 hunspell-ko
 hunspell-lo
 hunspell-lt hyphen-lt
 hunspell-lv hyphen-lv mythes-lv
 hunspell-mn hyphen-mn
 hunspell-ne mythes-ne
 hunspell-nl_NL hyphen-nl_NL
 hunspell-no hyphen-no mythes-no
 hunspell-oc
 hunspell-pl hyphen-pl mythes-pl
 hunspell-pt_BR hyphen-pt_BR mythes-pt_BR
 hunspell-pt_PT hyphen-pt_PT mythes-pt_PT
 hunspell-ro_RO hyphen-ro mythes-ro
 hunspell-ru_RU hyphen-ru mythes-ru
 hunspell-si
 hunspell-sk hyphen-sk mythes-sk
 hunspell-sl hyphen-sl mythes-sl
 hunspell-sq hyphen-sq
 hunspell-sr hyphen-sr
 hunspell-sv hyphen-sv mythes-sv
 hunspell-sw
 hunspell-te hyphen-te
 hunspell-th hyphen-th
 hunspell-tr
 hunspell-uk hyphen-uk mythes-uk
 hunspell-vi
 hyphen-zu"

build_options="bdic"
desc_option_bdic="Enable Chromium's bdic format"

if [ "$XBPS_WORDSIZE" = 64 ]; then
	hostmakedepends+=" qt6-webengine"
	build_options_default="bdic"
else
	case "$XBPS_MACHINE" in
	i686*)
		hostmakedepends+=" qt5-webengine"
		build_options_default="bdic"
		;;
	esac
fi

_drop_long_dic() {
	local lang="$1"
	local len="$2"
	local dir="${3:-$lang}"
	cp "dictionaries/$dir/$lang.aff" bdic/
	sed "/.\\{$len\\}/d" dictionaries/$dir/$lang.dic >"bdic/$lang.dic"
}

_build_bdic() {
	local file base lang dic
	PATH="/usr/lib/qt6/libexec:/usr/lib/qt5/bin:$PATH"

	mkdir -p bdic
	# convert-dict not understand TAB
	sed 's/\t/ /' "dictionaries/an_ES/an_ES.aff" >"bdic/an_ES.aff"
	cp "dictionaries/an_ES/an_ES.dic" bdic/

	# convert-dict works on fixed array of utf-16 characters.
	_drop_long_dic da_DK 112
	_drop_long_dic gl_ES 111 gl
	_drop_long_dic gu_IN 45
	_drop_long_dic ko_KR 173
	_drop_long_dic th_TH 45
	# convert-dict not understand IGNORE
	for lang in ar bo ckb hu_HU uk_UA; do
		sed '/^IGNORE/d' "dictionaries/$lang/$lang.aff" >"bdic/$lang.aff"
		cp "dictionaries/$lang/$lang.dic" bdic/
	done

	find dictionaries -name '*.aff' |
	while read file; do
		base="${file%.aff}"
		lang="${base##*/}"
		echo "converting: $lang"
		if [ -f "bdic/$lang.aff" ]; then
			dic="bdic/$lang.dic"
		else
			dic="${base}.dic"
		fi
		qwebengine_convert_dict "${dic}" "bdic/$lang.bdic"
	done
}

_vbdic() {
	if [ "$build_option_bdic" ]; then
		vmkdir usr/share/hunspell-bdic
		vinstall "bdic/$1.bdic" 0644 usr/share/hunspell-bdic
	fi
}

_vbdiclink() {
	if [ "$build_option_bdic" ]; then
		ln -sf "$1.bdic" "${PKGDESTDIR}/usr/share/hunspell-bdic/$2.bdic"
	fi
}

_vhunspell() {
	local subdir lang lnk
	if [ "$1" = -d ]; then
		subdir=$2
		shift 2
	fi
	: "${subdir:=$1}"
	lang="$1"
	shift
	vmkdir usr/share/hunspell
	vinstall "dictionaries/$subdir/$lang.aff" 0644 \
		usr/share/hunspell "$lang.aff"
	vinstall "dictionaries/$subdir/$lang.dic" 0644 \
		usr/share/hunspell "$lang.dic"
	_vbdic "$lang"
	for lnk; do
		ln -sf "$lang.aff" "${PKGDESTDIR}/usr/share/hunspell/$lnk.aff"
		ln -sf "$lang.dic" "${PKGDESTDIR}/usr/share/hunspell/$lnk.dic"
		_vbdiclink "$lang" "$lnk"
	done
}

_vhyphen() {
	local subdir lang lnk
	if [ "$1" = -d ]; then
		subdir=$2
		shift 2
	fi
	: "${subdir:=$1}"
	lang="$1"
	shift
	vmkdir usr/share/hyphen
	vinstall "dictionaries/$subdir/hyph_${lang}.dic" 0644 usr/share/hyphen
	for lnk; do
		ln -s "hyph_$lang.dic" \
			"${PKGDESTDIR}/usr/share/hyphen/hyph_$lnk.dic"
	done
}

_vmythes() {
	local subdir lang lnk
	local ver=
	if [ "$1" = -v ]; then ver="_v$2"; shift 2; fi
	if [ "$1" = -d ]; then
		subdir=$2
		shift 2
	fi
	: "${subdir:=$1}"
	lang="$1"
	shift
	vmkdir usr/share/mythes
	vinstall "dictionaries/$subdir/th_${lang}${ver}.dat" \
		0644 usr/share/mythes
	vinstall "dictionaries/$subdir/th_${lang}${ver}.idx" \
		0644 usr/share/mythes
	for lnk; do
		ln -s "th_$lang$ver.dat" \
			"${PKGDESTDIR}/usr/share/mythes/th_$lnk$ver.dat"
		ln -s "th_$lang$ver.idx" \
			"${PKGDESTDIR}/usr/share/mythes/th_$lnk$ver.idx"
	done
}

do_build() {
	local file

	if [ "$build_option_bdic" ]; then
		_build_bdic
	fi

	find dictionaries -name 'th_*.dat' |
	while read file; do
		th_gen_idx.pl <"$file" >"${file%.dat}.idx"
	done
}

post_patch() {
	mv dictionaries/be_BY/{be-official,be_BY}.aff
	mv dictionaries/be_BY/{be-official,be_BY}.dic
	mv dictionaries/ckb/dictionaries/ckb.{aff,dic} dictionaries/ckb/

	mv dictionaries/de/de_AT_frami.aff dictionaries/de/de_AT.aff
	mv dictionaries/de/de_AT_frami.dic dictionaries/de/de_AT.dic
	mv dictionaries/de/de_CH_frami.aff dictionaries/de/de_CH.aff
	mv dictionaries/de/de_CH_frami.dic dictionaries/de/de_CH.dic
	mv dictionaries/de/de_DE_frami.aff dictionaries/de/de_DE.aff
	mv dictionaries/de/de_DE_frami.dic dictionaries/de/de_DE.dic

	mv dictionaries/fa_IR/{fa-IR,fa_IR}.aff
	mv dictionaries/fa_IR/{fa-IR,fa_IR}.dic

	mv dictionaries/cs_CZ/{thes,th}_cs_CZ.dat
	mv dictionaries/gl/{thesaurus,th}_gl.dat
	mv dictionaries/ru_RU/th_ru_RU{_M_aot_and,}_v2.dat
	mv dictionaries/fr_FR/{thes,th}_fr.dat
}

do_install() {
	:
}

# pkgname is:
# - if unavailable: only language; break
# - if lower version: keep old name; break
# - use only language, provides and replaces
hunspell-af_package() {
	short_desc="Afrikaans dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-or-later"
	pkg_install() {
		_vhunspell af_ZA af_NA
	}
}

hyphen-af_package() {
	short_desc="Afrikaans hyphenation rules"
	license="LGPL-2.1-or-later"
	pkg_install() {
		_vhyphen af_ZA af_NA
	}
}

hunspell-an_package() {
	short_desc="Aragonese dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-3.0-or-later, LGPL-3.0-or-later, MPL-1.1"
	pkg_install() {
		_vhunspell an_ES
	}
}

hunspell-ar_package() {
	short_desc="Arabic dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-or-later, LGPL-2.1-or-later, MPL-1.1, MPL-2.0"
	pkg_install() {
		_vhunspell ar ar_SA ar_DZ ar_BH ar_EG ar_IQ ar_JO \
			ar_KW ar_LB ar_LY ar_MA ar_OM ar_QA ar_SD \
			ar_SY ar_TN ar_AE ar_YE
	}
}

mythes-ar_package() {
	short_desc="Arabic thesaurus for LibreOffice"
	license="GPL-2.0-or-later, LGPL-2.1-or-later, MPL-1.1, MPL-2.0"
	pkg_install() {
		_vmythes ar ar_SA ar_DZ ar_BH ar_EG ar_IQ ar_JO \
			ar_KW ar_LB ar_LY ar_MA ar_OM ar_QA ar_SD \
			ar_SY ar_TN ar_AE ar_YE
	}
}

hunspell-be_package() {
	short_desc="Belarusian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-3.0-only, CC-BY-SA-4.0"
	pkg_install() {
		_vhunspell be_BY
	}
}

hyphen-be_package() {
	short_desc="Belarusian hyphenation rules"
	license="LGPL-3.0-only, CC-BY-SA-4.0"
	pkg_install() {
		_vhyphen be_BY
	}
}

hunspell-bg_package() {
	short_desc="Bulgarian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-only"
	pkg_install() {
		_vhunspell bg_BG
	}
}

hyphen-bg_package() {
	short_desc="Bulgarian hyphenation rules"
	license="GPL-2.0-only"
	pkg_install() {
		_vhyphen bg_BG
	}
}

mythes-bg_package() {
	short_desc="Bulgarian thesaurus for LibreOffice"
	license="GPL-2.0-only"
	pkg_install() {
		_vmythes -v 2 bg_BG
	}
}

hunspell-bn_package() {
	short_desc="Bengali dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-only"
	pkg_install() {
		_vhunspell bn_BD bn_IN
	}
}

hunspell-bo_package() {
	short_desc="Tibetan dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="CC0-1.0"
	pkg_install() {
		_vhunspell bo bo_CN bo_IN
	}
}

hunspell-br_package() {
	short_desc="Breton dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-or-later"
	pkg_install() {
		_vhunspell br_FR
	}
}

hunspell-bs_package() {
	short_desc="Bosnian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-or-later, GPL-2.0-or-later, MPL-1.1"
	pkg_install() {
		_vhunspell bs_BA bs
	}
}

hunspell-ca_ES_package() {
	short_desc="Catalan dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-or-later, GPL-2.0-or-later"
	pkg_install() {
		_vhunspell -d ca/dictionaries ca ca_ES ca_AD ca_FR ca_IT
		_vhunspell -d ca/dictionaries ca-valencia \
			ca@valencia ca_ES@valencia
	}
}

hyphen-ca_package() {
	short_desc="Catalan hyphenation rules"
	license="LGPL-2.1-or-later, GPL-2.0-or-later"
	pkg_install() {
		_vhyphen -d ca/dictionaries ca \
			ca_ES ca_ES@valencia ca_AD ca_FR ca_IT
	}
}

mythes-ca_package() {
	short_desc="Catalan thesaurus for LibreOffice"
	license="CC-BY-4.0"
	pkg_install() {
		_vmythes -v 3 -d ca/dictionaries ca_ES \
			ca_ES@valencia ca_AD ca_FR ca_IT
	}
}

hunspell-ckb_package() {
	short_desc="Central Kurdish (Sorani) dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="CC-BY-SA-4.0"
	pkg_install() {
		_vhunspell ckb ckb-IR ckb-IQ
	}
}

hunspell-cs_package() {
	short_desc="Czech dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GFDL-1.1-or-later"
	pkg_install() {
		_vhunspell cs_CZ
	}
}

hyphen-cs_package() {
	short_desc="Czech hyphenation rules"
	license="GPL-1.0-or-later"
	pkg_install() {
		_vhyphen cs_CZ
	}
}

mythes-cs_package() {
	short_desc="Czech thesaurus for LibreOffice"
	license="GFDL-1.1-or-later"
	pkg_install() {
		_vmythes cs_CZ
	}
}

hunspell-da_DK_package() {
	short_desc="Danish dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-or-later, GPL-2.0-or-later, MPL-1.1"
	pkg_install() {
		_vhunspell da_DK
	}
}

hyphen-da_package() {
	short_desc="Danish hyphenation rules"
	license="LGPL-2.1-or-later"
	pkg_install() {
		_vhyphen da_DK
	}
}

mythes-da_package() {
	short_desc="Danish thesaurus for LibreOffice"
	license="LGPL-2.1-or-later, GPL-2.0-or-later, MPL-1.1"
	pkg_install() {
		_vmythes da_DK
	}
}

hunspell-de_package() {
	short_desc="German dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-or-later, GPL-2.0-or-later, MPL-1.1"
	provides="hunspell-de_CH-20240301_1 hunspell-de_DE-20240301_1"
	replaces="hunspell-de_CH>=0 hunspell-de_DE>=0"
	pkg_install() {
		_vhunspell -d de de_AT
		_vhunspell -d de de_CH
		_vhunspell -d de de_DE
	}
}

hyphen-de_package() {
	short_desc="German hyphenation rules"
	license="LGPL-2.1-or-later, GPL-2.0-only, GPL-3.0-only"
	pkg_install() {
		_vhyphen -d de de_AT
		_vhyphen -d de de_CH
		_vhyphen -d de de_DE
	}
}

mythes-de_package() {
	short_desc="German thesaurus for LibreOffice"
	license="LGPL-2.1-or-later, GPL-2.0-only, GPL-3.0-only"
	pkg_install() {
		_vmythes -v 2 -d de de_CH
		_vmythes -v 2 -d de de_DE de_AT
	}
}

hunspell-el_GR_package() {
	short_desc="Greek dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-or-later, GPL-2.0-or-later, MPL-1.1"
	pkg_install() {
		_vhunspell el_GR
	}
}

hyphen-el_package() {
	short_desc="Greek hyphenation rules"
	license="LGPL-2.1-or-later"
	pkg_install() {
		_vhyphen el_GR
	}
}

hunspell-en_package() {
	short_desc="English dictionary for hunspell"
	depends="virtual?hunspell-en_GB hunspell-qtwebengine-dict"
	license="custom:SCOWL, LGPL-2.1-or-later"
	provides="hunspell-en_AU-2024_1
	 hunspell-en_CA-2024_1
	 hunspell-en_US-2024_1"
	replaces="hunspell-en_AU>=0 hunspell-en_CA>=0 hunspell-en_US>=0"
	pkg_install() {
		_vhunspell -d en en_AU
		_vhunspell -d en en_CA
		_vhunspell -d en en_US en_IL en_PH
		_vhunspell -d en en_ZA en_MW en_NA en_ZW
		vlicense dictionaries/en/README_en_AU.txt
		vlicense dictionaries/en/README_en_CA.txt
		vlicense dictionaries/en/README_en_US.txt
	}
}

hunspell-en_GB-all_package() {
	short_desc="British English dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="custom:SCOWL"
	provides="hunspell-en_GB-2024_1"
	replaces="hunspell-en_GB>=0"
	pkg_install() {
		_vhunspell -d en en_GB en_BS en_BZ en_GH en_IE en_IN en_JM \
			en_NZ en_TT
		vlicense dictionaries/en/README_en_GB.txt
	}
}

hyphen-en_package() {
	short_desc="English hyphenation rules"
	license="custom:SCOWL"
	pkg_install() {
		_vhyphen -d en en_GB \
			en_BS en_BZ en_GH en_IE en_IN en_JM en_NZ en_TT \
			en_AU en_CA en_ZA en_MW en_NA en-ZW
		_vhyphen -d en en_US en_IL en_PH
		vlicense dictionaries/en/WordNet_license.txt
	}
}

mythes-en_package() {
	short_desc="English thesaurus for LibreOffice"
	license="MIT"
	pkg_install() {
		_vmythes -v 2 -d en en_US en_IL en_PH en_GB \
			en_BS en_BZ en_GH en_IE en_IN en_JM en_NZ en_TT \
			en_AU en_CA en_ZA en_MW en_NA en-ZW
		vlicense dictionaries/en/WordNet_license.txt
	}
}

hunspell-eo_package() {
	short_desc="Esperanto dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-3.0-or-later"
	reverts="20100216_1"
	pkg_install() {
		_vhunspell eo
	}
}

hyphen-eo_package() {
	short_desc="Esperanto hyphenation rules"
	license="GPL-3.0-or-later"
	pkg_install() {
		_vhyphen eo
	}
}

mythes-eo_package() {
	short_desc="Esperanto thesaurus for LibreOffice"
	license="GPL-3.0-or-later"
	pkg_install() {
		_vmythes eo
	}
}

_es_lang="es_AR es_BO es_CL es_CO es_CR es_CU es_DO es_EC es_ES es_GQ es_GT
 es_HN es_MX es_NI es_PA es_PE es_PH es_PR es_PY es_SV es_US es_UY es_VE"
hunspell-es_package() {
	short_desc="Spanish dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	provides="hunspell-es_ES-${version}_${revision}"
	replaces="hunspell-es_ES>=0"
	license="GPL-3.0-or-later, LGPL-3.0-or-later, MPL-1.1"
	pkg_install() {
		local l
		for l in $_es_lang; do
			_vhunspell -d es "$l"
		done
	}
}

hyphen-es_package() {
	short_desc="Spanish hyphenation rules"
	license="GPL-3.0-or-later, LGPL-3.0-or-later, MPL-1.1"
	pkg_install() {
		_vhyphen es $_es_lang
	}
}

mythes-es_package() {
	short_desc="Spanish thesaurus for LibreOffice"
	license="GPL-3.0-or-later, LGPL-3.0-or-later, MPL-1.1"
	pkg_install() {
		_vmythes -v 2 es $_es_lang
	}
}

hunspell-et_package() {
	short_desc="Estonian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-or-later"
	pkg_install() {
		_vhunspell et_EE
	}
}

hyphen-et_package() {
	short_desc="Estonian hyphenation rules"
	license="LGPL-2.1-or-later"
	pkg_install() {
		_vhyphen et_EE
	}
}

hunspell-fa_package() {
	short_desc="Persian dictionary for hunspell by Lilak"
	license="Apache-2.0"
	pkg_install() {
		_vhunspell fa_IR
	}
}

# This is simplified version of hunspell-fr_FR
# hunspell-fr-libreoffice_package() {
# 	short_desc="Modern French dictionary for hunspell by LibreOffice"
# 	license="MPL-1.1"
# 	provides="hunspell-fr_FR-${version}_${revision}"
# 	replaces="hunspell-fr_FR>=0"
# 	pkg_install() {
# 		_vhunspell -d fr_FR fr fr_FR fr_BE fr_CA fr_CH fr_LU fr_MC
# 	}
# }

hyphen-fr_package() {
	short_desc="French hyphenation rules"
	license="MPL-1.1"
	pkg_install() {
		_vhyphen -d fr_FR fr fr_FR fr_BE fr_CA fr_CH fr_LU fr_MC
	}
}

mythes-fr_package() {
	short_desc="French thesaurus for LibreOffice"
	license="MPL-1.1"
	pkg_install() {
		_vmythes -d fr_FR fr fr_FR fr_BE fr_CA fr_CH fr_LU fr_MC
	}
}

hunspell-gd_package() {
	short_desc="Scottish Gaelic dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-3.0-or-later"
	pkg_install() {
		_vhunspell gd_GB
	}
}

hunspell-gl_package() {
	short_desc="Galician dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-3.0-or-later"
	pkg_install() {
		_vhunspell -d gl gl_ES
	}
}

hyphen-gl_package() {
	short_desc="Galician hyphenation rules"
	license="GPL-3.0-or-later"
	pkg_install() {
		_vhyphen gl gl_ES
	}
}

mythes-gl_package() {
	short_desc="Galician thesaurus for LibreOffice"
	license="GPL-3.0-or-later"
	pkg_install() {
		_vmythes gl gl_ES
	}
}

hunspell-gu_package() {
	short_desc="Gujarati dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vhunspell gu_IN
	}
}

hunspell-gug_package() {
	short_desc="Guarani dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GFDL-1.2-or-later"
	pkg_install() {
		_vhunspell gug gug_PY
	}
}

mythes-gug_package() {
	short_desc="Guarani thesaurus for LibreOffice"
	license="GFDL-1.2-or-later"
	pkg_install() {
		_vmythes -d gug gug_PY
	}
}

hunspell-he_package() {
	short_desc="Hebrew dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="AGPL-3.0-or-later"
	pkg_install() {
		_vhunspell he_IL
	}
}

hunspell-hi_package() {
	short_desc="Hindi dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vhunspell hi_IN
	}
}

hunspell-hr_package() {
	short_desc="Croatian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-or-later, GPL-2.0-or-later, MPL-1.1"
	provides="hunspell-hr_HR-20240301_1"
	replaces="hunspell-hr_HR>=0"
	pkg_install() {
		_vhunspell hr_HR
	}
}

hyphen-hr_package() {
	short_desc="Croatian hyphenation rules"
	license="LGPL-2.1-or-later, GPL-2.0-or-later, MPL-1.1"
	pkg_install() {
		_vhyphen hr_HR
	}
}

hunspell-hu_package() {
	short_desc="Hungarian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-3.0-or-later, MPL-2.0"
	pkg_install() {
		_vhunspell hu_HU
	}
}

hyphen-hu_package() {
	short_desc="Hungarian hyphenation rules"
	license="GPL-3.0-or-later, LGPL-3.0-or-later, MPL-2.0"
	pkg_install() {
		_vhyphen hu_HU
	}
}

mythes-hu_package() {
	short_desc="Hungarian thesaurus for LibreOffice"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vmythes -v 2 hu_HU
	}
}

hunspell-id_package() {
	short_desc="Indonesian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-3.0-or-later"
	pkg_install() {
		_vhunspell -d id id_ID
	}
}

hyphen-id_package() {
	short_desc="Indonesian hyphenation rules"
	license="LGPL-3.0-or-later"
	pkg_install() {
		_vhyphen -d id id_ID
	}
}

mythes-id_package() {
	short_desc="Indonesian thesaurus for LibreOffice"
	license="LGPL-3.0-or-later"
	pkg_install() {
		_vmythes -v 2 -d id id_ID
	}
}

hunspell-is_package() {
	short_desc="Icelandic dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="CC-BY-SA-3.0, CC-BY-4.0"
	pkg_install() {
		_vhunspell is is_IS
	}
}

hyphen-is_package() {
	short_desc="Icelandic hyphenation rules"
	license="CC-BY-SA-3.0, CC-BY-4.0"
	pkg_install() {
		_vhyphen is is_IS
	}
}

mythes-is_package() {
	short_desc="Icelandic thesaurus for LibreOffice"
	license="CC-BY-SA-3.0, CC-BY-4.0"
	pkg_install() {
		_vmythes is is_IS
	}
}

hunspell-it_IT_package() {
	short_desc="Italian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-3.0-only, LGPL-3.0-only"
	pkg_install() {
		_vhunspell it_IT
	}
}

hyphen-it_IT_package() {
	short_desc="Italian hyphenation rules"
	license="GPL-3.0-only, LGPL-3.0-only"
	pkg_install() {
		_vhyphen it_IT
	}
}

mythes-it_IT_package() {
	short_desc="Italian thesaurus for LibreOffice"
	license="GPL-3.0-only, LGPL-3.0-only"
	pkg_install() {
		_vmythes -v 2 it_IT
	}
}

hunspell-kmr_package() {
	short_desc="Kurdish dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-3.0-or-later, LGPL-2.1-or-later, MPL-1.1"
	pkg_install() {
		_vhunspell kmr_Latn kmr_Latn-TR kmr_Latn-SY \
			kmr@latin kmr_TR@latin kmr_SY@latin
	}
}

hunspell-ko_package() {
	short_desc="Korean dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-3.0-only"
	pkg_install() {
		_vhunspell ko_KR
	}
}

hunspell-lo_package() {
	short_desc="Lao dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-3.0-only"
	pkg_install() {
		_vhunspell lo_LA
	}
}

hunspell-lt_package() {
	short_desc="Lithuanian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="BSD-3-Clause"
	pkg_install() {
		_vhunspell -d lt_LT lt lt_LT
		vlicense dictionaries/lt_LT/COPYING
	}
}

hyphen-lt_package() {
	short_desc="Lithuanian hyphenation rules"
	license="LPPL-1.3c"
	pkg_install() {
		_vhyphen -d lt_LT lt lt_LT
	}
}

hunspell-lv_package() {
	short_desc="Latvian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-or-later"
	pkg_install() {
		_vhunspell lv_LV
	}
}

hyphen-lv_package() {
	short_desc="Latvian hyphenation rules"
	license="LGPL-2.1-or-later"
	pkg_install() {
		_vhyphen lv_LV
	}
}

mythes-lv_package() {
	short_desc="Latvian thesaurus for LibreOffice"
	license="LGPL-2.1-or-later"
	pkg_install() {
		_vmythes -v 2 lv_LV
	}
}

hunspell-mn_package() {
	short_desc="Mongolian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LPPL-1.3c"
	pkg_install() {
		_vhunspell mn_MN mn mn_Cyrl mn_Cyrl_MN
	}
}

hyphen-mn_package() {
	short_desc="Mongolian hyphenation rules"
	license="LPPL-1.3c"
	pkg_install() {
		_vhyphen mn_MN mn mn_Cyrl mn_Cyrl_MN
	}
}

hunspell-ne_package() {
	short_desc="Nepali dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-only"
	pkg_install() {
		_vhunspell ne_NP
	}
}

mythes-ne_package() {
	short_desc="Nepali thesaurus for LibreOffice"
	license="LGPL-2.1-only"
	pkg_install() {
		_vmythes -v 2 ne_NP
	}
}

hunspell-nl_NL_package() {
	short_desc="Dutch (Netherland) dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="BSD-3-Clause, CC-BY-SA-3.0"
	pkg_install() {
		_vhunspell nl_NL
		vlicense dictionaries/nl_NL/license_en_EN.txt
		vlicense dictionaries/nl_NL/licentie_nl_NL.txt
	}
}

hyphen-nl_NL_package() {
	short_desc="Dutch (Netherland) hyphenation rules"
	license="BSD-3-Clause, CC-BY-SA-3.0"
	pkg_install() {
		_vhyphen nl_NL
		vlicense dictionaries/nl_NL/license_en_EN.txt
		vlicense dictionaries/nl_NL/licentie_nl_NL.txt
	}
}

hunspell-no_package() {
	short_desc="Norwegian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vhunspell -d no nb_NO
		_vhunspell -d no nn_NO
	}
}

hyphen-no_package() {
	short_desc="Norwegian hyphenation rules"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vhyphen -d no nb_NO
		_vhyphen -d no nn_NO
	}
}

mythes-no_package() {
	short_desc="Norwegian thesaurus for LibreOffice"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vmythes -v 2 -d no nb_NO
		_vmythes -v 2 -d no nn_NO
	}
}

hunspell-oc_package() {
	short_desc="Occitan dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vhunspell oc_FR
	}
}

hunspell-pl_package() {
	short_desc="Polish dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-2.1-or-later, GPL-2.0-or-later, MPL-1.1"
	provides="hunspell-pl_PL-20240301_1"
	replaces="hunspell-pl_PL>=0"
	pkg_install() {
		_vhunspell pl_PL
	}
}

hyphen-pl_package() {
	short_desc="Polish hyphenation rules"
	license="LGPL-2.1-or-later, GPL-2.0-or-later, MPL-1.1"
	pkg_install() {
		_vhyphen pl_PL
	}
}

mythes-pl_package() {
	short_desc="Polish thesaurus for LibreOffice"
	license="LGPL-2.1-or-later, GPL-2.0-or-later, MPL-1.1"
	pkg_install() {
		_vmythes -v 2 pl_PL
	}
}

hunspell-pt_BR_package() {
	short_desc="Brazillian Portuguese dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-3.0-or-later, MPL-1.1, BSD-3-Clause"
	pkg_install() {
		_vhunspell pt_BR
	}
}

# TODO
hunspell-pt_PT_package() {
	reverts="20201029_1 20220621_1"
	short_desc="Portuguese (Portugal) dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-or-later, MPL-1.1"
	pkg_install() {
		_vhunspell pt_PT
	}
}

hyphen-pt_BR_package() {
	short_desc="Brazillian Portuguese hyphenation rules"
	license="LGPL-3.0-or-later"
	pkg_install() {
		_vhyphen pt_BR
	}
}

hyphen-pt_PT_package() {
	short_desc="Portuguese (Portugal) hyphenation rules"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vhyphen pt_PT
	}
}

mythes-pt_BR_package() {
	short_desc="Brazillian Portuguese thesaurus for LibreOffice"
	license="BSD-3-Clause"
	pkg_install() {
		_vmythes pt_BR
		vlicense dictionaries/pt_BR/license-thes.readme
	}
}

mythes-pt_PT_package() {
	short_desc="Portuguese Portugal thesaurus for LibreOffice"
	license="CC-BY-SA-3.0"
	pkg_install() {
		_vmythes pt_PT
	}
}

hunspell-ro_RO_package() {
	short_desc="Romanian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-or-later, LGPL-2.1-or-later, MPL-1.1"
	pkg_install() {
		_vhunspell -d ro ro_RO
	}
}

hyphen-ro_package() {
	short_desc="Romanian hyphenation rules"
	license="GPL-2.0-or-later, LGPL-2.1-or-later, MPL-1.1"
	pkg_install() {
		_vhyphen -d ro ro_RO
	}
}

mythes-ro_package() {
	short_desc="Romanian thesaurus for LibreOffice"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vmythes -v 2 -d ro ro_RO
	}
}

hunspell-ru_RU_package() {
	short_desc="Russian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="BSD-4-Clause"
	pkg_install() {
		_vhunspell ru_RU
	}
}

hyphen-ru_package() {
	short_desc="Russian hyphenation rules"
	license="BSD-4-Clause"
	pkg_install() {
		_vhyphen ru_RU
	}
}

mythes-ru_package() {
	short_desc="Russian thesaurus for LibreOffice"
	license="LGPL-2.1-or-later"
	pkg_install() {
		_vmythes -v 2 ru_RU
	}
}

hunspell-si_package() {
	short_desc="Sinhala dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-3.0-or-later"
	pkg_install() {
		_vhunspell si_LK
	}
}

hunspell-sk_package() {
	short_desc="Slovak dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-or-later, LGPL-2.1-or-later, MPL-1.1"
	pkg_install() {
		_vhunspell sk_SK
	}
}

hyphen-sk_package() {
	short_desc="Slovak hyphenation rules"
	license="GPL-2.0-or-later, LGPL-2.1-or-later, MPL-1.1"
	pkg_install() {
		_vhyphen sk_SK
	}
}

mythes-sk_package() {
	short_desc="Slovak thesaurus for LibreOffice"
	license="MIT"
	pkg_install() {
		_vmythes -v 2 sk_SK
		vlicense dictionaries/sk_SK/README_th_sk_SK_v2.txt
	}
}

hunspell-sl_package() {
	short_desc="Slovenian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-or-later, LGPL-2.1-or-later"
	provides="hunspell-sl_SI-2024_1"
	replaces="hunspell-sl_SI>=0"
	pkg_install() {
		_vhunspell sl_SI
	}
}

hyphen-sl_package() {
	short_desc="Slovenian hyphenation rules"
	license="GPL-2.0-or-later, LGPL-2.1-or-later"
	pkg_install() {
		_vhyphen sl_SI
	}
}

mythes-sl_package() {
	short_desc="Slovenian thesaurus for LibreOffice"
	license="GPL-2.0-or-later, LGPL-2.1-or-later"
	pkg_install() {
		_vmythes -v 2 sl_SI
	}
}

hunspell-sq_package() {
	short_desc="Albanian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="MPL-2.0"
	pkg_install() {
		_vhunspell sq_AL
	}
}

hyphen-sq_package() {
	short_desc="Albanian hyphenation rules"
	license="MPL-2.0"
	pkg_install() {
		_vhyphen sq_AL
	}
}

hunspell-sr_package() {
	short_desc="Serbian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="MPL-2.0, GPL-3.0-or-later, LGPL-3.0-or-later"
	# SR is Suriname, Serbia is RS
	replaces="hunspell-sr_SR>=0"
	pkg_install() {
		_vhunspell sr sr_RS sr_CS
		_vhunspell -d sr sr-Latn sr_Latn_RS sr_Latn_CS \
			sr@latin sr_RS@latin sr_CS@latin
	}
}

hyphen-sr_package() {
	short_desc="Serbian hyphenation rules"
	license="MPL-2.0, GPL-3.0-or-later, LGPL-3.0-or-later"
	pkg_install() {
		_vhyphen sr sr_RS sr_CS
		_vhyphen -d sr sr-Latn sr_Latn_RS sr_Latn_CS \
			sr@latin sr_RS@latin sr_CS@latin
	}
}

hunspell-sv_package() {
	short_desc="Swedish dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-3.0-or-later"
	provides="hunspell-sv_SE-${version}_${revision}"
	replaces="hunspell-sv_SE>=0"
	pkg_install() {
		_vhunspell -d sv_SE sv_FI
		_vhunspell sv_SE
	}
}

hyphen-sv_package() {
	short_desc="Swedish hyphenation rules"
	license="MPL-2.0, LGPL-3.0-or-later"
	pkg_install() {
		_vhyphen -d sv_SE sv sv_SE sv_FI
	}
}

mythes-sv_package() {
	short_desc="Swedish thesaurus for LibreOffice"
	license="MIT"
	pkg_install() {
		_vmythes sv_SE
		vlicense dictionaries/sv_SE/README_th_sv_SE.txt
	}
}

hunspell-sw_package() {
	short_desc="Swahili dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-3.0-or-later"
	pkg_install() {
		_vhunspell sw_TZ
	}
}

hunspell-te_package() {
	short_desc="Telugu dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vhunspell te_IN te
	}
}

hyphen-te_package() {
	short_desc="Telugu hyphenation rules"
	license="GPL-3.0-or-later, LGPL-3.0-or-later"
	pkg_install() {
		_vhyphen te_IN te
	}
}

hunspell-th_package() {
	short_desc="Thai dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="LGPL-3.0-or-later"
	pkg_install() {
		_vhunspell th_TH
	}
}

hyphen-th_package() {
	short_desc="Thai hyphenation rules"
	license="LPPL-1.3c"
	pkg_install() {
		_vhyphen th_TH
	}
}

hunspell-tr_package() {
	short_desc="Turkish dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="MPL-2.0"
	pkg_install() {
		_vhunspell tr_TR
	}
}

hunspell-uk_package() {
	short_desc="Ukrainian dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="MPL-1.1"
	pkg_install() {
		_vhunspell uk_UA
	}
}

hyphen-uk_package() {
	short_desc="Ukrainian hyphenation rules"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vhyphen uk_UA
	}
}

mythes-uk_package() {
	short_desc="Ukrainian thesaurus for LibreOffice"
	license="MPL-1.1, LGPL-2.1-or-later, GPL-2.0-or-later"
	pkg_install() {
		_vmythes uk_UA
	}
}

hunspell-vi_package() {
	short_desc="Vietnamese dictionary for hunspell"
	depends="hunspell-qtwebengine-dict"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vhunspell -d vi vi_VN
	}
}

hyphen-zu_package() {
	short_desc="Zulu hyphenation rules"
	license="GPL-2.0-or-later"
	pkg_install() {
		_vhyphen zu_ZA
	}
}
