Create single strings for the window title
Currently there is a strings with four placeholders that represents
optional bits: the "press to release", a whitespace (!), the subtitle,
and the application title. This is suboptimal, because it hides the way
the title is composed, and makes it hard to properly translate.
Instead of this string puzzle, create separate strings for each case
(there are only four of them, and one is only the application title).
Each of the string has all the static text availale, with a proper
comment explaining the layout.
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Pino Toscano
3 years ago
1389 | 1389 | { |
1390 | 1390 | VirtViewerWindowPrivate *priv = self->priv; |
1391 | 1391 | char *title; |
1392 | gchar *ungrab = NULL; | |
1393 | 1392 | |
1394 | 1393 | if (priv->grabbed) { |
1395 | 1394 | gchar *label; |
1405 | 1404 | label = g_strdup(_("Ctrl_L+Alt_L")); |
1406 | 1405 | } |
1407 | 1406 | |
1408 | ungrab = g_strdup_printf(_("(Press %s to release pointer)"), label); | |
1407 | if (priv->subtitle) { | |
1408 | /* translators: | |
1409 | * This is "<ungrab accelerator> <subtitle> - <appname>" | |
1410 | * Such as: "(Press Ctrl+Alt to release pointer) BigCorpTycoon MOTD - Virt Viewer" | |
1411 | */ | |
1412 | title = g_strdup_printf(_("(Press %s to release pointer) %s - %s"), | |
1413 | label, | |
1414 | priv->subtitle, | |
1415 | g_get_application_name()); | |
1416 | } else { | |
1417 | /* translators: | |
1418 | * This is "<ungrab accelerator> - <appname>" | |
1419 | * Such as: "(Press Ctrl+Alt to release pointer) - Virt Viewer" | |
1420 | */ | |
1421 | title = g_strdup_printf(_("(Press %s to release pointer) - %s"), | |
1422 | label, | |
1423 | g_get_application_name()); | |
1424 | } | |
1425 | ||
1409 | 1426 | g_free(label); |
1410 | } | |
1411 | ||
1412 | if (!ungrab && !priv->subtitle) | |
1413 | title = g_strdup(g_get_application_name()); | |
1414 | else | |
1427 | } else if (priv->subtitle) { | |
1415 | 1428 | /* translators: |
1416 | * This is "<ungrab (or empty)><space (or empty)><subtitle (or empty)> - <appname>" | |
1417 | * Such as: "(Press Ctrl+Alt to release pointer) BigCorpTycoon MOTD - Virt Viewer" | |
1429 | * This is "<subtitle> - <appname>" | |
1430 | * Such as: "BigCorpTycoon MOTD - Virt Viewer" | |
1418 | 1431 | */ |
1419 | title = g_strdup_printf(_("%s%s%s - %s"), | |
1420 | /* translators: <ungrab empty> */ | |
1421 | ungrab ? ungrab : "", | |
1422 | /* translators: <space> */ | |
1423 | ungrab && priv->subtitle ? _(" ") : "", | |
1432 | title = g_strdup_printf(_("%s - %s"), | |
1424 | 1433 | priv->subtitle, |
1425 | 1434 | g_get_application_name()); |
1435 | } else { | |
1436 | title = g_strdup(g_get_application_name()); | |
1437 | } | |
1426 | 1438 | |
1427 | 1439 | gtk_window_set_title(GTK_WINDOW(priv->window), title); |
1428 | 1440 | |
1429 | 1441 | g_free(title); |
1430 | g_free(ungrab); | |
1431 | 1442 | } |
1432 | 1443 | |
1433 | 1444 | void |