app: add "language" gimprc option and set the language accordingly
This commit is contained in:
28
app/app.c
28
app/app.c
@ -20,6 +20,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <locale.h>
|
||||||
|
|
||||||
#ifdef HAVE_SYS_PARAM_H
|
#ifdef HAVE_SYS_PARAM_H
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -64,9 +65,11 @@
|
|||||||
|
|
||||||
/* local prototypes */
|
/* local prototypes */
|
||||||
|
|
||||||
static void app_init_update_none (const gchar *text1,
|
static void app_init_update_noop (const gchar *text1,
|
||||||
const gchar *text2,
|
const gchar *text2,
|
||||||
gdouble percentage);
|
gdouble percentage);
|
||||||
|
static void app_init_language (const gchar *language);
|
||||||
|
|
||||||
static gboolean app_exit_after_callback (Gimp *gimp,
|
static gboolean app_exit_after_callback (Gimp *gimp,
|
||||||
gboolean kill_it,
|
gboolean kill_it,
|
||||||
GMainLoop *loop);
|
GMainLoop *loop);
|
||||||
@ -183,6 +186,9 @@ app_run (const gchar *full_prog_name,
|
|||||||
|
|
||||||
config = GIMP_BASE_CONFIG (gimp->config);
|
config = GIMP_BASE_CONFIG (gimp->config);
|
||||||
|
|
||||||
|
/* change the locale if a language if specified */
|
||||||
|
app_init_language (gimp->config->language);
|
||||||
|
|
||||||
/* initialize lowlevel stuff */
|
/* initialize lowlevel stuff */
|
||||||
swap_is_ok = base_init (config, be_verbose, use_cpu_accel);
|
swap_is_ok = base_init (config, be_verbose, use_cpu_accel);
|
||||||
|
|
||||||
@ -194,7 +200,7 @@ app_run (const gchar *full_prog_name,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (! update_status_func)
|
if (! update_status_func)
|
||||||
update_status_func = app_init_update_none;
|
update_status_func = app_init_update_noop;
|
||||||
|
|
||||||
/* Create all members of the global Gimp instance which need an already
|
/* Create all members of the global Gimp instance which need an already
|
||||||
* parsed gimprc, e.g. the data factories
|
* parsed gimprc, e.g. the data factories
|
||||||
@ -258,10 +264,26 @@ app_run (const gchar *full_prog_name,
|
|||||||
/* private functions */
|
/* private functions */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
app_init_update_none (const gchar *text1,
|
app_init_update_noop (const gchar *text1,
|
||||||
const gchar *text2,
|
const gchar *text2,
|
||||||
gdouble percentage)
|
gdouble percentage)
|
||||||
{
|
{
|
||||||
|
/* deliberately do nothing */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
app_init_language (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;
|
||||||
|
|
||||||
|
g_printerr ("Setting language to %s\n", language);
|
||||||
|
|
||||||
|
g_setenv ("LANGUAGE", language, TRUE);
|
||||||
|
setlocale (LC_ALL, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
PROP_LANGUAGE,
|
||||||
PROP_INTERPOLATION_TYPE,
|
PROP_INTERPOLATION_TYPE,
|
||||||
PROP_PLUG_IN_PATH,
|
PROP_PLUG_IN_PATH,
|
||||||
PROP_MODULE_PATH,
|
PROP_MODULE_PATH,
|
||||||
@ -133,6 +134,11 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
|
|||||||
object_class->set_property = gimp_core_config_set_property;
|
object_class->set_property = gimp_core_config_set_property;
|
||||||
object_class->get_property = gimp_core_config_get_property;
|
object_class->get_property = gimp_core_config_get_property;
|
||||||
|
|
||||||
|
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_LANGUAGE,
|
||||||
|
"language", LANGUAGE_BLURB,
|
||||||
|
NULL, /* take from environment */
|
||||||
|
GIMP_PARAM_STATIC_STRINGS |
|
||||||
|
GIMP_CONFIG_PARAM_RESTART);
|
||||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_INTERPOLATION_TYPE,
|
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_INTERPOLATION_TYPE,
|
||||||
"interpolation-type",
|
"interpolation-type",
|
||||||
INTERPOLATION_TYPE_BLURB,
|
INTERPOLATION_TYPE_BLURB,
|
||||||
@ -422,6 +428,7 @@ gimp_core_config_finalize (GObject *object)
|
|||||||
{
|
{
|
||||||
GimpCoreConfig *core_config = GIMP_CORE_CONFIG (object);
|
GimpCoreConfig *core_config = GIMP_CORE_CONFIG (object);
|
||||||
|
|
||||||
|
g_free (core_config->language);
|
||||||
g_free (core_config->plug_in_path);
|
g_free (core_config->plug_in_path);
|
||||||
g_free (core_config->module_path);
|
g_free (core_config->module_path);
|
||||||
g_free (core_config->interpreter_path);
|
g_free (core_config->interpreter_path);
|
||||||
@ -468,6 +475,10 @@ gimp_core_config_set_property (GObject *object,
|
|||||||
|
|
||||||
switch (property_id)
|
switch (property_id)
|
||||||
{
|
{
|
||||||
|
case PROP_LANGUAGE:
|
||||||
|
g_free (core_config->language);
|
||||||
|
core_config->language = g_value_dup_string (value);
|
||||||
|
break;
|
||||||
case PROP_INTERPOLATION_TYPE:
|
case PROP_INTERPOLATION_TYPE:
|
||||||
core_config->interpolation_type = g_value_get_enum (value);
|
core_config->interpolation_type = g_value_get_enum (value);
|
||||||
break;
|
break;
|
||||||
@ -652,6 +663,9 @@ gimp_core_config_get_property (GObject *object,
|
|||||||
|
|
||||||
switch (property_id)
|
switch (property_id)
|
||||||
{
|
{
|
||||||
|
case PROP_LANGUAGE:
|
||||||
|
g_value_set_string (value, core_config->language);
|
||||||
|
break;
|
||||||
case PROP_INTERPOLATION_TYPE:
|
case PROP_INTERPOLATION_TYPE:
|
||||||
g_value_set_enum (value, core_config->interpolation_type);
|
g_value_set_enum (value, core_config->interpolation_type);
|
||||||
break;
|
break;
|
||||||
|
@ -39,6 +39,7 @@ struct _GimpCoreConfig
|
|||||||
{
|
{
|
||||||
GimpBaseConfig parent_instance;
|
GimpBaseConfig parent_instance;
|
||||||
|
|
||||||
|
gchar *language;
|
||||||
GimpInterpolationType interpolation_type;
|
GimpInterpolationType interpolation_type;
|
||||||
gchar *plug_in_path;
|
gchar *plug_in_path;
|
||||||
gchar *module_path;
|
gchar *module_path;
|
||||||
|
@ -198,6 +198,9 @@ N_("Sets the level of interpolation used for scaling and other " \
|
|||||||
#define INTERPRETER_PATH_BLURB \
|
#define INTERPRETER_PATH_BLURB \
|
||||||
"Sets the interpreter search path."
|
"Sets the interpreter search path."
|
||||||
|
|
||||||
|
#define LANGUAGE_BLURB \
|
||||||
|
N_("Specifies the language to use.")
|
||||||
|
|
||||||
#define LAST_OPENED_SIZE_BLURB \
|
#define LAST_OPENED_SIZE_BLURB \
|
||||||
N_("How many recently opened image filenames to keep on the File menu.")
|
N_("How many recently opened image filenames to keep on the File menu.")
|
||||||
|
|
||||||
|
@ -615,6 +615,12 @@ gimp_init_malloc (void)
|
|||||||
static void
|
static void
|
||||||
gimp_init_i18n (void)
|
gimp_init_i18n (void)
|
||||||
{
|
{
|
||||||
|
/* We may change the locale later if the user specifies a language
|
||||||
|
* in the gimprc file. Here we are just initializing the locale
|
||||||
|
* according to the environment variables and set up the paths to
|
||||||
|
* the message catalogs.
|
||||||
|
*/
|
||||||
|
|
||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
|
|
||||||
bindtextdomain (GETTEXT_PACKAGE"-libgimp", gimp_locale_directory ());
|
bindtextdomain (GETTEXT_PACKAGE"-libgimp", gimp_locale_directory ());
|
||||||
|
Reference in New Issue
Block a user