From e248c740eca9e0cc04c706580694c7b1b04d909f Mon Sep 17 00:00:00 2001 From: Robin Candau Date: Mon, 20 May 2024 00:03:58 +0200 Subject: [PATCH] Make Arch-Update also look in XDG_DATA_HOME/XDG_DATA_DIRS for translation files and example config This commit aims to make Arch-Update also look in XDG_DATA_HOME/XDG_DATA_DIRS for translation files and example config (instead of assuming the `/usr` or the `/usr/local` prefix during install). Fixes https://github.com/Antiz96/arch-update/issues/166 --- src/script/arch-update.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index c86fd32..49b2343 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -30,7 +30,13 @@ esac # shellcheck disable=SC1091 . gettext.sh export TEXTDOMAIN="${_name}" # Using "Arch-Update" as TEXTDOMAIN to avoid conflicting with the "arch-update" TEXTDOMAIN used by the arch-update Gnome extension (https://extensions.gnome.org/extension/1010/archlinux-updates-indicator/) -if find /usr/local/share/locale/*/LC_MESSAGES/"${_name}".mo &> /dev/null; then +if [ -f "${XDG_DATA_HOME}/locale/fr/LC_MESSAGES/${_name}.mo" ]; then + export TEXTDOMAINDIR="${XDG_DATA_HOME}/locale" +elif [ -f "${HOME}/.local/share/locale/fr/LC_MESSAGES/${_name}.mo" ]; then + export TEXTDOMAINDIR="${HOME}/.local/share/locale" +elif [ -f "${XDG_DATA_DIRS}/locale/fr/LC_MESSAGES/${_name}.mo" ]; then + export TEXTDOMAINDIR="${XDG_DATA_DIRS}/locale" +elif [ -f "/usr/local/share/locale/fr/LC_MESSAGES/${_name}.mo" ]; then export TEXTDOMAINDIR="/usr/local/share/locale" fi @@ -676,8 +682,7 @@ case "${option}" in list_news ;; --gen-config) - example_config_file="/usr/share/doc/${name}/${name}.conf.example" - [ -f "/usr/local/share/doc/${name}/${name}.conf.example" ] && example_config_file="/usr/local/share/doc/${name}/${name}.conf.example" + example_config_file="${XDG_DATA_HOME:-${HOME}/.local/share:-${XDG_DATA_DIRS}:-/usr/local/share:-/usr/share}/doc/${name}/${name}.conf.example" if [ -f "${config_file}" ]; then error_msg "$(eval_gettext "The '\${config_file}' configuration file already exists\nPlease, remove it before generating a new one")"