Skip to content

Commit

Permalink
Make Arch-Update also look in XDG_DATA_HOME/XDG_DATA_DIRS for transla…
Browse files Browse the repository at this point in the history
…tion 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 #166
  • Loading branch information
Antiz96 committed May 19, 2024
1 parent ecc196e commit e248c74
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/script/arch-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")"
Expand Down

0 comments on commit e248c74

Please sign in to comment.