# Template file for 'libreoffice-bin-i18n'
pkgname=libreoffice-bin-i18n
version=4.4.3
revision=1
hostmakedepends="rpmextract"
short_desc="LibreOffice localization files (binary build)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="LGPL-3"
homepage="http://www.documentfoundation.org/"
_url="http://download.documentfoundation.org/libreoffice/stable/${version}/rpm/x86"
distfiles="
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_am.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_ast.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_bg.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_bn-IN.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_bn.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_bo.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_bs.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_ca-valencia.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_ca.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_cs.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_da.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_de.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_dz.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_el.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_en-GB.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_en-US.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_en-ZA.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_eo.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_es.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_et.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_eu.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_fi.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_fr.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_gl.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_gu.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_he.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_hi.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_hr.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_hu.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_id.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_is.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_it.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_ja.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_ka.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_km.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_ko.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_mk.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_nb.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_ne.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_nl.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_nn.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_om.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_pl.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_pt-BR.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_pt.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_ru.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_si.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_sk.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_sl.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_sq.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_sv.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_tg.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_tr.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_ug.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_uk.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_vi.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_zh-CN.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_helppack_zh-TW.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_af.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_am.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ar.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_as.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ast.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_be.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_bg.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_bn-IN.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_bn.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_bo.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_br.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_brx.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_bs.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ca.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_cs.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_cy.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_da.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_de.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_dgo.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_dz.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_el.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_en-GB.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_en-ZA.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_eo.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_es.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_et.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_eu.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_fa.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_fi.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_fr.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ga.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_gd.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_gl.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_gu.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_he.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_hi.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_hr.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_hu.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_id.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_is.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_it.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ja.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ka.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_kk.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_km.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_kn.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ko.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_kok.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ks.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_lb.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_lo.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_lt.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_lv.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_mai.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_mk.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ml.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_mn.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_mni.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_mr.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_my.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_nb.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ne.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_nl.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_nn.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_nr.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_nso.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_oc.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_om.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_or.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_pa-IN.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_pl.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_pt-BR.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_pt.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ro.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ru.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_rw.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_sa-IN.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_sat.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_sd.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_si.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_sid.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_sk.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_sl.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_sq.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_sr.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ss.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_st.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_sv.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_sw-TZ.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ta.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_te.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_tg.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_th.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_tn.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_tr.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ts.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_tt.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ug.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_uk.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_uz.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_ve.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_vi.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_xh.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_zh-CN.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_zh-TW.tar.gz
 ${_url}/LibreOffice_${version}_Linux_x86_rpm_langpack_zu.tar.gz"

