media-video/makemkv: Use the l10n eclass to select locales
authorJames Le Cuirot <chewi@gentoo.org>
Sat, 7 May 2016 22:35:31 +0000 (23:35 +0100)
committerJames Le Cuirot <chewi@gentoo.org>
Sun, 8 May 2016 16:26:45 +0000 (17:26 +0100)
Upstream uses non-standard locale names so map them with an
associative array and perform some tricks.

Thanks to Jan Chren for the initial work on this.

Package-Manager: portage-2.2.28

media-video/makemkv/makemkv-1.9.10.ebuild

index 58a476588719c32f105b872581f686024c75df90..d1daf39f1681ec7c4d6b0d0dc23b7cca2c6e018f 100644 (file)
@@ -43,6 +43,28 @@ RDEPEND="
 "
 DEPEND="${RDEPEND}"
 
+# Upstream uses non-standard locale names so map them with this
+# associative array and perform some tricks below.
+declare -A MY_LOCALES
+MY_LOCALES=(
+       [zh]=chi
+       [da]=dan
+       [de]=deu
+       [nl]=dut
+       [fr]=fra
+       [it]=ita
+       [ja]=jpn
+       [no]=nor
+       [fa]=per
+       [pl]=pol
+       [pt_BR]=ptb
+       [es]=spa
+       [sv]=swe
+)
+
+PLOCALES="${!MY_LOCALES[@]}"
+inherit l10n
+
 S="${WORKDIR}/makemkv-oss-${PV}"
 
 src_prepare() {
@@ -57,6 +79,9 @@ src_prepare() {
                PATCHES+=( "${FILESDIR}"/${PN}-qt5.patch )
        fi
 
+       # Check for locale changes against the non-standard names.
+       PLOCALES="${MY_LOCALES[@]}" l10n_find_plocales_changes "${WORKDIR}"/${MY_PB}/src/share makemkv_ .mo.gz
+
        default
 }
 
@@ -103,24 +128,29 @@ src_install() {
                make_desktop_entry ${PN} MakeMKV ${PN} 'Qt;AudioVideo;Video'
        fi
 
-       # install bin package
-       pushd "${WORKDIR}"/${MY_PB}/bin >/dev/null
+       cd "${WORKDIR}"/${MY_PB} || die
+
+       # install prebuilt bins
        if use x86; then
-               dobin i386/{makemkvcon,mmdtsdec}
+               dobin bin/i386/{makemkvcon,mmdtsdec}
        elif use amd64; then
-               dobin amd64/makemkvcon
-               use multilib && dobin i386/mmdtsdec
+               dobin bin/amd64/makemkvcon
+               use multilib && dobin bin/i386/mmdtsdec
        fi
-       popd >/dev/null
 
-       # install license and default profile
-       pushd "${WORKDIR}"/${MY_PB}/src/share >/dev/null
        insinto /usr/share/MakeMKV
-       doins *.{gz,xml}
-       popd >/dev/null
+
+       # install profiles
+       doins src/share/*.xml
+
+       # install locales
+       local locale
+       for locale in $(l10n_get_locales); do
+               doins src/share/makemkv_${MY_LOCALES[${locale}]}.mo.gz
+       done
 }
 
-pkg_preinst() {        gnome2_icon_savelist; }
+pkg_preinst() { gnome2_icon_savelist; }
 
 pkg_postinst() {
        gnome2_icon_cache_update