1 |
Ever since the L10N USE_EXPAND variable was introduced, the name of |
2 |
this eclass was somewhat confusing, because it operates on LINGUAS and |
3 |
is unrelated to L10N. Take the EAPI 8 bump as an opportunity to rename |
4 |
the eclass. |
5 |
|
6 |
Signed-off-by: Ulrich Müller <ulm@g.o> |
7 |
--- |
8 |
eclass/{l10n.eclass => plocale.eclass} | 78 +++++++++++++------------- |
9 |
1 file changed, 38 insertions(+), 40 deletions(-) |
10 |
copy eclass/{l10n.eclass => plocale.eclass} (61%) |
11 |
|
12 |
diff --git a/eclass/l10n.eclass b/eclass/plocale.eclass |
13 |
similarity index 61% |
14 |
copy from eclass/l10n.eclass |
15 |
copy to eclass/plocale.eclass |
16 |
index cd859429d8c7..81f147a655ed 100644 |
17 |
--- a/eclass/l10n.eclass |
18 |
+++ b/eclass/plocale.eclass |
19 |
@@ -1,29 +1,27 @@ |
20 |
-# Copyright 1999-2021 Gentoo Authors |
21 |
+# Copyright 2012-2021 Gentoo Authors |
22 |
# Distributed under the terms of the GNU General Public License v2 |
23 |
|
24 |
-# @ECLASS: l10n.eclass |
25 |
+# @ECLASS: plocale.eclass |
26 |
# @MAINTAINER: |
27 |
# Ulrich Müller <ulm@g.o> |
28 |
# @AUTHOR: |
29 |
# Ben de Groot <yngwin@g.o> |
30 |
-# @SUPPORTED_EAPIS: 5 6 7 |
31 |
+# @SUPPORTED_EAPIS: 6 7 8 |
32 |
# @BLURB: convenience functions to handle localizations |
33 |
# @DESCRIPTION: |
34 |
-# The l10n (localization) eclass offers a number of functions to more |
35 |
+# The plocale (localization) eclass offers a number of functions to more |
36 |
# conveniently handle localizations (translations) offered by packages. |
37 |
# These are meant to prevent code duplication for such boring tasks as |
38 |
# determining the cross-section between the user's set LINGUAS and what |
39 |
# is offered by the package. |
40 |
|
41 |
-case ${EAPI:-0} in |
42 |
- [567]) ;; |
43 |
+case ${EAPI} in |
44 |
+ 6|7|8) ;; |
45 |
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;; |
46 |
esac |
47 |
|
48 |
-inherit strip-linguas |
49 |
- |
50 |
-if [[ -z ${_L10N_ECLASS} ]]; then |
51 |
-_L10N_ECLASS=1 |
52 |
+if [[ -z ${_PLOCALE_ECLASS} ]]; then |
53 |
+_PLOCALE_ECLASS=1 |
54 |
|
55 |
# @ECLASS-VARIABLE: PLOCALES |
56 |
# @DEFAULT_UNSET |
57 |
@@ -37,81 +35,81 @@ _L10N_ECLASS=1 |
58 |
# @DEFAULT_UNSET |
59 |
# @DESCRIPTION: |
60 |
# In some cases the package fails when none of the offered PLOCALES are |
61 |
-# selected by the user. In that case this variable should be set to a |
62 |
+# selected by the user. In that case this variable should be set to a |
63 |
# default locale (usually 'en' or 'en_US') as backup. |
64 |
# |
65 |
# Example: PLOCALE_BACKUP="en_US" |
66 |
|
67 |
-# @FUNCTION: l10n_for_each_locale_do |
68 |
+# @FUNCTION: plocale_for_each_locale |
69 |
# @USAGE: <function> |
70 |
# @DESCRIPTION: |
71 |
-# Convenience function for processing localizations. The parameter should |
72 |
-# be a function (defined in the consuming eclass or ebuild) which takes |
73 |
-# an individual localization as (last) parameter. |
74 |
+# Convenience function for processing all enabled localizations. |
75 |
+# The parameter should be a function (defined in the consuming eclass |
76 |
+# or ebuild) which takes an individual locale as its (last) parameter. |
77 |
# |
78 |
-# Example: l10n_for_each_locale_do install_locale |
79 |
-l10n_for_each_locale_do() { |
80 |
+# Example: plocale_for_each_locale install_locale |
81 |
+plocale_for_each_locale() { |
82 |
local locs x |
83 |
- locs=$(l10n_get_locales) |
84 |
+ locs=$(plocale_get_locales) |
85 |
for x in ${locs}; do |
86 |
- "${@}" ${x} || die "failed to process enabled ${x} locale" |
87 |
+ "$@" ${x} || die "failed to process enabled ${x} locale" |
88 |
done |
89 |
} |
90 |
|
91 |
-# @FUNCTION: l10n_for_each_disabled_locale_do |
92 |
+# @FUNCTION: plocale_for_each_disabled_locale |
93 |
# @USAGE: <function> |
94 |
# @DESCRIPTION: |
95 |
-# Complementary to l10n_for_each_locale_do, this function will process |
96 |
-# locales that are disabled. This could be used for example to remove |
97 |
+# Complementary to plocale_for_each_locale, this function will process |
98 |
+# locales that are disabled. This could be used for example to remove |
99 |
# locales from a Makefile, to prevent them from being built needlessly. |
100 |
-l10n_for_each_disabled_locale_do() { |
101 |
+plocale_for_each_disabled_locale() { |
102 |
local locs x |
103 |
- locs=$(l10n_get_locales disabled) |
104 |
+ locs=$(plocale_get_locales disabled) |
105 |
for x in ${locs}; do |
106 |
- "${@}" ${x} || die "failed to process disabled ${x} locale" |
107 |
+ "$@" ${x} || die "failed to process disabled ${x} locale" |
108 |
done |
109 |
} |
110 |
|
111 |
-# @FUNCTION: l10n_find_plocales_changes |
112 |
+# @FUNCTION: plocale_find_changes |
113 |
# @USAGE: <translations dir> <filename pre pattern> <filename post pattern> |
114 |
# @DESCRIPTION: |
115 |
# Ebuild maintenance helper function to find changes in package offered |
116 |
-# locales when doing a version bump. This could be added for example to |
117 |
-# src_prepare |
118 |
+# locales when doing a version bump. This could be added for example |
119 |
+# to src_prepare. |
120 |
# |
121 |
-# Example: l10n_find_plocales_changes "${S}/src/translations" "${PN}_" '.ts' |
122 |
-l10n_find_plocales_changes() { |
123 |
- [[ $# -ne 3 ]] && die "Exactly 3 arguments are needed!" |
124 |
+# Example: plocale_find_changes "${S}/src/translations" "${PN}_" '.ts' |
125 |
+plocale_find_changes() { |
126 |
+ [[ $# -eq 3 ]] || die "Exactly 3 arguments are needed!" |
127 |
ebegin "Looking in ${1} for new locales" |
128 |
pushd "${1}" >/dev/null || die "Cannot access ${1}" |
129 |
- local current= x= |
130 |
- for x in ${2}*${3} ; do |
131 |
+ local current="" x |
132 |
+ for x in ${2}*${3}; do |
133 |
x=${x#"${2}"} |
134 |
x=${x%"${3}"} |
135 |
current+="${x} " |
136 |
done |
137 |
- popd >/dev/null |
138 |
+ popd >/dev/null || die |
139 |
# RHS will be sorted with single spaces so ensure the LHS is too |
140 |
# before attempting to compare them for equality. See bug #513242. |
141 |
# Run them both through the same sorting algorithm so we don't have |
142 |
# to worry about them being the same. |
143 |
- if [[ "$(printf '%s\n' ${PLOCALES} | LC_ALL=C sort)" != "$(printf '%s\n' ${current} | LC_ALL=C sort)" ]] ; then |
144 |
- eend 1 "There are changes in locales! This ebuild should be updated to:" |
145 |
+ [[ "$(printf '%s\n' ${PLOCALES} | LC_ALL=C sort)" \ |
146 |
+ == "$(printf '%s\n' ${current} | LC_ALL=C sort)" ]] |
147 |
+ if ! eend $? "There are changes in locales!"; then |
148 |
+ eerror "This ebuild should be updated to:" |
149 |
eerror "PLOCALES=\"${current%[[:space:]]}\"" |
150 |
return 1 |
151 |
- else |
152 |
- eend 0 |
153 |
fi |
154 |
} |
155 |
|
156 |
-# @FUNCTION: l10n_get_locales |
157 |
+# @FUNCTION: plocale_get_locales |
158 |
# @USAGE: [disabled] |
159 |
# @DESCRIPTION: |
160 |
# Determine which LINGUAS the user has enabled that are offered by the |
161 |
# package, as listed in PLOCALES, and return them. In case no locales |
162 |
# are selected, fall back on PLOCALE_BACKUP. When the disabled argument |
163 |
# is given, return the disabled locales instead of the enabled ones. |
164 |
-l10n_get_locales() { |
165 |
+plocale_get_locales() { |
166 |
local loc locs |
167 |
if [[ -z ${LINGUAS+set} ]]; then |
168 |
# enable all if unset |
169 |
-- |
170 |
2.32.0 |