From 84c9091e3416c7b37fb494a4b57be970b9bd1510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Sun, 22 Nov 2020 19:41:35 -0300 Subject: [PATCH 1/4] Add meson build system for localization files. --- meson.build | 5 +++++ po/meson.build | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 meson.build create mode 100644 po/meson.build diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..96e8b668d --- /dev/null +++ b/meson.build @@ -0,0 +1,5 @@ +project('xbps', 'c', + version : '0.60', + default_options : ['warning_level=3']) + +subdir('po') diff --git a/po/meson.build b/po/meson.build new file mode 100644 index 000000000..bcf443686 --- /dev/null +++ b/po/meson.build @@ -0,0 +1,6 @@ +i18n = import('i18n') +i18n.gettext( + meson.project_name(), + args: '--directory=' + meson.source_root(), + preset: 'glib', +) From 3249e3be44b4c31bc2aacd0f575286ffc361e8f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Sun, 22 Nov 2020 19:43:02 -0300 Subject: [PATCH 2/4] configure: add localedir setting. --- configure | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure b/configure index f8895d796..5e481e30f 100755 --- a/configure +++ b/configure @@ -67,6 +67,7 @@ for x; do --bindir) BINDIR=$var;; --mandir) MANDIR=$var;; --datadir) SHAREDIR=$var;; + --localedir) LOCALEDIR=$var;; --build) BUILD=$var;; --host) HOST=$var;; --target) TARGET=$var;; @@ -96,6 +97,7 @@ done : ${BINDIR:=${PREFIX}/bin} : ${LIBDIR:=${EPREFIX}/lib} : ${SHAREDIR:=${EPREFIX}/share} +: ${LOCALEDIR:=${EPREFIX}/share/locale} : ${MANDIR:=${EPREFIX}/share/man} : ${INCLUDEDIR:=${EPREFIX}/include} : ${PKGCONFIGDIR:=${LIBDIR}/pkgconfig} @@ -202,6 +204,8 @@ echo "CPPFLAGS += -DXBPS_VERSION=\\\"${VERSION}\\\"" >>$CONFIG_MK echo "CPPFLAGS += -DXBPS_META_PATH=\\\"${DBDIR}\\\"" >>$CONFIG_MK echo "CPPFLAGS += -DUNUSED=\"__attribute__((__unused__))\"" >>$CONFIG_MK +echo "CPPFLAGS += -DLOCALEDIR=\\\"${LOCALEDIR}\\\"" >>$CONFIG_MK + if [ -d .git ]; then _gitrev=$(git rev-parse --short HEAD) echo "CPPFLAGS += -DXBPS_GIT=\\\"${_gitrev}\\\"" >>$CONFIG_MK From c86dba60a3ec3d44ada7344e857403cd10f5021b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Sun, 22 Nov 2020 19:43:54 -0300 Subject: [PATCH 3/4] [example] xbps-fetch: add localization. --- bin/xbps-fetch/main.c | 12 ++++++++++-- po/POTFILES | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 po/POTFILES diff --git a/bin/xbps-fetch/main.c b/bin/xbps-fetch/main.c index 0411f6567..2e297f942 100644 --- a/bin/xbps-fetch/main.c +++ b/bin/xbps-fetch/main.c @@ -30,6 +30,10 @@ #include #include #include +#include +#include + +#define _(x) gettext(x) #include @@ -39,7 +43,7 @@ static void __attribute__((noreturn)) usage(bool fail) { - fprintf(stdout, + fprintf(stdout,_( "Usage: xbps-fetch [options] \n\n" "OPTIONS\n" " -d, --debug Enable debug messages to stderr\n" @@ -47,7 +51,7 @@ usage(bool fail) " -o, --out Rename downloaded file to \n" " -s, --sha256 Output sha256sums of the files\n" " -v, --verbose Enable verbose output\n" - " -V, --version Show XBPS version\n"); + " -V, --version Show XBPS version\n")); exit(fail ? EXIT_FAILURE : EXIT_SUCCESS); } @@ -101,6 +105,10 @@ main(int argc, char **argv) { NULL, 0, NULL, 0 } }; + setlocale(LC_MESSAGES, ""); + bindtextdomain("xbps", LOCALEDIR); + textdomain("xbps"); + while ((c = getopt_long(argc, argv, "o:dhsVv", longopts, NULL)) != -1) { switch (c) { case 'h': diff --git a/po/POTFILES b/po/POTFILES new file mode 100644 index 000000000..92d4acb41 --- /dev/null +++ b/po/POTFILES @@ -0,0 +1 @@ +bin/xbps-fetch/main.c From 58db5e4099144d96a4214274faafc538214d1530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89rico=20Rolim?= Date: Sun, 22 Nov 2020 19:44:17 -0300 Subject: [PATCH 4/4] [example] po/LINGUAS: add pt_BR translation. --- po/LINGUAS | 1 + 1 file changed, 1 insertion(+) create mode 100644 po/LINGUAS diff --git a/po/LINGUAS b/po/LINGUAS new file mode 100644 index 000000000..d6247d624 --- /dev/null +++ b/po/LINGUAS @@ -0,0 +1 @@ +pt_BR