Codebase list virt-viewer / 0325901
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
1 changed file(s) with 26 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
13891389 {
13901390 VirtViewerWindowPrivate *priv = self->priv;
13911391 char *title;
1392 gchar *ungrab = NULL;
13931392
13941393 if (priv->grabbed) {
13951394 gchar *label;
14051404 label = g_strdup(_("Ctrl_L+Alt_L"));
14061405 }
14071406
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
14091426 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) {
14151428 /* 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"
14181431 */
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"),
14241433 priv->subtitle,
14251434 g_get_application_name());
1435 } else {
1436 title = g_strdup(g_get_application_name());
1437 }
14261438
14271439 gtk_window_set_title(GTK_WINDOW(priv->window), title);
14281440
14291441 g_free(title);
1430 g_free(ungrab);
14311442 }
14321443
14331444 void