-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add function to initialize locale directory localedir #796
Conversation
The function is called from gp_abilities_list_new() so existing code will carry on working as before. Non-standard installations of libgphoto2 can call the initialisation function with their choice of locale dir. The function includes code to ensure it's only run once.
I like the idea. What other aspects of non-standard installations are there, and should those be dealt with separately or in a coordinated way? I vaguely remember iolib and camlib locations being candidates for a similar non-standard install setup function. |
I've handled iolibs and camlibs locations by setting environment variables, but initialisation functions would be a nicer way of doing it. That would be a different PR though. |
Different PR maybe, but it would be nice if similar functions were named similarly, called similarly, and behaved similarly. If we are extending the API, we should do it in a halfway consistent manner, and this PR is as good a place to start with that as any. The PR commit e6747c4 adds a function to libgphoto2
This name uses "initialise" with letter "s". From a quick grep, we mostly use the "initialize" spelling using the letter "z" in our comments, but for function names the "z" vs "s" does not matter because our function names just use "init". "init" is a very common abbreviation, it is faster to type, takes less space, and does not need looking up whether it is written with "s" vs "z".
We already have the following two functions which are a bit related, both as to when and how they are called, and that they are also dealing with translated messages:
where Naming this consistently could be
if it is just for initialization or
if it is meant to be called any time to set the However, now we have two of functions with closely related functionality (both Anyway, libgphoto2 lacks a comprehensive library initialization function ("gp_init", "gp_library_init", like "libusb_init"), to which such initialization parameters could be resonably passed. So we need another way to do that kind of setup, while not breaking the existing ABI and API. Is it conceivable that someone needs to change the localedir, camlibdir, iolibdir after they have started doing actual things with libgphoto2? I do not think so, but my thinking is not always comprehensive. For a setting once model, the following set of functions and function names would make sense to me:
All (Note1: If we integrate libgphoto2_port into libgphoto2, we could remove the distinction between (Note2: If we can support statically adding (dlpreload) all drivers to the respective, we do not need camlibdir and iolibdir any more. There is no way around localedir, though.) When adding API functions, we also need to increment BTW, the |
I agree with all your points. Returning |
I read https://www.freebsd.org/cgi/man.cgi?query=bindtextdomain&apropos=0 as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure it make sense to
locale_initialised = 1;
in the error case.
For consistency with the other 300 uses of the word "initialize", use the AE spelling.
I agree. |
BTW, why the |
The Maybe |
Argh. Sorry for bringing this up. The relevant difference is that inside the gettext code, the codeset has a useful default without us calling any initialization function at all, while the localedir must be set (at least) once. So the two functions are fine flag-wise as they are. So we either have a Apropos I will have to check that when I am back in front of a PC. |
Calling |
Argh. Sorry for bringing this up. The relevant difference is that inside the gettext code, the codeset has a useful default without us calling any initialization function at all, while the localedir must be set (at least) once. https://www.gnu.org/software/libc/manual/html_node/Locating-gettext-catalog.html So we either have a Apropos I will have to check that when I am back in front of a PC. |
It appears the symbol version LIBGPHOTO2_5_0 takes the **5** part from libgphoto2 PACKAGE_VERSION 2.**5**.something, not from the soname libgphoto2.so.**6**.
@msmeissn I have a few questions for you
|
Implement and document that giving a NULL localedir argument to gp_init_localedir() or gp_port_init_localedir() means to use the compile time default value LOCALEDIR, which is usually something like /usr/share/locale.
# # gp_port_info_list_append, gp_port_info_list_get_info | ||
# | ||
# # Add new exported functions here too! | ||
#} LIBGPHOTO2_5_0; | ||
#}; # LIBGPHOTO2_6_0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are weird?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, but i see its all commented out.
looks good to me |
I have just squashed my barrage of commits, rebased onto master, and merged the result into master. Thank you very much for the original PR and the ensuing productive cooperation! |
The function is called from gp_abilities_list_new() so existing code
will carry on working as before. Non-standard installations of
libgphoto2 can call the initialisation function with their choice of
locale dir. The function includes code to ensure it's only run once.