From 9ee6d97c2883d42f204a533a8bc1f4562df778fb Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Wed, 16 Sep 2020 09:32:48 +0100 Subject: gentoo resync : 16.09.2020 --- eclass/l10n.eclass | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'eclass/l10n.eclass') diff --git a/eclass/l10n.eclass b/eclass/l10n.eclass index 0b2d287afa7f..7bd8f382fbe3 100644 --- a/eclass/l10n.eclass +++ b/eclass/l10n.eclass @@ -1,4 +1,4 @@ -# Copyright 1999-2018 Gentoo Foundation +# Copyright 1999-2020 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: l10n.eclass @@ -14,6 +14,9 @@ # determining the cross-section between the user's set LINGUAS and what # is offered by the package. +if [[ -z ${_L10N_ECLASS} ]]; then +_L10N_ECLASS=1 + # @ECLASS-VARIABLE: PLOCALES # @DEFAULT_UNSET # @DESCRIPTION: @@ -120,3 +123,52 @@ l10n_get_locales() { fi printf "%s" "${locs}" } + +# @FUNCTION: strip-linguas +# @USAGE: [|<-i|-u> ] +# @DESCRIPTION: +# Make sure that LINGUAS only contains languages that a package can +# support. The first form allows you to specify a list of LINGUAS. +# The -i builds a list of po files found in all the directories and uses +# the intersection of the lists. The -u builds a list of po files found +# in all the directories and uses the union of the lists. +strip-linguas() { + local ls newls nols + if [[ $1 == "-i" ]] || [[ $1 == "-u" ]] ; then + local op=$1; shift + ls=$(find "$1" -name '*.po' -exec basename {} .po ';'); shift + local d f + for d in "$@" ; do + if [[ ${op} == "-u" ]] ; then + newls=${ls} + else + newls="" + fi + for f in $(find "$d" -name '*.po' -exec basename {} .po ';') ; do + if [[ ${op} == "-i" ]] ; then + has ${f} ${ls} && newls="${newls} ${f}" + else + has ${f} ${ls} || newls="${newls} ${f}" + fi + done + ls=${newls} + done + else + ls="$@" + fi + + nols="" + newls="" + for f in ${LINGUAS} ; do + if has ${f} ${ls} ; then + newls="${newls} ${f}" + else + nols="${nols} ${f}" + fi + done + [[ -n ${nols} ]] \ + && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols} + export LINGUAS=${newls:1} +} + +fi -- cgit v1.2.3