Skip to contentSkip to conversation

gettextizing

PATCH Carles Pina i Estany 3 participants 4 messages Nov 22, 2009 – Nov 23, 2009

lore
Share & tools
lore
#0 lore raw

Hello,

Attached a patch that would gettextize some files under normal (but not the conflictive string, I will implement it later).

Tell how it looks, if you would merge it now or later, etc.

Thanks,

Signature · 2 lines
Carles Pina i Estany
	http://pinux.info

=== added file 'ChangeLog.gettext2'

ChangeLog.gettext2 +5 -0
@@ -0,0 +1,5 @@
+2009-11-22  Carles Pina i Estany <[email protected]>
+
+	* normal/menu_text.c: Gettexttize but not print_timeout function.
+	* normal/main.c: Gettexttize.
+	* normal/menu_entry.c: Likewise.

=== modified file 'normal/main.c'

main.c +3 -2
@@ -29,6 +29,7 @@
 #include <grub/reader.h>
 #include <grub/menu_viewer.h>
 #include <grub/auth.h>
+#include <grub/i18n.h>
 
 #define GRUB_DEFAULT_HISTORY_SIZE	50
 
@@ -508,10 +509,10 @@
   grub_normal_init_page ();
   grub_setcursor (1);
 
-  grub_printf ("\
+  grub_printf (_("\
  [ Minimal BASH-like line editing is supported. For the first word, TAB\n\
    lists possible command completions. Anywhere else TAB lists possible\n\
-   device/file completions.%s ]\n\n",
+   device/file completions.%s ]\n\n"),
 	       reader_nested ? " ESC at any time exits." : "");
 
   return 0;

=== modified file 'normal/menu_entry.c'

menu_entry.c +3 -2
@@ -24,6 +24,7 @@
 #include <grub/command.h>
 #include <grub/parser.h>
 #include <grub/auth.h>
+#include <grub/i18n.h>
 
 enum update_mode
   {
@@ -996,7 +997,7 @@
     }
 
   grub_cls ();
-  grub_printf ("  Booting a command list\n\n");
+  grub_printf (_("  Booting a command list\n\n"));
 
 
   /* Execute the script, line for line.  */
@@ -1176,6 +1177,6 @@
   grub_cls ();
   grub_print_error ();
   grub_errno = GRUB_ERR_NONE;
-  grub_printf ("\nPress any key to continue...");
+  grub_printf (_("\nPress any key to continue..."));
   (void) grub_getkey ();
 }

=== modified file 'normal/menu_text.c'

menu_text.c +10 -10
@@ -39,7 +39,7 @@
 void
 grub_wait_after_message (void)
 {
-  grub_printf ("\nPress any key to continue...");
+  grub_printf (_("\nPress any key to continue..."));
   (void) grub_getkey ();
   grub_putchar ('\n');
 }
@@ -87,22 +87,22 @@
 
   if (edit)
     {
-      grub_printf ("\n\
+      grub_printf (_("\n\
       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_uint32_t) GRUB_TERM_DISP_UP, (grub_uint32_t) GRUB_TERM_DISP_DOWN);
-      grub_printf ("\
+      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_printf (_("\n\
+      ESC to return previous menu."));
     }
 }
 
