diff options
-rw-r--r-- | dpkg-deb/main.c | 5 | ||||
-rw-r--r-- | dpkg-split/main.c | 5 | ||||
-rw-r--r-- | dselect/main.cc | 5 | ||||
-rw-r--r-- | lib/dpkg/Makefile.am | 2 | ||||
-rw-r--r-- | lib/dpkg/i18n.c | 32 | ||||
-rw-r--r-- | lib/dpkg/i18n.h | 2 | ||||
-rw-r--r-- | lib/dpkg/libdpkg.map | 2 | ||||
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | src/divertcmd.c | 5 | ||||
-rw-r--r-- | src/main.c | 5 | ||||
-rw-r--r-- | src/querycmd.c | 5 | ||||
-rw-r--r-- | src/statcmd.c | 5 | ||||
-rw-r--r-- | src/trigcmd.c | 5 |
13 files changed, 46 insertions, 33 deletions
diff --git a/dpkg-deb/main.c b/dpkg-deb/main.c index 50c80810e..310bd417d 100644 --- a/dpkg-deb/main.c +++ b/dpkg-deb/main.c @@ -247,10 +247,7 @@ int main(int argc, const char *const *argv) { int ret; setlocale(LC_NUMERIC, "POSIX"); - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - + dpkg_locales_init(PACKAGE); dpkg_program_init(BACKEND); dpkg_options_parse(&argv, cmdinfos, printforhelp); diff --git a/dpkg-split/main.c b/dpkg-split/main.c index 11ac34b6a..2e276315d 100644 --- a/dpkg-split/main.c +++ b/dpkg-split/main.c @@ -155,10 +155,7 @@ static const struct cmdinfo cmdinfos[]= { int main(int argc, const char *const *argv) { int ret; - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - + dpkg_locales_init(PACKAGE); dpkg_program_init(SPLITTER); dpkg_options_parse(&argv, cmdinfos, printforhelp); diff --git a/dselect/main.cc b/dselect/main.cc index dd7d4c45c..e8fc0da84 100644 --- a/dselect/main.cc +++ b/dselect/main.cc @@ -508,10 +508,7 @@ dselect_catch_fatal_error() int main(int, const char *const *argv) { - setlocale(LC_ALL, ""); - bindtextdomain(DSELECT, LOCALEDIR); - textdomain(DSELECT); - + dpkg_locales_init(DSELECT); dpkg_set_progname(DSELECT); push_error_context_func(dselect_catch_fatal_error, print_fatal_error, 0); diff --git a/lib/dpkg/Makefile.am b/lib/dpkg/Makefile.am index 03c646d5c..b94b46441 100644 --- a/lib/dpkg/Makefile.am +++ b/lib/dpkg/Makefile.am @@ -44,7 +44,7 @@ libdpkg_a_SOURCES = \ file.c \ fields.c \ glob.c \ - i18n.h \ + i18n.c i18n.h \ log.c \ mlib.c \ namevalue.c \ diff --git a/lib/dpkg/i18n.c b/lib/dpkg/i18n.c new file mode 100644 index 000000000..aeeaf25c8 --- /dev/null +++ b/lib/dpkg/i18n.c @@ -0,0 +1,32 @@ +/* + * libdpkg - Debian packaging suite library routines + * i18n.c - i18n support + * + * Copyright © 2013 Guillem Jover <guillem@debian.org> + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include <config.h> +#include <compat.h> + +#include <dpkg/i18n.h> + +void +dpkg_locales_init(const char *package) +{ + setlocale(LC_ALL, ""); + bindtextdomain(package, LOCALEDIR); + textdomain(package); +} diff --git a/lib/dpkg/i18n.h b/lib/dpkg/i18n.h index 112be4799..e67df8504 100644 --- a/lib/dpkg/i18n.h +++ b/lib/dpkg/i18n.h @@ -42,6 +42,8 @@ DPKG_BEGIN_DECLS #define N_(str) gettext_noop(str) #define C_(ctxt, str) pgettext(ctxt, str) +void dpkg_locales_init(const char *package); + /** @} */ DPKG_END_DECLS diff --git a/lib/dpkg/libdpkg.map b/lib/dpkg/libdpkg.map index 304df0af2..ed5ea35b0 100644 --- a/lib/dpkg/libdpkg.map +++ b/lib/dpkg/libdpkg.map @@ -62,6 +62,8 @@ LIBDPKG_PRIVATE { fgets_checked; # Charset and string functions + dpkg_locales_init; + cisdigit; str_escape_fmt; diff --git a/po/POTFILES.in b/po/POTFILES.in index 3dc42fba9..d617670cc 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -15,6 +15,7 @@ lib/dpkg/ehandle.c lib/dpkg/fields.c lib/dpkg/file.c lib/dpkg/glob.c +lib/dpkg/i18n.c lib/dpkg/log.c lib/dpkg/mlib.c lib/dpkg/nfmalloc.c diff --git a/src/divertcmd.c b/src/divertcmd.c index 5313fd585..ab5b5e93f 100644 --- a/src/divertcmd.c +++ b/src/divertcmd.c @@ -767,10 +767,7 @@ main(int argc, const char * const *argv) const char *env_pkgname; int ret; - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - + dpkg_locales_init(PACKAGE); dpkg_program_init("dpkg-divert"); dpkg_options_parse(&argv, cmdinfos, printforhelp); diff --git a/src/main.c b/src/main.c index 67477052d..f99515c16 100644 --- a/src/main.c +++ b/src/main.c @@ -843,10 +843,7 @@ commandfd(const char *const *argv) int main(int argc, const char *const *argv) { int ret; - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - + dpkg_locales_init(PACKAGE); dpkg_program_init("dpkg"); dpkg_options_load(DPKG, cmdinfos); dpkg_options_parse(&argv, cmdinfos, printforhelp); diff --git a/src/querycmd.c b/src/querycmd.c index 5f8074b75..bb3866cd7 100644 --- a/src/querycmd.c +++ b/src/querycmd.c @@ -861,10 +861,7 @@ static const struct cmdinfo cmdinfos[]= { int main(int argc, const char *const *argv) { int ret; - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - + dpkg_locales_init(PACKAGE); dpkg_program_init("dpkg-query"); dpkg_options_parse(&argv, cmdinfos, printforhelp); diff --git a/src/statcmd.c b/src/statcmd.c index 3a0a89e23..9a92c55a4 100644 --- a/src/statcmd.c +++ b/src/statcmd.c @@ -346,10 +346,7 @@ main(int argc, const char *const *argv) { int ret; - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - + dpkg_locales_init(PACKAGE); dpkg_program_init("dpkg-statoverride"); dpkg_options_parse(&argv, cmdinfos, printforhelp); diff --git a/src/trigcmd.c b/src/trigcmd.c index 1c1a3ccee..c1cd48b98 100644 --- a/src/trigcmd.c +++ b/src/trigcmd.c @@ -208,10 +208,7 @@ main(int argc, const char *const *argv) const char *badname; enum trigdef_updateflags tduf; - setlocale(LC_ALL, ""); - bindtextdomain(PACKAGE, LOCALEDIR); - textdomain(PACKAGE); - + dpkg_locales_init(PACKAGE); dpkg_program_init("dpkg-trigger"); dpkg_options_parse(&argv, cmdinfos, printforhelp); |