[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [libmicrohttpd] 01/06: style fixes to i18n example
From: |
gnunet |
Subject: |
[GNUnet-SVN] [libmicrohttpd] 01/06: style fixes to i18n example |
Date: |
Tue, 21 Mar 2017 21:49:57 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository libmicrohttpd.
commit d14c6aa0f7dfc3b950a9c0c8ef218b6ba4aa4725
Author: Christian Grothoff <address@hidden>
AuthorDate: Tue Mar 21 12:36:53 2017 +0100
style fixes to i18n example
---
src/examples/msgs_i18n.c | 78 +++++++++++++++++++++++++++---------------------
1 file changed, 44 insertions(+), 34 deletions(-)
diff --git a/src/examples/msgs_i18n.c b/src/examples/msgs_i18n.c
index 220729af..2d8eb566 100755
--- a/src/examples/msgs_i18n.c
+++ b/src/examples/msgs_i18n.c
@@ -19,7 +19,8 @@
/**
* @file msgs_i18n.c
* @brief example for how to use translate libmicrohttpd messages
- * @author Christian Grothoff, Silvio Clecio (silvioprog)
+ * @author Christian Grothoff
+ * @author Silvio Clecio (silvioprog)
*/
/*
@@ -35,51 +36,60 @@
* export LANGUAGE=pt_BR
* ./msgs_i18n
* # it may print: Opção inválida 4196490! (Você terminou a lista com
MHD_OPTION_END?)
- *
- * # tip: if you get any problem in your i18n application, you can debug it
using `strace` tool, e.g:
- * $ strace -e trace=open ./msgs_i18n
- *
*/
-
#include <stdio.h>
#include <locale.h>
#include <libintl.h>
#include <microhttpd.h>
-#ifndef _
-#define _(fm) dgettext("libmicrohttpd", fm)
-#endif
static int
-ahc_echo(void *cls,
- struct MHD_Connection *cnc,
- const char *url,
- const char *mt,
- const char *ver,
- const char *upd,
- size_t *upsz,
- void **ptr) {
- return MHD_NO;
+ahc_echo (void *cls,
+ struct MHD_Connection *cnc,
+ const char *url,
+ const char *mt,
+ const char *ver,
+ const char *upd,
+ size_t *upsz,
+ void **ptr)
+{
+ return MHD_NO;
}
+
static void
-error_handler(void *cls,
- const char *fm,
- va_list ap) {
- vprintf(_(fm), ap);
+error_handler (void *cls,
+ const char *fm,
+ va_list ap)
+{
+ /* Here we do the translation using GNU gettext.
+ As the error message is from libmicrohttpd, we specify
+ "libmicrohttpd" as the translation domain here. */
+ vprintf (dgettext ("libmicrohttpd",
+ fm),
+ ap);
}
+
int
-main() {
- setlocale(LC_ALL, "");
- /* notice I'm using PO files in the directory
"libmicrohttpd/src/examples/locale", please change it matching
- * where the MHD PO files are installed */
- bindtextdomain("libmicrohttpd", "locale");
- MHD_start_daemon(MHD_USE_SELECT_INTERNALLY | MHD_FEATURE_MESSAGES |
MHD_USE_ERROR_LOG,
- 8080,
- NULL, NULL,
- &ahc_echo, NULL,
- MHD_OPTION_EXTERNAL_LOGGER, &error_handler, NULL
- /* MHD_OPTION_END - to raise the error "Invalid option
..." we are going to translate */);
- return 1; /* purposely */
+main (int argc,
+ char **argv)
+{
+ setlocale(LC_ALL, "");
+
+ /* The example uses PO files in the directory
+ "libmicrohttpd/src/examples/locale". This
+ needs to be adapted to match
+ where the MHD PO files are installed. */
+ bindtextdomain ("libmicrohttpd",
+ "locale");
+ MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_FEATURE_MESSAGES |
MHD_USE_ERROR_LOG,
+ 8080,
+ NULL, NULL,
+ &ahc_echo, NULL,
+ MHD_OPTION_EXTERNAL_LOGGER, &error_handler, NULL,
+ 99999 /* invalid option, to raise the error
+ "Invalid option ..." which we are going
+ to translate */);
+ return 1; /* This program won't "succeed"... */
}
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [libmicrohttpd] branch master updated (f3dd2a63 -> 0bc2fe6f), gnunet, 2017/03/21
- [GNUnet-SVN] [libmicrohttpd] 05/06: add -lrt for glibc < 2.17 compatibility, gnunet, 2017/03/21
- [GNUnet-SVN] [libmicrohttpd] 01/06: style fixes to i18n example,
gnunet <=
- [GNUnet-SVN] [libmicrohttpd] 03/06: make error message more friendly, gnunet, 2017/03/21
- [GNUnet-SVN] [libmicrohttpd] 06/06: add -lrt for glib, gnunet, 2017/03/21
- [GNUnet-SVN] [libmicrohttpd] 04/06: document MHD_CONNECTION_INFO_CONNECTION_TIMEOUT in manual, gnunet, 2017/03/21
- [GNUnet-SVN] [libmicrohttpd] 02/06: clarify when it is ok to call MHD_get_fdset in documentation, document MHD_get_fdset2(), gnunet, 2017/03/21