From 1892f8cb1da5727e56323a42f7c2ff9b5d596c31 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 6 Jan 2009 12:35:19 +0000 Subject: [PATCH] Allow localizations to change the text direction The locale translators of Clutter are also the ones that should set the default direction of the text in a Clutter user interface. This commit adds a translatable string that defines the direction of the text; the translation authors will change it to the correct value and that will determine the default direction. The default text direction can be overridden by using the CLUTTER_TEXT_DIRECTION environment variable, or by using the --clutter-text-direction command line switch. In any other case, the locale will determine the text direction, as it should. --- clutter/clutter-main.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 2bd6a7dee..38ed3e5cf 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -406,19 +406,34 @@ _clutter_do_pick (ClutterStage *stage, static PangoDirection clutter_get_text_direction (void) { - const gchar *direction; PangoDirection dir = PANGO_DIRECTION_LTR; + const gchar *direction; direction = g_getenv ("CLUTTER_TEXT_DIRECTION"); if (direction && *direction != '\0') { if (strcmp (direction, "rtl") == 0) dir = PANGO_DIRECTION_RTL; - else + else if (strcmp (direction, "ltr") == 0) dir = PANGO_DIRECTION_LTR; } else - dir = PANGO_DIRECTION_LTR; + { + /* Translate to default:RTL if you want your widgets + * to be RTL, otherwise translate to default:LTR. + * + * Do *not* translate it to "predefinito:LTR": if it + * it isn't default:LTR or default:RTL it will not work + */ + char *e = _("default:LTR"); + + if (strcmp (e, "default:RTL") == 0) + dir = PANGO_DIRECTION_RTL; + else if (strcmp (e, "default:LTR") == 0) + dir = PANGO_DIRECTION_LTR; + else + g_warning ("Whoever translated default:LTR did so wrongly."); + } return dir; }