mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
libgimp: set_i18n() method of GimpPlugIn expects UTF-8 catalog directory.
Nothing was really clearly specified until now, which was kinda equivalent to the string being in the OS encoding as used by GLib. Since this string will usually be statically hardcoded in code (and not extracted from system), it's just much easier to request UTF-8 for this specific case.
This commit is contained in:
parent
f5d2c5369c
commit
f7579eabbb
2 changed files with 35 additions and 14 deletions
|
@ -898,15 +898,17 @@ _gimp_plug_in_set_i18n (GimpPlugIn *plug_in,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
gchar *utf8_catalog_dir = NULL;
|
||||||
|
|
||||||
use_gettext = GIMP_PLUG_IN_GET_CLASS (plug_in)->set_i18n (plug_in,
|
use_gettext = GIMP_PLUG_IN_GET_CLASS (plug_in)->set_i18n (plug_in,
|
||||||
procedure_name,
|
procedure_name,
|
||||||
gettext_domain,
|
gettext_domain,
|
||||||
catalog_dir);
|
&utf8_catalog_dir);
|
||||||
if (use_gettext)
|
if (use_gettext)
|
||||||
{
|
{
|
||||||
gboolean reserved = FALSE;
|
gboolean reserved = FALSE;
|
||||||
|
|
||||||
if (! (*gettext_domain))
|
if (*gettext_domain == NULL)
|
||||||
{
|
{
|
||||||
*gettext_domain = g_strdup (plug_in->priv->translation_domain_name);
|
*gettext_domain = g_strdup (plug_in->priv->translation_domain_name);
|
||||||
}
|
}
|
||||||
|
@ -919,17 +921,34 @@ _gimp_plug_in_set_i18n (GimpPlugIn *plug_in,
|
||||||
* set by the lib itself; devs must set NULL). See docs of
|
* set by the lib itself; devs must set NULL). See docs of
|
||||||
* set_i18n() method.
|
* set_i18n() method.
|
||||||
*/
|
*/
|
||||||
if (*catalog_dir)
|
if (utf8_catalog_dir != NULL)
|
||||||
{
|
g_printerr ("[%s] Do not set a catalog directory with set_i18n() with reserved domain: %s\n",
|
||||||
g_printerr ("[%s] Do not set a catalog directory with set_i18n() with reserved domain: %s\n",
|
procedure_name, *gettext_domain);
|
||||||
procedure_name, *gettext_domain);
|
|
||||||
g_clear_pointer (catalog_dir, g_free);
|
|
||||||
}
|
|
||||||
|
|
||||||
*catalog_dir = g_strdup (gimp_locale_directory ());
|
*catalog_dir = g_strdup (gimp_locale_directory ());
|
||||||
reserved = TRUE;
|
reserved = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (utf8_catalog_dir != NULL && *catalog_dir == NULL)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
/* The passed-on catalog directory is in UTF-8 because this is
|
||||||
|
* usually hardcoded (in which case it's easier to request a
|
||||||
|
* specific encoding, chosen at development time, rather than the
|
||||||
|
* "OS encoding", depending on runtime).
|
||||||
|
* But now we want to transform it to the encoding used for
|
||||||
|
* filenames by GLib.
|
||||||
|
*/
|
||||||
|
*catalog_dir = g_filename_from_utf8 (utf8_catalog_dir, -1, NULL, NULL, &error);
|
||||||
|
|
||||||
|
if (*catalog_dir == NULL)
|
||||||
|
g_printerr ("[%s] provided catalog directory is not proper UTF-8: %s\n",
|
||||||
|
procedure_name, error ? error->message : "(N/A)");
|
||||||
|
|
||||||
|
g_clear_error (&error);
|
||||||
|
}
|
||||||
|
|
||||||
if (*catalog_dir && ! reserved)
|
if (*catalog_dir && ! reserved)
|
||||||
{
|
{
|
||||||
if (g_path_is_absolute (*catalog_dir))
|
if (g_path_is_absolute (*catalog_dir))
|
||||||
|
@ -982,6 +1001,8 @@ _gimp_plug_in_set_i18n (GimpPlugIn *plug_in,
|
||||||
*catalog_dir = g_file_get_path (plug_in->priv->translation_domain_path);
|
*catalog_dir = g_file_get_path (plug_in->priv->translation_domain_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_clear_pointer (&utf8_catalog_dir, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_gettext && ! g_file_test (*catalog_dir, G_FILE_TEST_IS_DIR))
|
if (use_gettext && ! g_file_test (*catalog_dir, G_FILE_TEST_IS_DIR))
|
||||||
|
|
|
@ -134,8 +134,8 @@ struct _GimpPlugInClass
|
||||||
* @gettext_domain: (out) (nullable): Gettext domain. If %NULL, it
|
* @gettext_domain: (out) (nullable): Gettext domain. If %NULL, it
|
||||||
* defaults to the plug-in name as determined by the
|
* defaults to the plug-in name as determined by the
|
||||||
* directory the binary is called from.
|
* directory the binary is called from.
|
||||||
* @catalog_dir: (out) (nullable): relative path to a subdirectory
|
* @catalog_dir: (out) (nullable) (type utf8): relative path to a
|
||||||
* of the plug-in folder containing the compiled
|
* subdirectory of the plug-in folder containing the compiled
|
||||||
* Gettext message catalogs. If %NULL, it defaults to
|
* Gettext message catalogs. If %NULL, it defaults to
|
||||||
* "locale/".
|
* "locale/".
|
||||||
*
|
*
|
||||||
|
@ -157,12 +157,12 @@ struct _GimpPlugInClass
|
||||||
* simply set the method to %NULL, or possibly implement this method
|
* simply set the method to %NULL, or possibly implement this method
|
||||||
* to do something useful for your usage while returning %FALSE.
|
* to do something useful for your usage while returning %FALSE.
|
||||||
*
|
*
|
||||||
* If you wish to tweak the @gettext_domain or the @localedir, return
|
* If you wish to tweak the @gettext_domain or the @catalog_dir, return
|
||||||
* %TRUE and allocate appropriate @gettext_domain and/or @localedir
|
* %TRUE and allocate appropriate @gettext_domain and/or @catalog_dir
|
||||||
* (these use the default if set %NULL).
|
* (these use the default if set %NULL).
|
||||||
*
|
*
|
||||||
* Note that @localedir must be a relative path, subdirectory of the
|
* Note that @catalog_dir must be a relative path, encoded as UTF-8,
|
||||||
* directory of `gimp_get_progname()`.
|
* subdirectory of the directory of `gimp_get_progname()`.
|
||||||
* The domain names "gimp30-std-plug-ins", "gimp30-script-fu" and
|
* The domain names "gimp30-std-plug-ins", "gimp30-script-fu" and
|
||||||
* "gimp30-python" are reserved and can only be used with a %NULL
|
* "gimp30-python" are reserved and can only be used with a %NULL
|
||||||
* @catalog_dir. These will use the translation catalogs installed for
|
* @catalog_dir. These will use the translation catalogs installed for
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue