Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Add internationalization to XBPS #350

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions bin/xbps-fetch/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include <errno.h>
#include <unistd.h>
#include <getopt.h>
#include <libintl.h>
#include <locale.h>

#define _(x) gettext(x)

#include <openssl/sha.h>

Expand All @@ -39,15 +43,15 @@
static void __attribute__((noreturn))
usage(bool fail)
{
fprintf(stdout,
fprintf(stdout,_(
"Usage: xbps-fetch [options] <url> <url+N>\n\n"
"OPTIONS\n"
" -d, --debug Enable debug messages to stderr\n"
" -h, --help Show usage\n"
" -o, --out <file> Rename downloaded file to <file>\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);
}

Expand Down Expand Up @@ -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':
Expand Down
4 changes: 4 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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;;
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
project('xbps', 'c',
version : '0.60',
default_options : ['warning_level=3'])

subdir('po')
1 change: 1 addition & 0 deletions po/LINGUAS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pt_BR
1 change: 1 addition & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bin/xbps-fetch/main.c
6 changes: 6 additions & 0 deletions po/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
i18n = import('i18n')
i18n.gettext(
meson.project_name(),
args: '--directory=' + meson.source_root(),
preset: 'glib',
)