mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 09:23:24 +00:00
app: reload plug-ins when language changes between runs.
Since localization is fully handled plug-in side now (see #8124), we need to make sure the query functions are run again for all plug-ins when the UI language changes (otherwise we might end up with localizations from the previously used languages). We were already reloading plug-ins when explicitly changing the lang in the Preferences, but this new implementation is much better as it's generic. In particular, it will also handle the case when the system language changes (or when you play with locale environment variables).
This commit is contained in:
parent
ca1a0e3650
commit
a7a027706b
7 changed files with 73 additions and 11 deletions
25
app/app.c
25
app/app.c
|
@ -67,6 +67,7 @@
|
|||
|
||||
#include "app.h"
|
||||
#include "errors.h"
|
||||
#include "language.h"
|
||||
#include "sanity.h"
|
||||
#include "gimp-debug.h"
|
||||
|
||||
|
@ -193,8 +194,10 @@ app_run (const gchar *full_prog_name,
|
|||
GFile *default_folder = NULL;
|
||||
GFile *gimpdir;
|
||||
const gchar *abort_message;
|
||||
GError *font_error = NULL;
|
||||
gint retval = EXIT_SUCCESS;
|
||||
const gchar *current_language;
|
||||
gchar *prev_language = NULL;
|
||||
GError *font_error = NULL;
|
||||
gint retval = EXIT_SUCCESS;
|
||||
|
||||
if (filenames && filenames[0] && ! filenames[1] &&
|
||||
g_file_test (filenames[0], G_FILE_TEST_IS_DIR))
|
||||
|
@ -309,6 +312,17 @@ app_run (const gchar *full_prog_name,
|
|||
*/
|
||||
gimp_initialize (gimp, update_status_func);
|
||||
|
||||
g_object_get (gimp->edit_config,
|
||||
"prev-language", &prev_language,
|
||||
NULL);
|
||||
/* Language was already initialized. I call this again only to get the
|
||||
* actual language information.
|
||||
*/
|
||||
current_language = language_init (NULL);
|
||||
gimp->query_all = (prev_language == NULL ||
|
||||
g_strcmp0 (prev_language, current_language) != 0);
|
||||
g_free (prev_language);
|
||||
|
||||
/* Load all data files
|
||||
*/
|
||||
gimp_restore (gimp, update_status_func, &font_error);
|
||||
|
@ -323,11 +337,12 @@ app_run (const gchar *full_prog_name,
|
|||
*/
|
||||
gimp_update_auto_check (gimp->edit_config, gimp);
|
||||
|
||||
/* Set this after gimp_update_auto_check(). This will be used for the
|
||||
* next run.
|
||||
*/
|
||||
/* Setting properties to be used for the next run. */
|
||||
g_object_set (gimp->edit_config,
|
||||
/* Set this after gimp_update_auto_check(). */
|
||||
"config-version", GIMP_VERSION,
|
||||
/* Set this after gimp_restore(). */
|
||||
"prev-language", current_language,
|
||||
NULL);
|
||||
|
||||
loop = run_loop = g_main_loop_new (NULL, FALSE);
|
||||
|
|
|
@ -56,6 +56,7 @@ enum
|
|||
{
|
||||
PROP_0,
|
||||
PROP_LANGUAGE,
|
||||
PROP_PREV_LANGUAGE,
|
||||
PROP_CONFIG_VERSION,
|
||||
PROP_INTERPOLATION_TYPE,
|
||||
PROP_DEFAULT_THRESHOLD,
|
||||
|
@ -183,6 +184,19 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
|
|||
GIMP_PARAM_STATIC_STRINGS |
|
||||
GIMP_CONFIG_PARAM_RESTART);
|
||||
|
||||
/* The language which was being used previously. If the "language"
|
||||
* property was at default (i.e. System language), this
|
||||
* must map to the actually used language for UI display, because if
|
||||
* this changed (for whatever reasons, e.g. changed environment
|
||||
* variables, or actually changing system language), we want to reload
|
||||
* plug-ins.
|
||||
*/
|
||||
GIMP_CONFIG_PROP_STRING (object_class, PROP_PREV_LANGUAGE,
|
||||
"prev-language",
|
||||
"Language used in previous run",
|
||||
NULL, NULL,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
/* This is the version of the config files, which must map to the
|
||||
* version of GIMP. It is used right now only to detect the last run
|
||||
* version in order to detect an update. It could be used later also
|
||||
|
@ -902,6 +916,10 @@ gimp_core_config_set_property (GObject *object,
|
|||
g_free (core_config->language);
|
||||
core_config->language = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_PREV_LANGUAGE:
|
||||
g_free (core_config->prev_language);
|
||||
core_config->prev_language = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_INTERPOLATION_TYPE:
|
||||
core_config->interpolation_type = g_value_get_enum (value);
|
||||
break;
|
||||
|
@ -1203,6 +1221,9 @@ gimp_core_config_get_property (GObject *object,
|
|||
case PROP_LANGUAGE:
|
||||
g_value_set_string (value, core_config->language);
|
||||
break;
|
||||
case PROP_PREV_LANGUAGE:
|
||||
g_value_set_string (value, core_config->prev_language);
|
||||
break;
|
||||
case PROP_INTERPOLATION_TYPE:
|
||||
g_value_set_enum (value, core_config->interpolation_type);
|
||||
break;
|
||||
|
|
|
@ -41,6 +41,7 @@ struct _GimpCoreConfig
|
|||
GimpGeglConfig parent_instance;
|
||||
|
||||
gchar *language;
|
||||
gchar *prev_language;
|
||||
GimpInterpolationType interpolation_type;
|
||||
gint default_threshold;
|
||||
gchar *plug_in_path;
|
||||
|
|
|
@ -61,6 +61,7 @@ struct _Gimp
|
|||
|
||||
gboolean restored; /* becomes TRUE in gimp_restore() */
|
||||
gboolean initialized; /* Fully initialized (only set once at start). */
|
||||
gboolean query_all; /* Force query all plug-ins. */
|
||||
|
||||
gint busy;
|
||||
guint busy_idle_id;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <langinfo.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
@ -33,9 +34,15 @@
|
|||
#include "language.h"
|
||||
|
||||
|
||||
void
|
||||
const gchar *
|
||||
language_init (const gchar *language)
|
||||
{
|
||||
static gchar *actual_language = NULL;
|
||||
|
||||
if (actual_language != NULL)
|
||||
/* Already initialized. */
|
||||
return actual_language;
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
if (! language &&
|
||||
g_getenv ("LANG") == NULL &&
|
||||
|
@ -731,9 +738,23 @@ language_init (const gchar *language)
|
|||
/* We already set the locale according to the environment, so just
|
||||
* return early if no language is set in gimprc.
|
||||
*/
|
||||
if (! language)
|
||||
return;
|
||||
if (! language || strlen (language) == 0)
|
||||
{
|
||||
/* Using system language. It doesn't matter too much that the string
|
||||
* format is different when using system or preference-set language,
|
||||
* because this string is only used for comparison. As long as 2
|
||||
* similar run have the same settings, the strings will be
|
||||
* identical.
|
||||
*/
|
||||
actual_language = g_strdup (nl_langinfo (_NL_IDENTIFICATION_LANGUAGE));
|
||||
}
|
||||
else
|
||||
{
|
||||
g_setenv ("LANGUAGE", language, TRUE);
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
g_setenv ("LANGUAGE", language, TRUE);
|
||||
setlocale (LC_ALL, "");
|
||||
actual_language = g_strdup (language);
|
||||
}
|
||||
|
||||
return actual_language;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#endif
|
||||
|
||||
|
||||
void language_init (const gchar *language);
|
||||
const gchar * language_init (const gchar *language);
|
||||
|
||||
|
||||
#endif /* __LANGUAGE_H__ */
|
||||
|
|
|
@ -474,6 +474,9 @@ gimp_plug_in_manager_query_new (GimpPlugInManager *manager,
|
|||
{
|
||||
GimpPlugInDef *plug_in_def = list->data;
|
||||
|
||||
if (manager->gimp->query_all)
|
||||
gimp_plug_in_def_set_needs_query (plug_in_def, TRUE);
|
||||
|
||||
if (plug_in_def->needs_query)
|
||||
n_plugins++;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue