Skip to content

Commit ede77fc

Browse files
authored
fix:repeat trigger update locale when locale exists (#1614)
Description: Log:
1 parent d3ae2cf commit ede77fc

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

distrobox-init

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ setup_apt()
827827
# In case the locale is not available, install it
828828
# will ensure we don't fallback to C.UTF-8
829829
if [ -e /etc/locale.gen ] && {
830-
! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "${HOST_LOCALE}"
830+
! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "$(echo ${HOST_LOCALE} | tr -d '-' )"
831831
}; then
832832
sed -i "s|#.*en_US.UTF-8|en_US.UTF-8|g" /etc/locale.gen
833833
sed -i "s|#.*${HOST_LOCALE}|${HOST_LOCALE}|g" /etc/locale.gen
@@ -953,7 +953,7 @@ setup_dnf()
953953
if [ ! -e /usr/share/i18n/charmaps ]; then
954954
${manager} reinstall -y glibc-common
955955
fi
956-
if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "${HOST_LOCALE}"; then
956+
if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "$(echo ${HOST_LOCALE} | tr -d '-' )"; then
957957
LANG="${HOST_LOCALE}" localedef -i "${HOST_LOCALE_LANG}" -f "${HOST_LOCALE_ENCODING}" "${HOST_LOCALE}"
958958
fi
959959

@@ -1030,7 +1030,7 @@ setup_emerge()
10301030

10311031
# In case the locale is not available, install it
10321032
# will ensure we don't fallback to C.UTF-8
1033-
if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "${HOST_LOCALE}"; then
1033+
if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "$(echo ${HOST_LOCALE} | tr -d '-' )"; then
10341034
sed -i "s|#.*en_US.UTF-8|en_US.UTF-8|g" /etc/locale.gen
10351035
sed -i "s|#.*${HOST_LOCALE}|${HOST_LOCALE}|g" /etc/locale.gen
10361036
locale-gen
@@ -1141,7 +1141,7 @@ setup_microdnf()
11411141
if [ ! -e /usr/share/zoneinfo/UTC ]; then
11421142
microdnf reinstall -y tzdata || microdnf install -y glibc-common
11431143
fi
1144-
if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "${HOST_LOCALE}"; then
1144+
if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "$(echo ${HOST_LOCALE} | tr -d '-' )"; then
11451145
LANG="${HOST_LOCALE}" localedef -i "${HOST_LOCALE_LANG}" -f "${HOST_LOCALE_ENCODING}" "${HOST_LOCALE}"
11461146
fi
11471147

@@ -1255,7 +1255,7 @@ setup_pacman()
12551255

12561256
# In case the locale is not available, install it
12571257
# will ensure we don't fallback to C.UTF-8
1258-
if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "${HOST_LOCALE}"; then
1258+
if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "$(echo ${HOST_LOCALE} | tr -d '-' )"; then
12591259
sed -i "s|#.*en_US.UTF-8|en_US.UTF-8|g" /etc/locale.gen
12601260
sed -i "s|#.*${HOST_LOCALE}|${HOST_LOCALE}|g" /etc/locale.gen
12611261
locale-gen -a
@@ -1489,7 +1489,7 @@ setup_xbps()
14891489
# In case the locale is not available, install it
14901490
# will ensure we don't fallback to C.UTF-8
14911491
if command -v locale && {
1492-
! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "${HOST_LOCALE}"
1492+
! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "$(echo ${HOST_LOCALE} | tr -d '-' )"
14931493
}; then
14941494
sed -i "s|#.*en_US.UTF-8|en_US.UTF-8|g" /etc/default/libc-locales
14951495
sed -i "s|#.*${HOST_LOCALE}|${HOST_LOCALE}|g" /etc/default/libc-locales
@@ -1601,7 +1601,7 @@ setup_zypper()
16011601

16021602
# In case the locale is not available, install it
16031603
# will ensure we don't fallback to C.UTF-8
1604-
if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "${HOST_LOCALE}"; then
1604+
if ! locale -a | grep -qi en_us.utf8 || ! locale -a | grep -qi "$(echo ${HOST_LOCALE} | tr -d '-' )"; then
16051605
LANG="${HOST_LOCALE}" localedef -i "${HOST_LOCALE_LANG}" -f "${HOST_LOCALE_ENCODING}" "${HOST_LOCALE}" || true
16061606
fi
16071607

0 commit comments

Comments
 (0)