From 005b3a05b87ed2aa0bb22d82f0d7a2d54320ab9b Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Wed, 11 Jan 2023 15:42:31 +0100 Subject: [PATCH] Make use of the gimp_bind_text_domain () util function --- app/main.c | 4 ++-- app/widgets/gimplanguagestore-parser.c | 4 ++-- libgimp/gimp.c | 2 +- libgimp/gimpplugin.c | 4 ++-- libgimpbase/gimpenv.c | 25 +++++++------------------ 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/app/main.c b/app/main.c index 2e7e65f8ee..95ad8c021f 100644 --- a/app/main.c +++ b/app/main.c @@ -1073,12 +1073,12 @@ gimp_init_i18n (void) setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE"-libgimp", gimp_locale_directory ()); + gimp_bind_text_domain (GETTEXT_PACKAGE"-libgimp", gimp_locale_directory ()); #ifdef HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset (GETTEXT_PACKAGE"-libgimp", "UTF-8"); #endif - bindtextdomain (GETTEXT_PACKAGE, gimp_locale_directory ()); + gimp_bind_text_domain (GETTEXT_PACKAGE, gimp_locale_directory ()); #ifdef HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif diff --git a/app/widgets/gimplanguagestore-parser.c b/app/widgets/gimplanguagestore-parser.c index 279fccf27e..ad0533fc42 100644 --- a/app/widgets/gimplanguagestore-parser.c +++ b/app/widgets/gimplanguagestore-parser.c @@ -374,9 +374,9 @@ iso_codes_parser_init (void) #ifdef G_OS_WIN32 /* on Win32, assume iso-codes is installed in the same location as GIMP */ - bindtextdomain ("iso_639", gimp_locale_directory ()); + gimp_bind_text_domain ("iso_639", gimp_locale_directory ()); #else - bindtextdomain ("iso_639", ISO_CODES_LOCALEDIR); + gimp_bind_text_domain ("iso_639", ISO_CODES_LOCALEDIR); #endif bind_textdomain_codeset ("iso_639", "UTF-8"); diff --git a/libgimp/gimp.c b/libgimp/gimp.c index 4e751ab8f3..cdf1163566 100644 --- a/libgimp/gimp.c +++ b/libgimp/gimp.c @@ -487,7 +487,7 @@ gimp_main (GType plug_in_type, /* initialize i18n support */ setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE"-libgimp", gimp_locale_directory ()); + gimp_bind_text_domain (GETTEXT_PACKAGE"-libgimp", gimp_locale_directory ()); #ifdef HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset (GETTEXT_PACKAGE"-libgimp", "UTF-8"); #endif diff --git a/libgimp/gimpplugin.c b/libgimp/gimpplugin.c index 41f7833aba..0034b74430 100644 --- a/libgimp/gimpplugin.c +++ b/libgimp/gimpplugin.c @@ -1016,7 +1016,7 @@ _gimp_plug_in_create_procedure (GimpPlugIn *plug_in, if (_gimp_plug_in_set_i18n (plug_in, procedure_name, &gettext_domain, &catalog_dir)) { - bindtextdomain (gettext_domain, catalog_dir); + gimp_bind_text_domain (gettext_domain, catalog_dir); #ifdef HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset (gettext_domain, "UTF-8"); #endif @@ -1346,7 +1346,7 @@ gimp_plug_in_proc_run_internal (GimpPlugIn *plug_in, if (_gimp_plug_in_set_i18n (plug_in, gimp_procedure_get_name (procedure), &gettext_domain, &catalog_dir)) { - bindtextdomain (gettext_domain, catalog_dir); + gimp_bind_text_domain (gettext_domain, catalog_dir); #ifdef HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset (gettext_domain, "UTF-8"); #endif diff --git a/libgimpbase/gimpenv.c b/libgimpbase/gimpenv.c index f95fbf6c4c..435661de7d 100644 --- a/libgimpbase/gimpenv.c +++ b/libgimpbase/gimpenv.c @@ -514,12 +514,13 @@ gimp_data_directory (void) * from the executable's full filename is used. * * The returned string is owned by GIMP and must not be modified or - * freed. The returned string is in the encoding used for filenames by - * the C library, which isn't necessarily UTF-8. (On Windows, unlike - * the other similar functions here, the return value from this - * function is in the system codepage, never in UTF-8. It can thus be - * passed directly to the bindtextdomain() function from libintl which - * does not handle UTF-8.) + * freed. The returned string encoding depends on the system where GIMP + * is running: on UNIX it's in the encoding used for filenames by + * the C library (which isn't necessarily UTF-8); on Windows it's UTF-8. + * + * On UNIX the returned string can be passed directly to the bindtextdomain() + * function from libintl; on Windows the returned string can be converted to + * UTF-16 and passed to the wbindtextdomain() function from libintl. * * Returns: The top directory for GIMP locale files. */ @@ -536,18 +537,6 @@ gimp_locale_directory (void) gimp_locale_dir = gimp_env_get_dir ("GIMP3_LOCALEDIR", LOCALEDIR, tmp); g_free (tmp); - -#ifdef G_OS_WIN32 - /* FIXME: g_win32_locale_filename_from_utf8() can actually return - * NULL (we had actual cases of this). Not sure exactly what - * gimp_locale_directory() should do when this happens. Anyway - * that's really broken, and something should be done some day - * about this! - */ - tmp = g_win32_locale_filename_from_utf8 (gimp_locale_dir); - g_free (gimp_locale_dir); - gimp_locale_dir = tmp; -#endif } return gimp_locale_dir;