@@ -517,7 +517,7 @@
 notify_booting (grub_menu_entry_t entry,
 		void *userdata __attribute__((unused)))
 {
-  grub_printf ("  Booting \'%s\'\n\n", entry->title);
+  grub_printf (_("  Booting \'%s\'\n\n"), entry->title);
 }
 
 /* Callback invoked when a default menu entry executed because of a timeout
@@ -527,7 +527,7 @@
 notify_fallback (grub_menu_entry_t entry,
 		 void *userdata __attribute__((unused)))
 {
-  grub_printf ("\n  Falling back to \'%s\'\n\n", entry->title);
+  grub_printf (_("\n  Falling back to \'%s\'\n\n"), entry->title);
   grub_millisleep (DEFAULT_ENTRY_ERROR_DELAY_MS);
 }
 
@@ -541,7 +541,7 @@
       grub_print_error ();
       grub_errno = GRUB_ERR_NONE;
     }
-  grub_printf ("\n  Failed to boot default entries.\n");
+  grub_printf (_("\n  Failed to boot default entries.\n"));
   grub_wait_after_message ();
 }
 
#1 lore raw
Quoted 1 line · Carles Pina i Estany

This one needs some cleanup before it can be gettextized. Translators should receive complete messages with no kludges in them. See info gettext "Preparing Strings" for more details on that. For example, these shouldn't be part of the translatable string:

main.c line 513

Quoted 3 lines
main.c +1 -1
-  grub_printf ("\
+  grub_printf (_("\
  [ Minimal BASH-like line editing is supported. For the first word, TAB\n\
    ^
Quoted 1 line
    lists possible command completions. Anywhere else TAB lists possible\n\
                                                                  	  ^^

main.c line 515

Quoted 2 lines
main.c +1 -1
-   device/file completions.%s ]\n\n",
+   device/file completions.%s ]\n\n"),
                              ^^

Eliminating the newlines is not trivial, but it fixes another problem: this string doesn't render well on non-80x25 terminals.

menu_entry.c

Quoted 5 lines
menu_entry.c +2 -2
-  grub_printf ("  Booting a command list\n\n");
+  grub_printf (_("  Booting a command list\n\n"));
[...]
-  grub_printf ("\nPress any key to continue...");
+  grub_printf (_("\nPress any key to continue..."));

I'm not sure if the spaces and newlines here would be a problem. Jordi, any comment?

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."
#2 lore raw
Quoted 11 lines · Robert Millan
Quoted 2 lines

+ grub_printf (_("\
[ Minimal BASH-like line editing is supported. For the first word, TAB\n\

    ^
Quoted 1 line
    lists possible command completions. Anywhere else TAB lists possible\n\
                                                                  	  ^^

main.c line 515

Quoted 2 lines
main.c +1 -1
-   device/file completions.%s ]\n\n",
+   device/file completions.%s ]\n\n"),
                              ^^

Eliminating the newlines is not trivial, but it fixes another problem: this string doesn't render well on non-80x25 terminals.

Right, this string is of the PAIN kind.

Quoted 8 lines

menu_entry.c

Quoted 5 lines
menu_entry.c +2 -2
-  grub_printf ("  Booting a command list\n\n");
+  grub_printf (_("  Booting a command list\n\n"));
[...]
-  grub_printf ("\nPress any key to continue...");
+  grub_printf (_("\nPress any key to continue..."));

I'm not sure if the spaces and newlines here would be a problem. Jordi, any comment?

Not a big issue in this case. However, it makes it difficult to reuse these strings, ie we can end up having 3 different strings:
- \nPress any key to continue...
- Press any key to continue...
- Press any key to continue...\n

which makes it easy to make different translations for the same string if the translator isn't careful.

Signature · 3 lines
Jordi Mallach Pérez  --  Debian developer     http://www.debian.org/
[email protected]     [email protected]     http://www.sindominio.net/
GnuPG public key information available at http://oskuro.net/
#3 lore raw
Quoted 6 lines · Jordi Mallach
Quoted 5 lines

Review

Quoted 2 lines
(quoted diff) +1 -1
-  grub_printf ("\nPress any key to continue...");
+  grub_printf (_("\nPress any key to continue..."));

I'm not sure if the spaces and newlines here would be a problem. Jordi, any comment?

Quoted 8 lines

Not a big issue in this case. However, it makes it difficult to reuse these strings, ie we can end up having 3 different strings:
- \nPress any key to continue...
- Press any key to continue...
- Press any key to continue...\n

which makes it easy to make different translations for the same string if the translator isn't careful.

Thanks Jordi. This made me think, it also makes GCC allocate the string 3 times. So one more reason to handle those!

Signature · 5 lines
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."