summaryrefslogtreecommitdiff
path: root/libgphoto2
diff options
context:
space:
mode:
authorJim Easterbrook <jim@jim-easterbrook.me.uk>2022-05-11 09:53:52 +0100
committerHans Ulrich Niedermann <hun@n-dimensional.de>2022-05-19 17:04:35 +0200
commit33d2d2e8f7705c68114dcae254c6fc319a4c3378 (patch)
treeffc24ff9da79d39bcc25ca2c4883b8c8878697ba /libgphoto2
parentd1650f14bc3a69ad27dcc6c9f02b8f171adf3379 (diff)
downloadlibgphoto2-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')
-rw-r--r--libgphoto2/gphoto2-abilities-list.c22
-rw-r--r--libgphoto2/libgphoto2.sym1
2 files changed, 22 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)));
diff --git a/libgphoto2/libgphoto2.sym b/libgphoto2/libgphoto2.sym
index e83fefcf0..cd82d3680 100644
--- a/libgphoto2/libgphoto2.sym
+++ b/libgphoto2/libgphoto2.sym
@@ -122,6 +122,7 @@ gp_filesystem_set_funcs
gp_file_unref
gp_gamma_correct_single
gp_gamma_fill_table
+gp_initialise_locale
gp_library_version
gp_list_append
gp_list_count