[Pkg-privacy-commits] [libgsecuredelete] 03/25: Add i18n support
Intrigeri
intrigeri at moszumanska.debian.org
Wed Dec 7 17:10:34 UTC 2016
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to branch master
in repository libgsecuredelete.
commit fd7fa31f4f9b1a723a8cfb2f6b8d52f86f19d2ae
Author: Colomban Wendling <ban at herbesfolles.org>
Date: Wed Jul 13 23:00:54 2016 +0200
Add i18n support
---
.gitignore | 10 ++++
HACKING | 2 +-
Makefile.am | 12 +++--
configure.ac | 5 ++
gsd-sfill-helper.in => gsd-sfill-helper.sh.in | 23 ++++----
gsecuredelete/Makefile.am | 5 +-
gsecuredelete/config.vapi | 3 ++
gsecuredelete/gsd-async-operation.vala | 8 +--
gsecuredelete/gsd-swap-operation.vala | 2 +-
po/LINGUAS | 1 +
po/Makevars | 78 +++++++++++++++++++++++++++
po/POTFILES.in | 11 ++++
12 files changed, 139 insertions(+), 21 deletions(-)
diff --git a/.gitignore b/.gitignore
index f19d930..d4118f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,16 @@ stamp-*
build/aux/
build/m4/
+po/Makefile.in.in
+po/POTFILES
+po/Makevars.template
+po/Rules-quot
+po/*.gmo
+po/*.header
+po/*.sed
+po/*.sin
+po/*.pot
+
# remove this if adding some C sources
*.[ch]
diff --git a/HACKING b/HACKING
index 4f1136d..e2bc3cc 100644
--- a/HACKING
+++ b/HACKING
@@ -25,7 +25,7 @@
A test application for the operations. It is not actual part of the
library.
-* gsd-sfill-helper.in:
+* gsd-sfill-helper.sh.in:
A wrapper script for `sfill` for it to support file size limits and
possibly run the operation as root.
diff --git a/Makefile.am b/Makefile.am
index e313dd3..bad7cd2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = gsecuredelete docs
+SUBDIRS = gsecuredelete docs po
ACLOCAL_AMFLAGS = -I build/m4 -I build
@@ -16,12 +16,14 @@ pkgconfig_DATA = gsecuredelete.pc
pkglibexec_SCRIPTS = gsd-sfill-helper
CLEANFILES = $(pkglibexec_SCRIPTS)
-EXTRA_DIST += gsd-sfill-helper.in
+EXTRA_DIST += gsd-sfill-helper.sh.in
compile_script = $(SED) -e 's%[@]SRM_PATH[@]%$(SRM_PATH)%g' \
- -e 's%[@]SFILL_PATH[@]%$(SFILL_PATH)%g'
+ -e 's%[@]SFILL_PATH[@]%$(SFILL_PATH)%g' \
+ -e 's%[@]GETTEXT_PACKAGE[@]%$(PACKAGE)%g' \
+ -e 's%[@]LOCALEDIR[@]%$(localedir)%g'
-gsd-sfill-helper: gsd-sfill-helper.in Makefile
+gsd-sfill-helper: gsd-sfill-helper.sh.in Makefile
$(AM_V_GEN) \
- $(compile_script) < $(srcdir)/gsd-sfill-helper.in > $@ && \
+ $(compile_script) < $(srcdir)/gsd-sfill-helper.sh.in > $@ && \
chmod +x $@
diff --git a/configure.ac b/configure.ac
index 757bf6d..20b53d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,8 +59,13 @@ PKG_CHECK_MODULES([GOBJECT], [gobject-2.0])
# Checks for library functions.
+# i18n
+AM_GNU_GETTEXT_VERSION([0.17])
+AM_GNU_GETTEXT([external])
+
AC_CONFIG_FILES([Makefile
gsecuredelete/Makefile
docs/Makefile
+ po/Makefile.in
gsecuredelete.pc])
AC_OUTPUT
diff --git a/gsd-sfill-helper.in b/gsd-sfill-helper.sh.in
similarity index 84%
rename from gsd-sfill-helper.in
rename to gsd-sfill-helper.sh.in
index 809fc5a..a619bb9 100644
--- a/gsd-sfill-helper.in
+++ b/gsd-sfill-helper.sh.in
@@ -19,6 +19,11 @@
# drop-in replacement and wrapper script for sfill to work around its lack of
# support for file size limits.
+. gettext.sh
+
+export TEXTDOMAIN="@GETTEXT_PACKAGE@"
+export TEXTDOMAINDIR="@LOCALEDIR@"
+
SRM="@SRM_PATH@"
SFILL="@SFILL_PATH@"
@@ -42,11 +47,11 @@ die() {
# check we have the required tools
which "$SRM" >/dev/null || \
- die "$SRM: command not found. " \
- "Please make sure secure-delete is correctly installed."
+ die "$(eval_gettext '$SRM: command not found. ')" \
+ "$(gettext "Please make sure secure-delete is correctly installed.")"
which "$SFILL" >/dev/null || \
- die "$SFILL: command not found. "\
- "Please make sure secure-delete is correctly installed."
+ die "$(eval_gettext '$SFILL: command not found. ')" \
+ "$(gettext "Please make sure secure-delete is correctly installed.")"
# parse arguments
@@ -66,7 +71,7 @@ shift $(expr $OPTIND - 1)
# do our work in a temp directory so in the worst case if we fail to cleanup we
# don't leave the user with tons of temp files but a single directory
-dir=$(mktemp -d --tmpdir="$1") || die "failed to create temp directory"
+dir=$(mktemp -d --tmpdir="$1") || die "$(gettext "failed to create temporary directory")"
# runs a command asynchronously and wait for the trap handler to run
# immediately. the pid of the launched command is in $cmdpid
@@ -85,7 +90,7 @@ launch_cmd() {
}
cleanup() {
- echo 'Terminated by signal. Clean exit.' >&2
+ echo "$(gettext 'Terminated by signal. Clean exit.')" >&2
rm -rf '$dir'
# kill current background job if any
@@ -123,7 +128,7 @@ if [ `whoami` != root ]; then
fstype=$(df -T "$dir" | tail -n1 | tr -s ' ' | cut -d' ' -f 2)
case $fstype in
msdos|umsdos|vfat) # no need to be root for those FS
- [ -n $OPT_v ] || echo "File system type is $fstype, no need to be root"
+ [ -n $OPT_v ] || echo "$(eval_gettext 'File system type is $fstype, no need to be root')"
;;
*) # guess we better be root for all other FS types, so try to become root!
@@ -136,7 +141,7 @@ if [ `whoami` != root ]; then
fi
fi
- echo "Continuing without root privileges, wipe may be incomplete" >&2
+ echo "$(gettext "Continuing without root privileges, wipe may be incomplete")" >&2
MISSING_ROOT=1
;;
esac
@@ -178,6 +183,6 @@ fi
# if we missed root permissions, report this as a special failure (42)
if [ $MISSING_ROOT -ne 0 ]; then
- echo "Wipe succeeded but may have been incomplete due to missing root privileges.">&2
+ echo "$(gettext "Wipe succeeded but may have been incomplete due to missing root privileges.")">&2
exit 42
fi
diff --git a/gsecuredelete/Makefile.am b/gsecuredelete/Makefile.am
index 6c09e99..c5c62e3 100644
--- a/gsecuredelete/Makefile.am
+++ b/gsecuredelete/Makefile.am
@@ -5,7 +5,9 @@ EXTRA_DIST = config.vapi
DISTCLEANFILES = gsd-config.h
AM_VALAFLAGS = $(VALA_PACKAGES:%=--pkg=%)
-AM_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -DG_LOG_DOMAIN=\"$(PACKAGE)\"
+AM_CPPFLAGS = -DGETTEXT_PACKAGE=\"$(PACKAGE)\" -DLOCALEDIR=\"$(localedir)\" \
+ -DG_LOG_DOMAIN=\"$(PACKAGE)\"
+AM_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS)
AM_LDFLAGS = $(GLIB_LIBS) $(GOBJECT_LIBS)
libgsecuredelete_la_includedir=$(includedir)/gsecuredelete
@@ -18,6 +20,7 @@ libgsecuredelete_la_LDFLAGS = $(AM_LDFLAGS) \
libgsecuredelete_la_SOURCES = gsd-async-operation.vala \
gsd-delete-operation.vala \
gsd-fill-operation.vala \
+ gsd-intl.vala \
gsd-mem-operation.vala \
gsd-secure-delete-operation.vala \
gsd-swap-operation.vala \
diff --git a/gsecuredelete/config.vapi b/gsecuredelete/config.vapi
index 528495c..9a528e8 100644
--- a/gsecuredelete/config.vapi
+++ b/gsecuredelete/config.vapi
@@ -4,6 +4,9 @@ namespace Gsd.Config
{
public const string PACKAGE;
public const string VERSION;
+ /* i18n */
+ public const string GETTEXT_PACKAGE;
+ public const string LOCALEDIR;
/* program paths */
public const string SRM_PATH;
public const string SFILL_PATH;
diff --git a/gsecuredelete/gsd-async-operation.vala b/gsecuredelete/gsd-async-operation.vala
index 2699702..6f1c8bc 100644
--- a/gsecuredelete/gsd-async-operation.vala
+++ b/gsecuredelete/gsd-async-operation.vala
@@ -308,7 +308,7 @@ namespace Gsd
finished = false;
} else {
if (! Process.if_exited (exit_status)) {
- message = "Subprocess crashed.\n" + get_subprocess_error_msg ();
+ message = _("Subprocess crashed.") + "\n" + get_subprocess_error_msg ();
} else {
int status_int = Process.exit_status (exit_status);
ExitStatus status = this.classify_exit_status (status_int);
@@ -316,7 +316,7 @@ namespace Gsd
if (status == ExitStatus.WARNING) {
message = get_subprocess_error_msg ();
} else if (status == ExitStatus.ERROR) {
- message = "Subprocess failed.\n" + get_subprocess_error_msg ();
+ message = _("Subprocess failed.") + "\n" + get_subprocess_error_msg ();
}
success = (status != ExitStatus.ERROR);
@@ -450,9 +450,9 @@ namespace Gsd
success = false;
if (! Process.if_exited (exit_status)) {
- message = "Subprocess crashed.\n" + error_output;
+ message = _("Subprocess crashed.") + "\n" + error_output;
} else if (Process.exit_status (exit_status) != 0) {
- message = "Subprocess failed.\n" + error_output;
+ message = _("Subprocess failed.") + "\n" + error_output;
} else {
success = true;
}
diff --git a/gsecuredelete/gsd-swap-operation.vala b/gsecuredelete/gsd-swap-operation.vala
index 82bdf39..e891de5 100644
--- a/gsecuredelete/gsd-swap-operation.vala
+++ b/gsecuredelete/gsd-swap-operation.vala
@@ -93,7 +93,7 @@ namespace Gsd
/* not really clean to throw AsyncOperationError.SUBCLASS_ERROR, but
* there's no clean way to do that.. */
if (this.check_device && this.swap_is_in_use (this.device)) {
- throw new AsyncOperationError.SUBCLASS_ERROR ("The swap device \"%s\" is in use",
+ throw new AsyncOperationError.SUBCLASS_ERROR (_("The swap device \"%s\" is in use"),
this.device);
}
diff --git a/po/LINGUAS b/po/LINGUAS
new file mode 100644
index 0000000..8bba9bc
--- /dev/null
+++ b/po/LINGUAS
@@ -0,0 +1 @@
+# Set of available languages.
diff --git a/po/Makevars b/po/Makevars
new file mode 100644
index 0000000..5a27404
--- /dev/null
+++ b/po/Makevars
@@ -0,0 +1,78 @@
+# Makefile variables for PO directory in any package using GNU gettext.
+
+# Usually the message domain is the same as the package name.
+DOMAIN = $(PACKAGE)
+
+# These two variables depend on the location of this directory.
+subdir = po
+top_builddir = ..
+
+# These options get passed to xgettext.
+XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
+
+# This is the copyright holder that gets inserted into the header of the
+# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
+# package. (Note that the msgstr strings, extracted from the package's
+# sources, belong to the copyright holder of the package.) Translators are
+# expected to transfer the copyright for their translations to this person
+# or entity, or to disclaim their copyright. The empty string stands for
+# the public domain; in this case the translators are expected to disclaim
+# their copyright.
+COPYRIGHT_HOLDER = Colomban Wendling <ban at herbesfolles.org>
+
+# This tells whether or not to prepend "GNU " prefix to the package
+# name that gets inserted into the header of the $(DOMAIN).pot file.
+# Possible values are "yes", "no", or empty. If it is empty, try to
+# detect it automatically by scanning the files in $(top_srcdir) for
+# "GNU packagename" string.
+PACKAGE_GNU = no
+
+# This is the email address or URL to which the translators shall report
+# bugs in the untranslated strings:
+# - Strings which are not entire sentences, see the maintainer guidelines
+# in the GNU gettext documentation, section 'Preparing Strings'.
+# - Strings which use unclear terms or require additional context to be
+# understood.
+# - Strings which make invalid assumptions about notation of date, time or
+# money.
+# - Pluralisation problems.
+# - Incorrect English spelling.
+# - Incorrect formatting.
+# It can be your email address, or a mailing list address where translators
+# can write to without being subscribed, or the URL of a web page through
+# which the translators can contact you.
+MSGID_BUGS_ADDRESS = $(PACKAGE_BUGREPORT)
+
+# This is the list of locale categories, beyond LC_MESSAGES, for which the
+# message catalogs shall be used. It is usually empty.
+EXTRA_LOCALE_CATEGORIES =
+
+# This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
+# context. Possible values are "yes" and "no". Set this to yes if the
+# package uses functions taking also a message context, like pgettext(), or
+# if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
+USE_MSGCTXT = no
+
+# These options get passed to msgmerge.
+# Useful options are in particular:
+# --previous to keep previous msgids of translated messages,
+# --quiet to reduce the verbosity.
+MSGMERGE_OPTIONS =
+
+# These options get passed to msginit.
+# If you want to disable line wrapping when writing PO files, add
+# --no-wrap to MSGMERGE_OPTIONS, XGETTEXT_OPTIONS, and
+# MSGINIT_OPTIONS.
+MSGINIT_OPTIONS =
+
+# This tells whether or not to regenerate a PO file when $(DOMAIN).pot
+# has changed. Possible values are "yes" and "no". Set this to no if
+# the POT file is checked in the repository and the version control
+# program ignores timestamps.
+PO_DEPENDS_ON_POT = yes
+
+# This tells whether or not to forcibly update $(DOMAIN).pot and
+# regenerate PO files on "make dist". Possible values are "yes" and
+# "no". Set this to no if the POT file and PO files are maintained
+# externally.
+DIST_DEPENDS_ON_UPDATE_PO = yes
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..437020b
--- /dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,11 @@
+# List of source files which contain translatable strings.
+gsd-sfill-helper.sh.in
+gsecuredelete/gsd-async-operation.vala
+gsecuredelete/gsd-delete-operation.vala
+gsecuredelete/gsd-fill-operation.vala
+gsecuredelete/gsd-intl.vala
+gsecuredelete/gsd-mem-operation.vala
+gsecuredelete/gsd-secure-delete-operation.vala
+gsecuredelete/gsd-swap-operation.vala
+gsecuredelete/gsd-utils.vala
+gsecuredelete/gsd-zeroable-operation.vala
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libgsecuredelete.git
More information about the Pkg-privacy-commits
mailing list