|
From: | silvioprog |
Subject: | Re: [libmicrohttpd] MHD can't find MO files |
Date: | Fri, 24 Feb 2017 20:03:30 -0300 |
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 <address@hidden> 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 filexgettext --keyword=_ --language=C --add-comments --sort-output -o libmicrohttpd.pot src/microhttpd/*.c# generate the PO filemsginit --input=libmicrohttpd.pot --locale=pt_BR --output=libmicrohttpd.poNow, I open the .po file in the Poedit program and find the message "Failed to bind to port" as showed in the following picture:After clicking in Save button, Poedit generates the .mo file used in my test:# creating + building + running the testmkdir -p test/locale/pt_BR/LC_MESSAGESmv libmicrohttpd.mo libmicrohttpd.po test/locale/pt_BR/LC_MESSAGEScd testcat >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;}EOFgcc -o test main.c -lmicrohttpdexport LANGUAGE=pt_BRexport LANG=pt_BR./testFailed to bind to port 80: Permission deniedOK, now let's go debug it checking errors:strace -e trace=open ./testopen("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3open("/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) = 3open("/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écioSilvio Clécio
[Prev in Thread] | Current Thread | [Next in Thread] |