summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen de Groot <yngwin@gentoo.org>2012-07-19 23:25:21 +0800
committerBen de Groot <yngwin@gentoo.org>2012-07-19 23:25:21 +0800
commit93b90ef82c7e72858cba254d9bd0427ad5180fc1 (patch)
treee987a9255e4018fb5dae83ce712cc5a148f34ba7
parentl10n.eclass: return instead of export (diff)
downloadyngwin-93b90ef82c7e72858cba254d9bd0427ad5180fc1.tar.gz
yngwin-93b90ef82c7e72858cba254d9bd0427ad5180fc1.tar.bz2
yngwin-93b90ef82c7e72858cba254d9bd0427ad5180fc1.zip
Update l10n.eclass
-rw-r--r--app-text/goldendict/goldendict-1.0.1-r10.ebuild2
-rw-r--r--eclass/l10n.eclass73
-rw-r--r--net-im/qtwitter/qtwitter-0.10.0-r10.ebuild2
3 files changed, 44 insertions, 33 deletions
diff --git a/app-text/goldendict/goldendict-1.0.1-r10.ebuild b/app-text/goldendict/goldendict-1.0.1-r10.ebuild
index ad25e20..6b4ecb4 100644
--- a/app-text/goldendict/goldendict-1.0.1-r10.ebuild
+++ b/app-text/goldendict/goldendict-1.0.1-r10.ebuild
@@ -39,7 +39,7 @@ src_prepare() {
l10n_find_plocales_changes "${S}/locale" '' '.ts'
- l10n_for_each_unselected_locale_do editpro
+ l10n_for_each_disabled_locale_do editpro
# do not install duplicates
sed -e '/[icon,desktop]s2/d' -i ${PN}.pro || die
diff --git a/eclass/l10n.eclass b/eclass/l10n.eclass
index f2918f3..ffe8a9b 100644
--- a/eclass/l10n.eclass
+++ b/eclass/l10n.eclass
@@ -33,7 +33,11 @@
# Example: PLOCALE_BACKUP="en_US"
# Add linguas useflags
-[[ -n "${PLOCALES}" ]] && IUSE+=" $(printf 'linguas_%s ' ${PLOCALES})"
+if [[ -n "${PLOCALES}" ]]; then
+ for u in ${PLOCALES}; do
+ IUSE+=" linguas_${u}"
+ done
+fi
# @FUNCTION: l10n_for_each_locale_do
# @USAGE: <function>
@@ -44,30 +48,27 @@
#
# Example: l10n_for_each_locale_do install_locale
l10n_for_each_locale_do() {
- local xlocs=
- xlocs=$(l10n_get_linguas_crosssection)
- if [[ -n "${xlocs}" ]]; then
- local x
- for x in ${xlocs}; do
- ${@} ${x} || die "failed to process ${x} locale"
+ local locs x
+ locs=$(l10n_get_locales)
+ if [[ -n "${locs}" ]]; then
+ for x in ${locs}; do
+ ${@} ${x} || die "failed to process enabled ${x} locale"
done
fi
}
-# @FUNCTION: l10n_for_each_unselected_locale_do
+# @FUNCTION: l10n_for_each_disabled_locale_do
# @USAGE: <function>
# @DESCRIPTION:
# Complementary to l10n_for_each_locale_do, this function will process
-# locales that are not selected. This could be used for example to remove
+# locales that are disabled. This could be used for example to remove
# locales from a Makefile, to prevent them from being built needlessly.
-l10n_for_each_unselected_locale_do() {
- local o= x=
- o=$(join -v 1 <(echo "${PLOCALES// /$'\n'}") <(echo "${LINGUAS// /$'\n'}") )
- o=${o//$'\n'/' '}
- einfo "Unselected locales are: ${o}"
- if [[ -n "${o}" ]]; then
- for x in ${o}; do
- ${@} ${x} || die "failed to process unselected ${x} locale"
+l10n_for_each_disabled_locale_do() {
+ local locs x
+ locs=$(l10n_get_locales disabled)
+ if [[ -n "${locs}" ]]; then
+ for x in ${locs}; do
+ ${@} ${x} || die "failed to process disabled ${x} locale"
done
fi
}
@@ -94,23 +95,33 @@ l10n_find_plocales_changes() {
if [[ ${PLOCALES} != ${current%[[:space:]]} ]] ; then
einfo "There are changes in locales! This ebuild should be updated to:"
einfo "PLOCALES=\"${current%[[:space:]]}\""
+ else
+ einfo "Done"
fi
}
-# @FUNCTION: l10n_get_linguas_crosssection
+# @FUNCTION: l10n_get_locales
+# @USAGE: [disabled]
# @DESCRIPTION:
-# Determine the cross-section of user-set LINGUAS and the locales which
-# the package offers (listed in PLOCALES), and return them. In case no
-# locales are selected, fall back on PLOCALE_BACKUP. This function is
-# normally used internally in this eclass, not by l10n.eclass consumers.
-l10n_get_linguas_crosssection() {
- local lang= loc= xloc=
- for lang in ${LINGUAS}; do
- for loc in ${PLOCALES}; do
- [[ ${lang} == ${loc} ]] && xloc+="${loc} "
- done
+# Determine which LINGUAS USE flags the user has enabled that are offered
+# by the package, as listed in PLOCALES, and return them. In case no
+# locales are selected, fall back on PLOCALE_BACKUP. When the disabled
+# argument is given, return the disabled useflags instead of the enabled
+# ones. This function is normally used internally in this eclass, not by
+# l10n.eclass consumers.
+l10n_get_locales() {
+ local disabled_locales enabled_locales loc locs
+ for loc in ${PLOCALES}; do
+ if use linguas_${loc}; then
+ enabled_locales+="${loc} "
+ else
+ disabled_locales+="${loc} "
+ fi
done
- xloc=${xloc:-$PLOCALE_BACKUP}
- printf "%s" "${xloc}"
-# einfo "Selected locales are: ${xloc:-none}"
+ if [[ ${1} == disabled ]]; then
+ locs=${disabled_locales}
+ else
+ locs=${enabled_locales:-$PLOCALE_BACKUP}
+ fi
+ printf "%s" "${locs}"
}
diff --git a/net-im/qtwitter/qtwitter-0.10.0-r10.ebuild b/net-im/qtwitter/qtwitter-0.10.0-r10.ebuild
index 4e14959..7f2a12f 100644
--- a/net-im/qtwitter/qtwitter-0.10.0-r10.ebuild
+++ b/net-im/qtwitter/qtwitter-0.10.0-r10.ebuild
@@ -34,7 +34,7 @@ src_prepare() {
l10n_find_plocales_changes "${S}/translations" '${PN}' '.ts'
local langs
- langs="$(l10n_get_linguas_crosssection)"
+ langs="$(l10n_get_locales)"
einfo "Selected localizations are: ${langs}"
# remove translations and add only the selected ones
sed -e '/^ *LANGS/,/^$/s/^/#/' \