tools: gst-play: mark more strings for translation
authorTim-Philipp Müller <tim@centricular.com>
Sun, 24 May 2015 17:46:21 +0000 (18:46 +0100)
committerTim-Philipp Müller <tim@centricular.com>
Sun, 24 May 2015 17:46:21 +0000 (18:46 +0100)
tools/gst-play.c

index 7c4a2ff..4e955d0 100644 (file)
@@ -231,7 +231,8 @@ play_set_relative_volume (GstPlay * play, gdouble volume_step)
   gst_stream_volume_set_volume (GST_STREAM_VOLUME (play->playbin),
       GST_STREAM_VOLUME_FORMAT_CUBIC, volume);
 
-  g_print ("Volume: %.0f%%                  \n", volume * 100);
+  g_print (_("Volume: %.0f%%"), volume * 100);
+  g_print ("                  \n");
 }
 
 /* returns TRUE if something was installed and we should restart playback */
@@ -320,7 +321,7 @@ play_bus_msg (GstBus * bus, GstMessage * msg, gpointer user_data)
       g_print ("\n");
       /* and switch to next item in list */
       if (!play_next (play)) {
-        g_print ("Reached end of play list.\n");
+        g_print ("%s\n", _("Reached end of play list."));
         g_main_loop_quit (play->loop);
       }
       break;
@@ -366,7 +367,7 @@ play_bus_msg (GstBus * bus, GstMessage * msg, gpointer user_data)
       }
       /* try next item in list then */
       if (!play_next (play)) {
-        g_print ("Reached end of play list.\n");
+        g_print ("%s\n", _("Reached end of play list."));
         g_main_loop_quit (play->loop);
       }
       break;
@@ -500,7 +501,8 @@ play_uri (GstPlay * play, const gchar * next_uri)
   play_reset (play);
 
   loc = play_uri_get_display_name (play, next_uri);
-  g_print ("Now playing %s\n", loc);
+  g_print (_("Now playing %s"), loc);
+  g_print ("\n");
   g_free (loc);
 
   g_object_set (play->playbin, "uri", next_uri, NULL);
@@ -563,7 +565,8 @@ play_about_to_finish (GstElement * playbin, gpointer user_data)
 
   next_uri = play->uris[next_idx];
   loc = play_uri_get_display_name (play, next_uri);
-  g_print ("About to finish, preparing next title: %s\n", loc);
+  g_print (_("About to finish, preparing next title: %s"), loc);
+  g_print ("\n");
   g_free (loc);
 
   g_object_set (play->playbin, "uri", next_uri, NULL);
@@ -685,7 +688,7 @@ relative_seek (GstPlay * play, gdouble percent)
   pos = pos + dur * percent;
   if (pos > dur) {
     if (!play_next (play)) {
-      g_print ("\nReached end of play list.\n");
+      g_print ("\n%s\n", _("Reached end of play list."));
       g_main_loop_quit (play->loop);
     }
   } else {
@@ -775,9 +778,12 @@ static void
 play_set_playback_rate (GstPlay * play, gdouble rate)
 {
   if (play_set_rate_and_trick_mode (play, rate, play->trick_mode)) {
-    g_print ("Rate: %.2f                               \n", rate);
+    g_print (_("Playback rate: %.2f"), rate);
+    g_print ("                               \n");
   } else {
-    g_print ("\nCould not change playback rate to %.2f.\n", rate);
+    g_print ("\n");
+    g_print (_("Could not change playback rate to %.2f"), rate);
+    g_print (".\n");
   }
 }
 
@@ -834,20 +840,42 @@ play_switch_trick_mode (GstPlay * play)
 static void
 print_keyboard_help (void)
 {
-  g_print ("\n\nInteractive mode - keyboard control:\n");
-  g_print ("space    : pause/unpause\n");
-  g_print ("q or ESC : quit\n");
-  g_print (">        : play next\n");
-  g_print ("<        : play previous\n");
-  g_print ("left     : seek forward\n");
-  g_print ("right    : seek backward\n");
-  g_print ("up       : volume up\n");
-  g_print ("down     : volume down\n");
-  g_print ("+        : increase playback rate\n");
-  g_print ("-        : decrease playback rate\n");
-  g_print ("d        : change playback direction\n");
-  g_print ("t        : enable/disable trick modes\n");
-  g_print ("k        : show keyboard shortcuts\n\n");
+  static struct
+  {
+    const gchar *key_desc;
+    const gchar *key_help;
+  } key_controls[] = {
+    {
+    N_("space"), N_("pause/unpause")}, {
+    N_("q or ESC"), N_("quit")}, {
+    ">", N_("play next")}, {
+    "<", N_("play previous")}, {
+    "\342\206\222", N_("seek forward")}, {
+    "\342\206\220", N_("seek backward")}, {
+    "\342\206\221", N_("volume up")}, {
+    "\342\206\223", N_("volume down")}, {
+    "+", N_("increase playback rate")}, {
+    "-", N_("decrease playback rate")}, {
+    "d", N_("change playback direction")}, {
+    "t", N_("enable/disable trick modes")}, {
+  "k", N_("show keyboard shortcuts")},};
+  guint i, chars_to_pad, desc_len, max_desc_len = 0;
+
+  g_print ("\n\n%s\n\n", _("Interactive mode - keyboard controls:"));
+
+  for (i = 0; i < G_N_ELEMENTS (key_controls); ++i) {
+    desc_len = g_utf8_strlen (key_controls[i].key_desc, -1);
+    max_desc_len = MAX (max_desc_len, desc_len);
+  }
+  ++max_desc_len;
+
+  for (i = 0; i < G_N_ELEMENTS (key_controls); ++i) {
+    chars_to_pad = max_desc_len - g_utf8_strlen (key_controls[i].key_desc, -1);
+    g_print ("\t%s", key_controls[i].key_desc);
+    g_print ("%-*s: ", chars_to_pad, "");
+    g_print ("%s\n", key_controls[i].key_help);
+  }
+  g_print ("\n");
 }
 
 static void
@@ -868,7 +896,7 @@ keyboard_cb (const gchar * key_input, gpointer user_data)
       break;
     case '>':
       if (!play_next (play)) {
-        g_print ("\nReached end of play list.\n");
+        g_print ("\n%s\n", _("Reached end of play list."));
         g_main_loop_quit (play->loop);
       }
       break;
@@ -1068,7 +1096,7 @@ main (int argc, char **argv)
 
   if (interactive) {
     if (gst_play_kb_set_key_handler (keyboard_cb, play)) {
-      g_print ("Press 'k' to see a list of keyboard shortcuts.\n");
+      g_print (_("Press 'k' to see a list of keyboard shortcuts.\n"));
       atexit (restore_terminal);
     } else {
       g_print ("Interactive keyboard handling in terminal not available.\n");