Frederik Schwan pushed to branch main at Arch Linux / Packaging / Packages /
glibc
Commits:
f87f2b50 by Frederik Schwan at 2026-01-05T11:03:52+01:00
allow locale overrides in /usr/local/share/i18n/locales/
fixes #23
- - - - -
ade969de by Levente Polyak at 2026-01-06T20:43:52+01:00
locale-gen: change fall-through selector for locale overrides
This picks the fall-through logic inspired from the Debian script
while adding comments and shell substitution instead of regex to
improve readability and clarity of the fall-through logic.
1. Fully matching override locale in /usr/local/
2. Fully matching system locale in /usr/
3. Partial matching override locale with base and optionally at-suffix
in /usr/local
3. Partial matching system locale with base and optionally at-suffix
in /usr/local
- - - - -
1 changed file:
- locale-gen
Changes:
=====================================
locale-gen
=====================================
@@ -4,6 +4,8 @@ set -e
LOCALEGEN=/etc/locale.gen
LOCALES=/usr/share/i18n/locales
+LOCALES_OVERRIDES=/usr/local/share/i18n/locales
+
if [ -n "$POSIXLY_CORRECT" ]; then
unset POSIXLY_CORRECT
fi
@@ -18,25 +20,44 @@ rm -rf /usr/lib/locale/locale-archive || true
umask 022
is_entry_ok() {
- if [ -n "$locale" -a -n "$charset" ] ; then
- true
- else
+ if [ -z "$locale" ] || [ -z "$charset" ]; then
echo "error: Bad entry '$locale $charset'"
- false
+ return 1
fi
}
echo "Generating locales..."
-while read locale charset; do \
- case $locale in \#*) continue;; "") continue;; esac; \
- is_entry_ok || continue
- echo -n " `echo $locale | sed 's/\([^.\@]*\).*/\1/'`"; \
- echo -n ".$charset"; \
- echo -n `echo $locale | sed 's/\([^\@]*\)\(\@.*\)*/\2/'`; \
- echo -n '...'; \
- if [ -f $LOCALES/$locale ]; then input=$locale; else \
- input=`echo $locale | sed 's/\([^.]*\)[^@]*\(.*\)/\1\2/'`; fi; \
- localedef -i $input -c -f $charset -A /usr/share/locale/locale.alias
$locale; \
- echo ' done'; \
+while read -r locale charset; do
+ if [ -z "$locale" ] || [ "${locale#\#}" != "$locale" ]; then continue; fi
+ is_entry_ok || continue
+
+ # strip charmap and at-suffix for locale base
+ locale_base="${locale%%.*}"
+ locale_base="${locale_base%%@*}"
+
+ # optional at-suffix
+ locale_at="${locale#*@}"
+ [ "$locale_at" = "$locale" ] && locale_at= || locale_at="@$locale_at"
+
+ printf " %s.%s%s..." "$locale_base" "$charset" "$locale_at"
+
+ # fully matching override locale
+ if [ -e "$LOCALES_OVERRIDES/$locale" ]; then
+ input="$LOCALES_OVERRIDES/$locale"
+ # fully matching vendor locale
+ elif [ -e "$LOCALES/$locale" ]; then
+ input="$locale"
+ # fallback to partial matches
+ else
+ # locale base with optional at-suffix
+ input="$locale_base$locale_at"
+ # override partial locale
+ if [ -e "$LOCALES_OVERRIDES/$input" ]; then
+ input="$LOCALES_OVERRIDES/$input"
+ fi
+ fi
+
+ localedef -i "$input" -c -f "$charset" -A /usr/share/locale/locale.alias
"$locale" || :
+ echo ' done'
done < $LOCALEGEN
echo "Generation complete."
View it on GitLab:
https://gitlab.archlinux.org/archlinux/packaging/packages/glibc/-/compare/a12a9a295c6316d7328eb03be5b7d25b67c7b746...ade969dec4981aaef394692f0241b4d75d725144
--
View it on GitLab:
https://gitlab.archlinux.org/archlinux/packaging/packages/glibc/-/compare/a12a9a295c6316d7328eb03be5b7d25b67c7b746...ade969dec4981aaef394692f0241b4d75d725144
You're receiving this email because of your account on gitlab.archlinux.org.