aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-24 22:21:14 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-03-24 22:21:14 +0000
commit9334e28a804b6db8a360ece0fb3a40aa05822ff4 (patch)
tree2145e3f00d1ef7ae15963b0c50e98fc98e3d1200
parentda5a575351c8636a694954c5efed2b6866dfeb1d (diff)
downloadpaludis-9334e28a804b6db8a360ece0fb3a40aa05822ff4.tar.gz
paludis-9334e28a804b6db8a360ece0fb3a40aa05822ff4.tar.xz
Make select news support multiple languages. Better 'you have unread news' message. Fixes: ticket:147
-rw-r--r--eselect/news.eselect16
-rwxr-xr-xhooks/news.bash4
2 files changed, 16 insertions, 4 deletions
diff --git a/eselect/news.eselect b/eselect/news.eselect
index 903f9a5..9b6c416 100644
--- a/eselect/news.eselect
+++ b/eselect/news.eselect
@@ -80,15 +80,27 @@ get_dir_name() {
sed -n -e "s~^ *newsdir: *\(.*\)~\1/${name}/~p"
}
+get_lang() {
+ if [[ -n "${LC_MESSAGES}" ]] ; then
+ echo ${LC_MESSAGES:0:2}
+ elif [[ -n "${LANG}" ]] ; then
+ echo ${LANG:0:2}
+ else
+ echo en
+ fi
+}
+
get_headers() {
local dir=${1}
- dir=${dir}/$(basename ${1%/} ).en.txt
+ dir=${dir}/$(basename ${1%/} ).$(get_lang).txt
+ [[ -f ${dir} ]] || dir=${dir}/$(basename ${1%/} ).en.txt
sed -e '/^$/,$d' < ${dir}
}
get_body() {
local dir=${1}
- dir=${dir}/$(basename ${1%/} ).en.txt
+ dir=${dir}/$(basename ${1%/} ).$(get_lang).txt
+ [[ -f ${dir} ]] || dir=${dir}/$(basename ${1%/} ).en.txt
sed -e '1,/^$/d' < ${dir}
}
diff --git a/hooks/news.bash b/hooks/news.bash
index 8e656ef..1fd5a42 100755
--- a/hooks/news.bash
+++ b/hooks/news.bash
@@ -1,7 +1,7 @@
#!/bin/bash
# vim: set et sw=4 sts=4 :
-# Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+# Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
#
# This file is part of the Paludis package manager. Paludis is free software;
# you can redistribute it and/or modify it under the terms of the GNU General
@@ -40,7 +40,7 @@ done
if [[ ${count} -gt 0 ]] ; then
[[ -z "${done_echo}" ]] && echo ; done_echo=yes
- ewarn "You have ${count} unread news items"
+ ewarn "You have ${count} unread news items (use 'eselect news' to read)"
elif [[ "${HOOK/pretend}" == "${HOOK}" ]] ; then
[[ -z "${done_echo}" ]] && echo ; done_echo=yes
einfo_unhooked "No unread news items found"