From 20ced1e4e15faf5e3d148414409b4f9cf9ebdd44 Mon Sep 17 00:00:00 2001 From: Matthew Sexton Date: Sun, 8 Sep 2019 09:28:25 -0400 Subject: [PATCH 2/3] Added trnslation headers and static functions --- src/pacman/pacman-conf.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c index d9e596b8..d1a4aca9 100644 --- a/src/pacman/pacman-conf.c +++ b/src/pacman/pacman-conf.c @@ -19,7 +19,9 @@ #include #include +#include #include "conf.h" +#include "util.h" const char *myname = "pacman-conf", *myver = "1.0.0"; @@ -34,6 +36,22 @@ static void cleanup(void) config_free(config); } +/** Sets up gettext localization. Safe to call multiple times. + */ +/* Inspired by the monotone function localize_monotone. */ +#if defined(ENABLE_NLS) +static void localize(void) +{ + static int init = 0; + if(!init) { + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + init = 1; + } +} +#endif + static void usage(int ret) { FILE *stream = (ret ? stderr : stdout); @@ -404,6 +422,11 @@ int main(int argc, char **argv) goto cleanup; } + /* i18n init */ +#if defined(ENABLE_NLS) + localize(); +#endif + for(; optind < argc; optind++) { directives = alpm_list_add(directives, argv[optind]); } -- 2.23.0