All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carles Pina i Estany <carles@pina.cat>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: gettextize normal/menu_text.c (print_timeout)
Date: Wed, 25 Nov 2009 00:30:59 +0000	[thread overview]
Message-ID: <20091125003059.GA31362@pina.cat> (raw)
In-Reply-To: <20091125000812.GA30522@pina.cat>

[-- Attachment #1: Type: text/plain, Size: 840 bytes --]


Hi,

On Nov/25/2009, Carles Pina i Estany wrote:
> 
> Hi,
> 
> > > +  const char *msg_localized = _("   The highlighted entry will be booted automatically in %ds.");
> > > +  const int msg_localized_len = grub_strlen (msg_localized);
> > > +  const int number_spaces = GRUB_TERM_WIDTH - msg_localized_len;
> > 
> > Seems like the right approach.  I wonder if we should do something
> > about the preceding spaces too...
> 
> find attached a patch that gettextizes menu_text.c

now yes, attached

BTW, I left spaces on the left of lot of strings. In my opinion I would
delete it and call print_spaces(3);. Fine? (or call grub_printf ("   ");
).

I removed the \n from the end of strings and used grub_putchar ('\n');
or grub_printf ("\n\n"); to not bother the translators and reuse the
strings.

-- 
Carles Pina i Estany
	http://pinux.info

[-- Attachment #2: gettext_menu_text.patch --]
[-- Type: text/x-diff, Size: 4051 bytes --]

=== modified file 'normal/menu_text.c'
--- normal/menu_text.c	2009-11-23 20:59:24 +0000
+++ normal/menu_text.c	2009-11-25 00:02:18 +0000
@@ -39,7 +39,8 @@ static grub_uint8_t grub_color_menu_high
 void
 grub_wait_after_message (void)
 {
-  grub_printf ("\nPress any key to continue...");
+  grub_putchar('\n');
+  grub_printf (_("Press any key to continue..."));
   (void) grub_getkey ();
   grub_putchar ('\n');
 }
@@ -84,25 +85,31 @@ static void
 print_message (int nested, int edit)
 {
   grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
-
+  
+  grub_putchar ('\n');
   if (edit)
     {
-      grub_printf ("\n\
+      grub_printf (_("\
       Minimum Emacs-like screen editing is supported. TAB lists\n\
       completions. Press Ctrl-x to boot, Ctrl-c for a command-line\n\
-      or ESC to return menu.");
+      or ESC to return menu."));
     }
   else
     {
-      grub_printf (_("\n\
-      Use the %C and %C keys to select which entry is highlighted.\n"),
+      grub_printf (_("\
+      Use the %C and %C keys to select which entry is highlighted."),
 		   (grub_uint32_t) GRUB_TERM_DISP_UP, (grub_uint32_t) GRUB_TERM_DISP_DOWN);
-      grub_printf ("\
+      grub_putchar ('\n');
+
+      grub_printf (_("\
       Press enter to boot the selected OS, \'e\' to edit the\n\
-      commands before booting or \'c\' for a command-line.");
+      commands before booting or \'c\' for a command-line."));
       if (nested)
-	grub_printf ("\n\
-      ESC to return previous menu.");
+        {
+	  grub_putchar ('\n');
+	  grub_printf (_("\
+        ESC to return previous menu."));
+	}
     }
 }
 
@@ -263,15 +270,28 @@ get_entry_number (const char *name)
 }
 
 static void
+print_spaces (int number_spaces)
+{
+  int i;
+  for (i = 0; i < number_spaces; i++)
+    grub_putchar(' ');
+}
+
+static void
 print_timeout (int timeout, int offset, int second_stage)
 {
   /* NOTE: Do not remove the trailing space characters.
      They are required to clear the line.  */
-  char *msg = "   The highlighted entry will be booted automatically in %ds.    ";
+  const char *msg = _("   The highlighted entry will be booted automatically in %ds.");
+  const int msg_localized_len = grub_strlen (msg);
+  const int number_spaces = GRUB_TERM_WIDTH - msg_localized_len;
+  
   char *msg_end = grub_strchr (msg, '%');
 
   grub_gotoxy (second_stage ? (msg_end - msg) : 0, GRUB_TERM_HEIGHT - 3);
   grub_printf (second_stage ? msg_end : msg, timeout);
+  print_spaces (second_stage ? number_spaces : 0);
+
   grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
   grub_refresh ();
 };
@@ -360,8 +380,7 @@ run_menu (grub_menu_t menu, int nested, 
 	  if (timeout >= 0)
 	    {
 	      grub_gotoxy (0, GRUB_TERM_HEIGHT - 3);
-              grub_printf ("\
-                                                                        ");
+	      print_spaces (GRUB_TERM_WIDTH - 1);
 	      grub_env_unset ("timeout");
 	      grub_env_unset ("fallback");
 	      grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
@@ -517,7 +536,8 @@ static void
 notify_booting (grub_menu_entry_t entry,
 		void *userdata __attribute__((unused)))
 {
-  grub_printf ("  Booting \'%s\'\n\n", entry->title);
+  grub_printf (_("  Booting \'%s\'"), entry->title);
+  grub_printf ("\n\n");
 }
 
 /* Callback invoked when a default menu entry executed because of a timeout
@@ -527,7 +547,9 @@ static void
 notify_fallback (grub_menu_entry_t entry,
 		 void *userdata __attribute__((unused)))
 {
-  grub_printf ("\n  Falling back to \'%s\'\n\n", entry->title);
+  grub_putchar('\n');
+  grub_printf (_("  Falling back to \'%s\'"), entry->title);
+  grub_printf ("\n\n");
   grub_millisleep (DEFAULT_ENTRY_ERROR_DELAY_MS);
 }
 
@@ -541,7 +563,9 @@ notify_execution_failure (void *userdata
       grub_print_error ();
       grub_errno = GRUB_ERR_NONE;
     }
-  grub_printf ("\n  Failed to boot default entries.\n");
+  grub_putchar ('\n');
+  grub_printf (_("  Failed to boot default entries."));
+  grub_putchar ('\n');
   grub_wait_after_message ();
 }


  reply	other threads:[~2009-11-25  0:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-22 23:50 gettextize normal/menu_text.c (print_timeout) Carles Pina i Estany
2009-11-23 12:04 ` Robert Millan
2009-11-25  0:08   ` Carles Pina i Estany
2009-11-25  0:30     ` Carles Pina i Estany [this message]
2009-11-25 18:55       ` Robert Millan
2009-11-25 22:09         ` Carles Pina i Estany
2009-11-25 22:21           ` Vladimir 'φ-coder/phcoder' Serbinenko
2009-11-25 22:54             ` Carles Pina i Estany
2009-11-26  1:50               ` Robert Millan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091125003059.GA31362@pina.cat \
    --to=carles@pina.cat \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.