... and looking at gettext() docs, for libraries it must be "#define _(String) dgettext (*PACKAGE*, String)": https://www.gnu.org/software/gettext/manual/gettext.html#Libraries.
I'm going to try to fix that in the MHD sources and back with some patch ... :-) On Fri, Feb 24, 2017 at 7:45 PM, silvioprog <[email protected]> wrote: > Complementing, the output translated message (for pt_BR) should be "Falha > ao vincular à porta: Permission denied" instead of "Failed to bind to > port 80: Permission denied". > > On Fri, Feb 24, 2017 at 7:41 PM, silvioprog <[email protected]> wrote: > >> Hello masters, >> >> I'm trying to translate the MHD messages, but any success in my tests. :-/ >> >> My steps (using MHD from trunk): >> >> # build + install >> ./bootstrap && ./configure && sudo make install-strip && sudo ldconfig >> >> # generate the POT file >> xgettext --keyword=_ --language=C --add-comments --sort-output -o >> libmicrohttpd.pot src/microhttpd/*.c >> >> # generate the PO file >> msginit --input=libmicrohttpd.pot --locale=pt_BR --output=libmicrohttpd.po >> >> Now, I open the .po file in the Poedit program and find the message >> "Failed to bind to port" as showed in the following picture: >> >> https://img42.com/VS64t >> >> After clicking in Save button, Poedit generates the .mo file used in my >> test: >> >> # creating + building + running the test >> mkdir -p test/locale/pt_BR/LC_MESSAGES >> mv libmicrohttpd.mo libmicrohttpd.po test/locale/pt_BR/LC_MESSAGES >> cd test >> cat >main.c <<EOF >> #include <stdio.h> >> #include <locale.h> >> #include <libintl.h> >> #include <microhttpd.h> >> >> static int ahc_echo(void *cls, struct MHD_Connection *cnc, const char >> *url, const char *method, const char *version, >> const char *upload_data, size_t *upload_data_size, >> void **ptr) { >> return MHD_NO; >> } >> >> int main() { >> setlocale(LC_ALL, ""); >> bindtextdomain("libmicrohttpd", "locale"); >> textdomain("libmicrohttpd"); >> MHD_start_daemon(MHD_USE_SELECT_INTERNALLY | MHD_FEATURE_MESSGES, >> 80, NULL, NULL, &ahc_echo, NULL, MHD_OPTION_END); >> return 0; >> } >> EOF >> gcc -o test main.c -lmicrohttpd >> export LANGUAGE=pt_BR >> export LANG=pt_BR >> ./test >> Failed to bind to port 80: Permission denied >> >> OK, now let's go debug it checking errors: >> >> strace -e trace=open ./test >> open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 >> open("/usr/local/lib/libmicrohttpd.so.12", O_RDONLY|O_CLOEXEC) = 3 >> open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3 >> open("/usr/lib/x86_64-linux-gnu/libgnutls.so.30", O_RDONLY|O_CLOEXEC) = 3 >> open("/lib/x86_64-linux-gnu/libgcrypt.so.20", O_RDONLY|O_CLOEXEC) = 3 >> open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3 >> open("/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3 >> open("/usr/lib/x86_64-linux-gnu/libp11-kit.so.0", O_RDONLY|O_CLOEXEC) = 3 >> open("/usr/lib/x86_64-linux-gnu/libidn.so.11", O_RDONLY|O_CLOEXEC) = 3 >> open("/usr/lib/x86_64-linux-gnu/libtasn1.so.6", O_RDONLY|O_CLOEXEC) = 3 >> open("/usr/lib/x86_64-linux-gnu/libnettle.so.6", O_RDONLY|O_CLOEXEC) = 3 >> open("/usr/lib/x86_64-linux-gnu/libhogweed.so.4", O_RDONLY|O_CLOEXEC) = 3 >> open("/usr/lib/x86_64-linux-gnu/libgmp.so.10", O_RDONLY|O_CLOEXEC) = 3 >> open("/lib/x86_64-linux-gnu/libgpg-error.so.0", O_RDONLY|O_CLOEXEC) = 3 >> open("/usr/lib/x86_64-linux-gnu/libffi.so.6", O_RDONLY|O_CLOEXEC) = 3 >> open("/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3 >> open("/dev/urandom", O_RDONLY) = 3 >> open("/proc/sys/crypto/fips_enabled", O_RDONLY) = -1 ENOENT (No such >> file or directory) >> open("/etc/gcrypt/hwf.deny", O_RDONLY) = -1 ENOENT (No such file or >> directory) >> open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 4 >> open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 5 >> open("/usr/share/locale/pt_BR/LC_MESSAGES/libc.mo", O_RDONLY) = -1 >> ENOENT (No such file or directory) >> open("/usr/share/locale/pt/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT >> (No such file or directory) >> open("/usr/share/locale-langpack/pt_BR/LC_MESSAGES/libc.mo", O_RDONLY) = >> -1 ENOENT (No such file or directory) >> open("/usr/share/locale-langpack/pt/LC_MESSAGES/libc.mo", O_RDONLY) = -1 >> ENOENT (No such file or directory) >> Failed to bind to port 80: Permission denied >> +++ exited with 0 +++ >> >> I.e, any call to the libmicrohttpd.mo file. :-/ >> >> So, how to translate MHD properly? >> >> Thank you! >> >> P.S: Looking at mhd_options.h I found the following comment: >> >> /** >> * Macro to make it easy to mark text for translation. Note that >> * we do not actually call gettext() in MHD, but we do make it >> * easy to create a ".po" file so that applications that do want >> * to translate error messages can do so. >> */ >> #define _(String) (String) >> >> sorry my ignorance, but, if MHD don't call gettext(), how will it >> translate the massages? o.O >> >> -- >> Silvio Clécio >> > > > > -- > Silvio Clécio > -- Silvio Clécio
