diff options
author | Jim Easterbrook <jim@jim-easterbrook.me.uk> | 2022-05-11 09:53:52 +0100 |
---|---|---|
committer | Hans Ulrich Niedermann <hun@n-dimensional.de> | 2022-05-19 17:04:35 +0200 |
commit | 33d2d2e8f7705c68114dcae254c6fc319a4c3378 (patch) | |
tree | ffc24ff9da79d39bcc25ca2c4883b8c8878697ba /libgphoto2/gphoto2-abilities-list.c | |
parent | d1650f14bc3a69ad27dcc6c9f02b8f171adf3379 (diff) | |
download | libgphoto2-33d2d2e8f7705c68114dcae254c6fc319a4c3378.tar.gz |
Add function to initialise locale directory
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.
Diffstat (limited to 'libgphoto2/gphoto2-abilities-list.c')
-rw-r--r-- | libgphoto2/gphoto2-abilities-list.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/libgphoto2/gphoto2-abilities-list.c b/libgphoto2/gphoto2-abilities-list.c index a88861cb3..a65d67cde 100644 --- a/libgphoto2/gphoto2-abilities-list.c +++ b/libgphoto2/gphoto2-abilities-list.c @@ -70,6 +70,26 @@ gp_message_codeset (const char *codeset) } /** + * \brief Initialise localisation. + * + * Call bindtextdomain() with our locale directory. This is called by + * gp_abilities_list_new() so you don't need to call it unless you have a + * non-standard installation. + * \param localedir Root directory of libgphoto2's localisation files. + * \return gphoto2 error code. + */ +int +gp_initialise_locale (const char *localedir) +{ + static int locale_initialised = 0; + if (locale_initialised) + return GP_OK; + locale_initialised = 1; + bindtextdomain (GETTEXT_PACKAGE_LIBGPHOTO2, localedir); + return GP_OK; +} + +/** * \brief Allocate the memory for a new abilities list. * * Function to allocate the memory for a new abilities list. @@ -90,7 +110,7 @@ gp_abilities_list_new (CameraAbilitiesList **list) * an other way without introducing a global initialization * function... */ - bindtextdomain (GETTEXT_PACKAGE_LIBGPHOTO2, LOCALEDIR); + gp_initialise_locale(LOCALEDIR); C_MEM (*list = calloc (1, sizeof (CameraAbilitiesList))); |