Gentoo Archives: gentoo-dev

From: James Le Cuirot <chewi@g.o>
To: gentoo-dev <gentoo-dev@l.g.o>, Ben de Groot <yngwin@g.o>
Subject: [gentoo-dev] [PATCH] l10n.eclass: Sort and normalize PLOCALES in l10n_find_plocales_change
Date: Sat, 07 May 2016 20:14:10
Message-Id: 20160507211349.476b5d78@symphony.aura-online.co.uk
1 l10n_find_plocales_change assumes that PLOCALES is sorted
2 alphanumerically with a single space between each entry and no
3 surrounding whitespace. This is not a bad assumption but it isn't
4 documented and it's inconvenient in at least one particular case.
5
6 MakeMKV uses non-standard locale names and I intend to map these using
7 an associative array, which is possible as of EAPI 6. This allows me
8 to do the following, though only with the above change as associative
9 arrays are not ordered.
10
11 declare -A MY_LOCALES
12 MY_LOCALES=( [zh]=chi [da]=dan … )
13 PLOCALES="${!MY_LOCALES[@]}"
14 inherit l10n
15
16 src_prepare() {
17 PLOCALES="${MY_LOCALES[@]}" l10n_find_plocales_changes …
18 }
19
20 src_install() {
21 for locale in $(l10n_get_locales); do
22 doins makemkv_${MY_LOCALES[${locale}]}.mo.gz
23 done
24 }
25 ---
26 eclass/l10n.eclass | 2 +-
27 1 file changed, 1 insertion(+), 1 deletion(-)
28
29 diff --git a/eclass/l10n.eclass b/eclass/l10n.eclass
30 index a7a6a26..26aa864 100644
31 --- a/eclass/l10n.eclass
32 +++ b/eclass/l10n.eclass
33 @@ -86,7 +86,7 @@ l10n_find_plocales_changes() {
34 current+="${x} "
35 done
36 popd >/dev/null
37 - if [[ ${PLOCALES} != ${current%[[:space:]]} ]] ; then
38 + if [[ $(tr -s "[:space:]" "\n" <<< "${PLOCALES}" | sort | xargs echo) != ${current%[[:space:]]} ]] ; then
39 einfo "There are changes in locales! This ebuild should be updated to:"
40 einfo "PLOCALES=\"${current%[[:space:]]}\""
41 else
42 --
43 2.7.1

Replies