1

I have an click app that depend on some lib,
and i have package that lib in the click package.
the lib loaded well. but the translations file (.mo) are not founded.
my click file free look like this:

/
/share
/share/locale/<LANG>/LC_MESSAGES/somlib.mo
/lib/i386-linux-gnu/somelib.so

Of course, there is more files, but that what i think that relevant for the question.

i also try to put it on /usr/share/locale/<LANG>/LC_MESSAGES/somlib.mo

but what i have found, that the lib try to find the translations files on real /usr/share/locale/... what i do not have access to it, with click package to put files there...
(i copy the files to this path with mv, and it is work)

I tried to use strace to know where that lib look for his files, but i don't know how to do it on the phone (using emulator). trying strace qmlscene gave me error that i have to connect to mir server, or something like that.

Thank you.

2
+50

The directory where gettext will search for translations for a particular translation domain is controlled by the bindtextdomain function. The library most likely has a call to this function somewhere in its initialisation routines. So two options you could try are:

  1. Modify the library so the bindtextdomain call specifies a directory based on $APP_DIR. So where the library might run:

    bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
    

    You might change it to something like:

    const char *app_dir = getenv("APP_DIR");
    if (app_dir) {
        char *localedir = NULL;
        asprintf(&localedir, "%s/share/locale", app_dir);
        bindtextdomain(PACKAGE, localedir);
        free(localedir);
    } else {
        /* Not running as a click package: use compiled in default */
        bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
    }
    
  2. Make a second call to bindtextdomain that will run after the library's initialisation that sets the correct directory for the library's translation domain (possibly using code similar to the above).

It is hard to offer any more advice without knowing more about the specifics.

  • first of all ,thank you. 1. that mean that i have to recompile the lib? 2. this is my code, you can give me a hint were to put that? additionally, if the bindtextdomain path is /usr/share/locale/... it should not be within the environment of the app? – avi software Jun 22 '15 at 16:27
  • (1) would require recompiling the library, yes. Looking at the library source sourceforge.net/p/libhdate/code/HEAD/tree/trunk/libhdate/src/… it looks like it is calling bindtextdomain every time that function is called, so it doesn't look like (2) will be possible. – James Henstridge Jun 23 '15 at 0:18
  • i tried to add this. i don't know what APP_ID is looking for... because that no work. and i can't run strace ... if i add second call to bindtextdomain with char *localedir ="/opt/click.ubuntu.com/hebrew-calendar.avisoftware/current/share/locale"; that work, you think it is good solution? – avi software Jun 23 '15 at 6:51
  • The APP_DIR environment variable is set to the directory where your application is installed, which is why I suggested using that to construct the locale directory you pass to bindtextdomain. That way you don't have to depend on the exact install location. – James Henstridge Jun 23 '15 at 9:22
  • something strange, the APP_DIR from the app return the correct path /opt/click.ubuntu.com/.click/users/phablet/hebrew-calendar.avisoftware but, from the lib it is not return this.. what is returns? i don't know.... – avi software Jun 24 '15 at 5:49

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.