summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-08-01 04:30:22 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-08-01 04:30:22 (EDT)
commit23c9f268392bcb735337f1c2580824886c5981dd (patch)
tree35e07b8c5ac49351afd7647633dfd9335138f21e
parentbb2c1e32b6614b01f9acef03871a0a403e59b06d (diff)
Mostly internationalize changelog library.
-rw-r--r--lib/changelog.sh25
-rw-r--r--locale/en_US.sh16
2 files changed, 25 insertions, 16 deletions
diff --git a/lib/changelog.sh b/lib/changelog.sh
index 847bd4f..327cc2d 100644
--- a/lib/changelog.sh
+++ b/lib/changelog.sh
@@ -30,9 +30,6 @@ OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'(-[1-9][0-9]*)?'
OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'(\+[a-z0-9]+-[1-9][0-9]*)?'
OH_SOURCE_VERSION_ID_RE="${OH_SOURCE_VERSION_ID_RE}"'$'
-# TODO: Either add an error callback to oh_changelog_parse() or make a central
-# error handling library.
-# TODO: Move message strings into locales.
oh_changelog_parse_error()
{
_file="${1}"
@@ -73,7 +70,7 @@ ${_line}"
:
elif [ "${_expect}" != CHANGES_OR_TRAILER ]; then
oh_changelog_parse_error "${_file}" "${_line_nr}" \
- 'found blank line where expected %s' "${_expect}"
+ "${oh_str_changelog_found_blank_line}" "${_expect}"
else
_blank_lines="${_blank_lines}
${_line}"
@@ -82,7 +79,7 @@ ${_line}"
if [ "${_expect}" != FIRST_HEADING -a \
"${_expect}" != NEXT_OR_EOF ]; then
oh_changelog_parse_error "${_file}" "${_line_nr}" \
- 'found start of entry where expected %s' "${_expect}"
+ "${oh_str_changelog_found_heading}" "${_expect}"
fi
_source="${_line%% (*}"
_line_="${_line#* (}"
@@ -93,7 +90,7 @@ ${_line}"
-z "${_version}" -o \
"${_version% *}" != "${_version}" ]; then
oh_changelog_parse_error "${_file}" "${_line_nr}" \
- 'badly formatted heading line'
+ "${oh_str_changelog_bad_heading}"
OH_CHANGELOG_SOURCE=
OH_CHANGELOG_VERSION=
OH_CHANGELOG_DISTRIBUTION=
@@ -103,13 +100,13 @@ ${_line}"
grep -E "${OH_SOURCE_RE}" >/dev/null 2>&1
if [ "${?}" -ne 0 ]; then
oh_changelog_parse_error "${_file}" "${_line_nr}" \
- "${oh_str_bad_source}"
+ "${oh_str_changelog_bad_source}"
fi
echo "${_version}" | \
grep -E "${OH_SOURCE_VERSION_ID_RE}" >/dev/null 2>&1
if [ "${?}" -ne 0 ]; then
oh_changelog_parse_error "${_file}" "${_line_nr}" \
- "${oh_str_bad_source_version}"
+ "${oh_str_changelog_bad_source_version}"
fi
OH_CHANGELOG_SOURCE="${_source}"
OH_CHANGELOG_VERSION="${_version}"
@@ -121,7 +118,7 @@ ${_line}"
elif [ "${_line# -- }" != "${_line}" ]; then
if [ "${_expect}" != CHANGES_OR_TRAILER ]; then
oh_changelog_parse_error "${_file}" "${_line_nr}" \
- 'found trailer where expected %s' "${_expect}"
+ "${oh_str_changelog_found_trailer}" "${_expect}"
fi
_line="${_line# -- }"
_maintainer="${_line%% *}"
@@ -129,7 +126,7 @@ ${_line}"
if [ -z "${_maintainer}" -o -z "${_date}" -o \
"${_maintainer}" = "${_date}" ]; then
oh_changelog_parse_error "${_file}" "${_line_nr}" \
- 'badly formatted trailer line'
+ "${oh_str_changelog_bad_trailer}"
OH_CHANGELOG_MAINTAINER=
OH_CHANGELOG_DATE=
elif [ -n "${OH_CHANGELOG_SOURCE}" ]; then
@@ -143,12 +140,12 @@ ${_line}"
_blank_lines=
elif [ "${_line# --}" != "${_line}" ]; then
oh_changelog_parse_error "${_file}" "${_line_nr}" \
- 'badly formatted trailer line'
+ "${oh_str_changelog_bad_trailer}"
elif [ "${_line## }" != "${_line}" ]; then
if [ "${_expect}" != START_CHANGES -a \
"${_expect}" != CHANGES_OR_TRAILER ]; then
oh_changelog_parse_error "${_file}" "${_line_nr}" \
- 'found change data where expected %s' "${_expect}"
+ "${oh_str_changelog_found_change}" "${_expect}"
fi
OH_CHANGELOG_CHANGES="${OH_CHANGELOG_CHANGES}
${_blank_lines}${_line}"
@@ -156,14 +153,14 @@ ${_blank_lines}${_line}"
_blank_lines=
else
oh_changelog_parse_error "${_file}" "${_line_nr}" \
- 'unrecognized line'
+ "${oh_str_changelog_bad_line}"
_blank_lines=
fi
done <"${_file}"
if [ "${_expect}" != NEXT_OR_EOF ]; then
oh_changelog_parse_error "${_file}" "${_line_nr}" \
- 'found eof where expected %s' "${_expect}"
+ "${oh_str_changelog_found_eof}" "${_expect}"
fi
return ${_entries}
diff --git a/locale/en_US.sh b/locale/en_US.sh
index 533f48e..cef81f6 100644
--- a/locale/en_US.sh
+++ b/locale/en_US.sh
@@ -18,8 +18,20 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# lib/changelog
-oh_str_bad_source='Invalid source package name "%s"'
-oh_str_bad_source_version='Invalid source package version identifier "%s"'
+oh_str_changelog_expect_first_heading='first heading'
+oh_str_changelog_expect_next_or_eof='next heading or eof'
+oh_str_changelog_expect_start_changes='start of change data'
+oh_str_changelog_expect_changes_or_trailer='more change data or trailer'
+oh_str_changelog_found_blank_line='found blank line where expected %s'
+oh_str_changelog_found_heading='found start of entry where expected %s'
+oh_str_changelog_bad_heading='badly formatted heading line'
+oh_str_changelog_bad_source='invalid source package name "%s"'
+oh_str_changelog_bad_source_version='invalid source package version identifier "%s"'
+oh_str_changelog_found_trailer='found trailer where expected %s'
+oh_str_changelog_bad_trailer='badly formatted trailer line'
+oh_str_changelog_found_change='found change data where expected %s'
+oh_str_changelog_bad_line='unrecognized line'
+oh_str_changelog_found_eof='found eof where expected %s'
# All utilities
oh_str_usage_none='No usage found'