_languages=(
	'af            "Afrikaans"'
	'am            "Amharic"'
	'ar            "Arabic"'
	'as            "Assamese (India)"'
	'ast           "Asturianu"'
	'be            "Belarusian"'
	'bg            "Bulgarian"'
	'bn            "Bengali"'
	'bn-IN         "Bengali (India)"'
	'bo            "Tibetan"'
	'br            "Breton"'
	'brx           "Bodo"'
	'bs            "Bosnian"'
	'ca            "Catalan"'
	'ca-valencia   "Catalan (Valencia)"'
	'cs            "Czech"'
	'cy            "Welsh"'
	'da            "Danish"'
	'de            "German"'
	'dgo           "Dogri"'
	'dz            "Dzongkha"'
	'el            "Greek"'
	'en-GB         "English (GB)"'
	'en-ZA         "English (ZA)"'
	'eo            "Esperanto"'
	'es            "Spanish"'
	'et            "Estonian"'
	'eu            "Basque"'
	'fa            "Persian"'
	'fi            "Finnish"'
	'fr            "French"'
	'ga            "Irish"'
	'gd            "Gaelic (Scottish)"'
	'gl            "Galician"'
	'gu            "Gujarati"'
	'he            "Hebrew"'
	'hi            "Hindi"'
	'hr            "Croatian"'
	'hu            "Hungarian"'
	'id            "Indonesian"'
	'is            "Icelandic"'
	'it            "Italian"'
	'ja            "Japanese"'
	'ka            "Georgian"'
	'kk            "Kazakh"'
	'km            "Khmer (Cambodia)"'
	'kn            "Kannada"'
	'ko            "Korean"'
	'kok           "Konkani"'
	'ks            "Kashmiri"'
	'lb            "Luxembourgish"'
	'lo            "Lao"'
	'lt            "Lithuanian"'
	'lv            "Latvian"'
	'mai           "Maithili"'
	'mk            "Macedonian"'
	'ml            "Malayalam"'
	'mn            "Mongolian"'
	'mni           "Manipuri"'
	'mr            "Marathi"'
	'my            "Burmese"'
	'nb            "Norwegian Bokmal"'
	'ne            "Nepali"'
	'nl            "Dutch"'
	'nn            "Norwegian Nynorsk"'
	'nr            "Ndebele (South)"'
	'nso           "Northern Sotho"'
	'oc            "Occitan"'
	'om            "Oromo"'
	'or            "Oriya"'
	'pa-IN         "Punjabi (India)"'
	'pl            "Polish"'
	'pt            "Portuguese"'
	'pt-BR         "Portuguese (Brasil)"'
	'ro            "Romanian"'
	'ru            "Russian"'
	'rw            "Kinyarwanda"'
	'sa-IN         "Sanskrit (India)"'
	'sat           "Santali"'
	'sd            "Sindhi"'
	'si            "Singhalese"'
	'sid           "Sidama"'
	'sk            "Slovak"'
	'sl            "Slovenian"'
	'sq            "Albanien"'
	'sr            "Serbian"'
	'ss            "Swati"'
	'st            "Southern Sotho"'
	'sv            "Swedish"'
	'sw-TZ         "Swahili (Tanzania)"'
	'ta            "Tamil"'
	'te            "Telugu"'
	'tg            "Tajik"'
	'th            "Thai"'
	'tn            "Tswana"'
	'tr            "Turkish"'
	'ts            "Tsonga"'
	'tt            "Tatar"'
	'ug            "Uighur"'
	'uk            "Ukrainian"'
	'uz            "Uzbek"'
	've            "Venda"'
	'vi            "Vietnamese"'
	'xh            "Xhosa"'
	'zh-CN         "Chinese (simplified)"'
	'zh-TW         "Chinese (traditional)"'
	'zu            "Zulu"'
)

do_build() {
	for i in $distfiles; do
		_localver="${version}.2"
		_tarbname="${i##*/}"
		_tarbname="${_tarbname%*.tar.gz}"
		_lang="${_tarbname##*_}"
		echo "Unpacking ${_tarbname}..."
		# We create a directory using p_${_lang} (for example p_zh-TW) containing
		# opt/libreoffice*, with helppack and/or langpack extracted inside it.
		if [ ! -d "${wrksrc}/p_${_lang}" ]; then
			mkdir -p ${wrksrc}/p_${_lang}
		fi
		cd ${wrksrc}/p_${_lang}
		if [ -d "${wrksrc}/LibreOffice_${_localver}_Linux_x86_rpm_helppack_${_lang}/RPMS/" ]; then
			rpmextract ${wrksrc}/LibreOffice_${_localver}_Linux_x86_rpm_helppack_${_lang}/RPMS/*.rpm
		fi
		if [ -d "${wrksrc}/LibreOffice_${_localver}_Linux_x86_rpm_langpack_${_lang}/RPMS/" ]; then
			rpmextract ${wrksrc}/LibreOffice_${_localver}_Linux_x86_rpm_langpack_${_lang}/RPMS/*.rpm
		fi
	done
}
do_install() {
	:
}

noarch=yes
create_wrksrc=yes
depends="${subpackages}"

for _lang in "${_languages[@]}"; do
	_locale=${_lang%% *}
	_pkgname=libreoffice-bin-i18n-${_locale}

	depends+=" ${_pkgname}>=${version}"

	eval "${_pkgname}_package() {
		_pkgtmpl ${_lang}
	}"
done

_pkgtmpl() {
	_lang="$1"
	short_desc="LibreOffice localization files (binary build) - $2 language pack"
	noarch=yes
	pkg_install() {
		vmkdir opt
		cp -R ${wrksrc}/p_${_lang}/opt/libreoffice*/ ${PKGDESTDIR}/opt/
	}
}

checksum="
[encoded data, 10725 characters]
"
