All of lore.kernel.org
 help / color / mirror / Atom feed
* gettext: help commands
@ 2009-12-25 11:50 Carles Pina i Estany
  2009-12-25 12:16 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2009-12-25 12:27 ` Carles Pina i Estany
  0 siblings, 2 replies; 6+ messages in thread
From: Carles Pina i Estany @ 2009-12-25 11:50 UTC (permalink / raw)
  To: grub-devel

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


Hello,

Find attached a patch that gettextizze the output of:
help play
help search
search --help

So, implements gettext in commands/help.c, lib/arg.c, I also did in
normal/dyncmd.c (for the module not found).

This is only the basic implementation, when this is agreed I will
prepare another patch to gettextizze the help of all commands.

I would commit it in this way when someone reviews it. It's quite
straightforward.

Thanks,

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

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

=== modified file 'ChangeLog'
--- ChangeLog	2009-12-25 00:04:51 +0000
+++ ChangeLog	2009-12-25 11:41:28 +0000
@@ -1,5 +1,25 @@
 2009-12-25  Carles Pina i Estany  <carles@pina.cat>
 
+	* commands/help.c: Include `<grub/i18n.h>'.
+	(grub_cmd_help): Gettextizze.
+	(GRUB_MOD_INIT): Likewise.
+	* commands/i386/pc/play.c: Include `<grub/i18n.h>'.
+	(GRUB_MOD_INIT): Gettextizze.
+	* commands/search.c: Include `<grub/i18n.h>'.
+	(options): Gettextizze.
+	(GRUB_MOD_INIT): Gettextizze.
+	* lib/arg.c: Include `<grub/i18n.h>'.
+	(help_options): Gettextizze.
+	(find_long): Likewise.
+	(grub_arg_show_help): Likewise.
+	* normal/dyncmd.c: Include `<grub/i18n.h>'.
+	(read_command_list): Gettextizze.
+	* po/POTFILES: Add `commands/i386/pc/play.c', `commands/search.c',
+	`commands/help.c', `lib/arg.c' and `normal/dyncmd.c'. 
+
+
+2009-12-25  Carles Pina i Estany  <carles@pina.cat>
+
 	* commands/efi/loadbios.c: Capitalize acronyms, replace `could not' by
 	`couldn't' and `can not' by `cannot'.
 	* commands/i386/pc/drivemap.c: Likewise.

=== modified file 'commands/help.c'
--- commands/help.c	2009-06-10 21:04:23 +0000
+++ commands/help.c	2009-12-25 11:34:16 +0000
@@ -21,6 +21,7 @@
 #include <grub/misc.h>
 #include <grub/term.h>
 #include <grub/extcmd.h>
+#include <grub/i18n.h>
 
 static grub_err_t
 grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
@@ -48,7 +49,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
 		       (desclen < GRUB_TERM_WIDTH / 2 - 1
 			? desclen : GRUB_TERM_WIDTH / 2 - 1));
 
-	  grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " ");
+	  grub_printf ("%s%s", _(description), (cnt++) % 2 ? "\n" : " ");
 	}
       return 0;
     }
@@ -65,8 +66,8 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	      if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
 		grub_arg_show_help ((grub_extcmd_t) cmd->data);
 	      else
-		grub_printf ("Usage: %s\n%s\b", cmd->summary,
-			     cmd->description);
+		grub_printf ("%s %s\n%s\b", _("Usage:"), _(cmd->summary),
+			     _(cmd->description));
 	    }
 	}
       return 0;
@@ -94,8 +95,8 @@ GRUB_MOD_INIT(help)
 {
   cmd = grub_register_extcmd ("help", grub_cmd_help,
 			      GRUB_COMMAND_FLAG_CMDLINE,
-			      "help [PATTERN ...]",
-			      "Show a help message.", 0);
+			      N_("help [PATTERN ...]"),
+			      N_("Show a help message."), 0);
 }
 
 GRUB_MOD_FINI(help)

=== modified file 'commands/i386/pc/play.c'
--- commands/i386/pc/play.c	2009-12-21 22:06:04 +0000
+++ commands/i386/pc/play.c	2009-12-25 11:28:02 +0000
@@ -27,6 +27,7 @@
 #include <grub/machine/time.h>
 #include <grub/cpu/io.h>
 #include <grub/command.h>
+#include <grub/i18n.h>
 
 #define BASE_TEMPO 120
 
@@ -207,7 +208,7 @@ static grub_command_t cmd;
 GRUB_MOD_INIT(play)
 {
   cmd = grub_register_command ("play", grub_cmd_play,
-			       "play FILE", "Play a tune.");
+			       N_("play FILE"), N_("Play a tune."));
 }
 
 GRUB_MOD_FINI(play)

=== modified file 'commands/search.c'
--- commands/search.c	2009-12-21 22:06:04 +0000
+++ commands/search.c	2009-12-25 11:28:02 +0000
@@ -26,14 +26,15 @@
 #include <grub/file.h>
 #include <grub/env.h>
 #include <grub/extcmd.h>
+#include <grub/i18n.h>
 
 static const struct grub_arg_option options[] =
   {
-    {"file",		'f', 0, "Search devices by a file.", 0, 0},
-    {"label",		'l', 0, "Search devices by a filesystem label.", 0, 0},
-    {"fs-uuid",		'u', 0, "Search devices by a filesystem UUID.", 0, 0},
-    {"set",		's', GRUB_ARG_OPTION_OPTIONAL, "Set a variable to the first device found.", "VAR", ARG_TYPE_STRING},
-    {"no-floppy",	'n', 0, "Do not probe any floppy drive.", 0, 0},
+    {"file",		'f', 0, N_("Search devices by a file."), 0, 0},
+    {"label",		'l', 0, N_("Search devices by a filesystem label."), 0, 0},
+    {"fs-uuid",		'u', 0, N_("Search devices by a filesystem UUID."), 0, 0},
+    {"set",		's', GRUB_ARG_OPTION_OPTIONAL, N_("Set a variable to the first device found."), "VAR", ARG_TYPE_STRING},
+    {"no-floppy",	'n', 0, N_("Do not probe any floppy drive."), 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -186,11 +187,11 @@ GRUB_MOD_INIT(search)
   cmd =
     grub_register_extcmd ("search", grub_cmd_search,
 			  GRUB_COMMAND_FLAG_BOTH,
-			  "search [-f|-l|-u|-s|-n] NAME",
-			  "Search devices by file, filesystem label or filesystem UUID."
+			  N_("search [-f|-l|-u|-s|-n] NAME"),
+			  N_("Search devices by file, filesystem label or filesystem UUID."
 			  " If --set is specified, the first device found is"
 			  " set to a variable. If no variable name is"
-			  " specified, \"root\" is used.",
+			  " specified, \"root\" is used."),
 			  options);
 }
 

=== modified file 'lib/arg.c'
--- lib/arg.c	2009-12-24 22:53:05 +0000
+++ lib/arg.c	2009-12-25 11:41:40 +0000
@@ -22,6 +22,7 @@
 #include <grub/err.h>
 #include <grub/term.h>
 #include <grub/extcmd.h>
+#include <grub/i18n.h>
 
 /* Built-in parser for default options.  */
 #define SHORT_ARG_HELP	-100
@@ -30,9 +31,9 @@
 static const struct grub_arg_option help_options[] =
   {
     {"help", SHORT_ARG_HELP, 0,
-     "Display this help and exit.", 0, ARG_TYPE_NONE},
+     N_("Display this help and exit."), 0, ARG_TYPE_NONE},
     {"usage", SHORT_ARG_USAGE, 0,
-     "Display the usage of this command and exit.", 0, ARG_TYPE_NONE},
+     N_("Display the usage of this command and exit."), 0, ARG_TYPE_NONE},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -106,7 +107,7 @@ find_long (const struct grub_arg_option 
 static void
 show_usage (grub_extcmd_t cmd)
 {
-  grub_printf ("Usage: %s\n", cmd->cmd->summary);
+  grub_printf ("%s %s\n", _("Usage:"), _(cmd->cmd->summary));
 }
 
 void
@@ -143,7 +144,7 @@ grub_arg_show_help (grub_extcmd_t cmd)
 		}
 	    }
 
-	  const char *doc = opt->doc;
+	  const char *doc = _(opt->doc);
 	  for (;;)
 	    {
 	      while (spacing-- > 0)
@@ -176,7 +177,7 @@ grub_arg_show_help (grub_extcmd_t cmd)
     }
 
   show_usage (cmd);
-  grub_printf ("%s\n\n", cmd->cmd->description);
+  grub_printf ("%s\n\n", _(cmd->cmd->description));
   if (cmd->options)
     showargs (cmd->options);
   showargs (help_options);

=== modified file 'normal/dyncmd.c'
--- normal/dyncmd.c	2009-11-09 14:50:20 +0000
+++ normal/dyncmd.c	2009-12-25 11:28:02 +0000
@@ -23,6 +23,7 @@
 #include <grub/misc.h>
 #include <grub/command.h>
 #include <grub/normal.h>
+#include <grub/i18n.h>
 
 static grub_err_t
 grub_dyncmd_dispatcher (struct grub_command *cmd,
@@ -132,7 +133,7 @@ read_command_list (void)
 
 		  cmd = grub_register_command_prio (name,
 						    grub_dyncmd_dispatcher,
-						    0, "not loaded", prio);
+						    0, N_("not loaded"), prio);
 		  if (! cmd)
 		    {
 		      grub_free (name);

=== modified file 'normal/menu_text.c'
--- normal/menu_text.c	2009-12-23 16:41:32 +0000
+++ normal/menu_text.c	2009-12-25 11:28:02 +0000
@@ -107,8 +107,10 @@ grub_getstringwidth (grub_uint32_t * str
 void
 grub_print_message_indented (const char *msg, int margin_left, int margin_right)
 {
+  int full_line_len;
   int line_len;
-  line_len = GRUB_TERM_WIDTH - grub_getcharwidth ('m') *
+
+  full_line_len = GRUB_TERM_WIDTH - grub_getcharwidth ('m') *
     (margin_left + margin_right);
 
   grub_uint32_t *unicode_msg;
@@ -129,6 +131,8 @@ grub_print_message_indented (const char 
 
   int first_loop = 1;
 
+  line_len = full_line_len - (grub_getxy() >> 8);
+
   while (current_position < last_position)
     {
       if (! first_loop)
@@ -155,6 +159,7 @@ grub_print_message_indented (const char 
       next_new_line++;
       current_position = next_new_line;
       first_loop = 0;
+      line_len = full_line_len;
     }
   grub_free (unicode_msg);
 }

=== modified file 'po/POTFILES'
--- po/POTFILES	2009-12-21 22:06:04 +0000
+++ po/POTFILES	2009-12-25 11:28:02 +0000
@@ -1,5 +1,12 @@
 # List of files which contain translatable strings.
+commands/i386/pc/play.c
 commands/loadenv.c
+commands/search.c
+commands/help.c
+
+lib/arg.c
+
+normal/dyncmd.c
 
 util/i386/pc/grub-mkimage.c
 util/i386/pc/grub-setup.c


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: gettext: help commands
  2009-12-25 11:50 gettext: help commands Carles Pina i Estany
@ 2009-12-25 12:16 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2009-12-25 12:29   ` Carles Pina i Estany
  2009-12-25 12:27 ` Carles Pina i Estany
  1 sibling, 1 reply; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2009-12-25 12:16 UTC (permalink / raw)
  To: The development of GNU GRUB

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

Carles Pina i Estany wrote:
> Hello,
>
> Find attached a patch that gettextizze the output of:
> help play
> help search
> search --help
>
> So, implements gettext in commands/help.c, lib/arg.c, I also did in
> normal/dyncmd.c (for the module not found).
>
> This is only the basic implementation, when this is agreed I will
> prepare another patch to gettextizze the help of all commands.
>
> I would commit it in this way when someone reviews it. It's quite
> straightforward.
>
>   

>=== modified file 'commands/help.c'
>--- commands/help.c	2009-06-10 21:04:23 +0000
>+++ commands/help.c	2009-12-25 11:34:16 +0000
> grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
>@@ -48,7 +49,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
> 		       (desclen < GRUB_TERM_WIDTH / 2 - 1
> 			? desclen : GRUB_TERM_WIDTH / 2 - 1));
> 
>-	  grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " ");
>+	  grub_printf ("%s%s", _(description), (cnt++) % 2 ? "\n" : " ");
At this point description is already cut at half of terminal width. You have to first translate and then cut the message and not the other way round
> 	}
>       return 0;
>     }


> Thanks,
>
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: gettext: help commands
  2009-12-25 11:50 gettext: help commands Carles Pina i Estany
  2009-12-25 12:16 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2009-12-25 12:27 ` Carles Pina i Estany
  1 sibling, 0 replies; 6+ messages in thread
From: Carles Pina i Estany @ 2009-12-25 12:27 UTC (permalink / raw)
  To: grub-devel

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


Hi,

On Dec/25/2009, Carles Pina i Estany wrote:

> Find attached a patch that gettextizze the output of:

The patch that I wanted to send is the attached one.

It's the same one but without normal/menu_text.c changed as is not
needed (will maybe be in the future).

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

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

=== modified file 'ChangeLog'
--- ChangeLog	2009-12-25 00:04:51 +0000
+++ ChangeLog	2009-12-25 11:45:00 +0000
@@ -1,5 +1,25 @@
 2009-12-25  Carles Pina i Estany  <carles@pina.cat>
 
+	* commands/help.c: Include `<grub/i18n.h>'.
+	(grub_cmd_help): Gettextizze.
+	(GRUB_MOD_INIT): Likewise.
+	* commands/i386/pc/play.c: Include `<grub/i18n.h>'.
+	(GRUB_MOD_INIT): Gettextizze.
+	* commands/search.c: Include `<grub/i18n.h>'.
+	(options): Gettextizze.
+	(GRUB_MOD_INIT): Gettextizze.
+	* lib/arg.c: Include `<grub/i18n.h>'.
+	(help_options): Gettextizze.
+	(find_long): Likewise.
+	(grub_arg_show_help): Likewise.
+	* normal/dyncmd.c: Include `<grub/i18n.h>'.
+	(read_command_list): Gettextizze.
+	* po/POTFILES: Add `commands/i386/pc/play.c', `commands/search.c',
+	`commands/help.c', `lib/arg.c' and `normal/dyncmd.c'. 
+
+
+2009-12-25  Carles Pina i Estany  <carles@pina.cat>
+
 	* commands/efi/loadbios.c: Capitalize acronyms, replace `could not' by
 	`couldn't' and `can not' by `cannot'.
 	* commands/i386/pc/drivemap.c: Likewise.

=== modified file 'commands/help.c'
--- commands/help.c	2009-06-10 21:04:23 +0000
+++ commands/help.c	2009-12-25 11:34:16 +0000
@@ -21,6 +21,7 @@
 #include <grub/misc.h>
 #include <grub/term.h>
 #include <grub/extcmd.h>
+#include <grub/i18n.h>
 
 static grub_err_t
 grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
@@ -48,7 +49,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
 		       (desclen < GRUB_TERM_WIDTH / 2 - 1
 			? desclen : GRUB_TERM_WIDTH / 2 - 1));
 
-	  grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " ");
+	  grub_printf ("%s%s", _(description), (cnt++) % 2 ? "\n" : " ");
 	}
       return 0;
     }
@@ -65,8 +66,8 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	      if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
 		grub_arg_show_help ((grub_extcmd_t) cmd->data);
 	      else
-		grub_printf ("Usage: %s\n%s\b", cmd->summary,
-			     cmd->description);
+		grub_printf ("%s %s\n%s\b", _("Usage:"), _(cmd->summary),
+			     _(cmd->description));
 	    }
 	}
       return 0;
@@ -94,8 +95,8 @@ GRUB_MOD_INIT(help)
 {
   cmd = grub_register_extcmd ("help", grub_cmd_help,
 			      GRUB_COMMAND_FLAG_CMDLINE,
-			      "help [PATTERN ...]",
-			      "Show a help message.", 0);
+			      N_("help [PATTERN ...]"),
+			      N_("Show a help message."), 0);
 }
 
 GRUB_MOD_FINI(help)

=== modified file 'commands/i386/pc/play.c'
--- commands/i386/pc/play.c	2009-12-21 22:06:04 +0000
+++ commands/i386/pc/play.c	2009-12-25 11:28:02 +0000
@@ -27,6 +27,7 @@
 #include <grub/machine/time.h>
 #include <grub/cpu/io.h>
 #include <grub/command.h>
+#include <grub/i18n.h>
 
 #define BASE_TEMPO 120
 
@@ -207,7 +208,7 @@ static grub_command_t cmd;
 GRUB_MOD_INIT(play)
 {
   cmd = grub_register_command ("play", grub_cmd_play,
-			       "play FILE", "Play a tune.");
+			       N_("play FILE"), N_("Play a tune."));
 }
 
 GRUB_MOD_FINI(play)

=== modified file 'commands/search.c'
--- commands/search.c	2009-12-21 22:06:04 +0000
+++ commands/search.c	2009-12-25 11:28:02 +0000
@@ -26,14 +26,15 @@
 #include <grub/file.h>
 #include <grub/env.h>
 #include <grub/extcmd.h>
+#include <grub/i18n.h>
 
 static const struct grub_arg_option options[] =
   {
-    {"file",		'f', 0, "Search devices by a file.", 0, 0},
-    {"label",		'l', 0, "Search devices by a filesystem label.", 0, 0},
-    {"fs-uuid",		'u', 0, "Search devices by a filesystem UUID.", 0, 0},
-    {"set",		's', GRUB_ARG_OPTION_OPTIONAL, "Set a variable to the first device found.", "VAR", ARG_TYPE_STRING},
-    {"no-floppy",	'n', 0, "Do not probe any floppy drive.", 0, 0},
+    {"file",		'f', 0, N_("Search devices by a file."), 0, 0},
+    {"label",		'l', 0, N_("Search devices by a filesystem label."), 0, 0},
+    {"fs-uuid",		'u', 0, N_("Search devices by a filesystem UUID."), 0, 0},
+    {"set",		's', GRUB_ARG_OPTION_OPTIONAL, N_("Set a variable to the first device found."), "VAR", ARG_TYPE_STRING},
+    {"no-floppy",	'n', 0, N_("Do not probe any floppy drive."), 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -186,11 +187,11 @@ GRUB_MOD_INIT(search)
   cmd =
     grub_register_extcmd ("search", grub_cmd_search,
 			  GRUB_COMMAND_FLAG_BOTH,
-			  "search [-f|-l|-u|-s|-n] NAME",
-			  "Search devices by file, filesystem label or filesystem UUID."
+			  N_("search [-f|-l|-u|-s|-n] NAME"),
+			  N_("Search devices by file, filesystem label or filesystem UUID."
 			  " If --set is specified, the first device found is"
 			  " set to a variable. If no variable name is"
-			  " specified, \"root\" is used.",
+			  " specified, \"root\" is used."),
 			  options);
 }
 

=== modified file 'lib/arg.c'
--- lib/arg.c	2009-12-24 22:53:05 +0000
+++ lib/arg.c	2009-12-25 11:41:40 +0000
@@ -22,6 +22,7 @@
 #include <grub/err.h>
 #include <grub/term.h>
 #include <grub/extcmd.h>
+#include <grub/i18n.h>
 
 /* Built-in parser for default options.  */
 #define SHORT_ARG_HELP	-100
@@ -30,9 +31,9 @@
 static const struct grub_arg_option help_options[] =
   {
     {"help", SHORT_ARG_HELP, 0,
-     "Display this help and exit.", 0, ARG_TYPE_NONE},
+     N_("Display this help and exit."), 0, ARG_TYPE_NONE},
     {"usage", SHORT_ARG_USAGE, 0,
-     "Display the usage of this command and exit.", 0, ARG_TYPE_NONE},
+     N_("Display the usage of this command and exit."), 0, ARG_TYPE_NONE},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -106,7 +107,7 @@ find_long (const struct grub_arg_option 
 static void
 show_usage (grub_extcmd_t cmd)
 {
-  grub_printf ("Usage: %s\n", cmd->cmd->summary);
+  grub_printf ("%s %s\n", _("Usage:"), _(cmd->cmd->summary));
 }
 
 void
@@ -143,7 +144,7 @@ grub_arg_show_help (grub_extcmd_t cmd)
 		}
 	    }
 
-	  const char *doc = opt->doc;
+	  const char *doc = _(opt->doc);
 	  for (;;)
 	    {
 	      while (spacing-- > 0)
@@ -176,7 +177,7 @@ grub_arg_show_help (grub_extcmd_t cmd)
     }
 
   show_usage (cmd);
-  grub_printf ("%s\n\n", cmd->cmd->description);
+  grub_printf ("%s\n\n", _(cmd->cmd->description));
   if (cmd->options)
     showargs (cmd->options);
   showargs (help_options);

=== modified file 'normal/dyncmd.c'
--- normal/dyncmd.c	2009-11-09 14:50:20 +0000
+++ normal/dyncmd.c	2009-12-25 11:28:02 +0000
@@ -23,6 +23,7 @@
 #include <grub/misc.h>
 #include <grub/command.h>
 #include <grub/normal.h>
+#include <grub/i18n.h>
 
 static grub_err_t
 grub_dyncmd_dispatcher (struct grub_command *cmd,
@@ -132,7 +133,7 @@ read_command_list (void)
 
 		  cmd = grub_register_command_prio (name,
 						    grub_dyncmd_dispatcher,
-						    0, "not loaded", prio);
+						    0, N_("not loaded"), prio);
 		  if (! cmd)
 		    {
 		      grub_free (name);

=== modified file 'po/POTFILES'
--- po/POTFILES	2009-12-21 22:06:04 +0000
+++ po/POTFILES	2009-12-25 11:28:02 +0000
@@ -1,5 +1,12 @@
 # List of files which contain translatable strings.
+commands/i386/pc/play.c
 commands/loadenv.c
+commands/search.c
+commands/help.c
+
+lib/arg.c
+
+normal/dyncmd.c
 
 util/i386/pc/grub-mkimage.c
 util/i386/pc/grub-setup.c


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: gettext: help commands
  2009-12-25 12:16 ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2009-12-25 12:29   ` Carles Pina i Estany
  2009-12-25 12:33     ` Vladimir 'φ-coder/phcoder' Serbinenko
  0 siblings, 1 reply; 6+ messages in thread
From: Carles Pina i Estany @ 2009-12-25 12:29 UTC (permalink / raw)
  To: The development of GNU GRUB

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


Hi,

On Dec/25/2009, Vladimir '??-coder/phcoder' Serbinenko wrote:

> >=== modified file 'commands/help.c'
> >--- commands/help.c	2009-06-10 21:04:23 +0000
> >+++ commands/help.c	2009-12-25 11:34:16 +0000
> > grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
> >@@ -48,7 +49,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
> > 		       (desclen < GRUB_TERM_WIDTH / 2 - 1
> > 			? desclen : GRUB_TERM_WIDTH / 2 - 1));
> > 
> >-	  grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " ");
> >+	  grub_printf ("%s%s", _(description), (cnt++) % 2 ? "\n" : " ");
> At this point description is already cut at half of terminal width.
> You have to first translate and then cut the message and not the other
> way round

See attached one.


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

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

=== modified file 'ChangeLog'
--- ChangeLog	2009-12-25 00:04:51 +0000
+++ ChangeLog	2009-12-25 11:45:00 +0000
@@ -1,5 +1,25 @@
 2009-12-25  Carles Pina i Estany  <carles@pina.cat>
 
+	* commands/help.c: Include `<grub/i18n.h>'.
+	(grub_cmd_help): Gettextizze.
+	(GRUB_MOD_INIT): Likewise.
+	* commands/i386/pc/play.c: Include `<grub/i18n.h>'.
+	(GRUB_MOD_INIT): Gettextizze.
+	* commands/search.c: Include `<grub/i18n.h>'.
+	(options): Gettextizze.
+	(GRUB_MOD_INIT): Gettextizze.
+	* lib/arg.c: Include `<grub/i18n.h>'.
+	(help_options): Gettextizze.
+	(find_long): Likewise.
+	(grub_arg_show_help): Likewise.
+	* normal/dyncmd.c: Include `<grub/i18n.h>'.
+	(read_command_list): Gettextizze.
+	* po/POTFILES: Add `commands/i386/pc/play.c', `commands/search.c',
+	`commands/help.c', `lib/arg.c' and `normal/dyncmd.c'. 
+
+
+2009-12-25  Carles Pina i Estany  <carles@pina.cat>
+
 	* commands/efi/loadbios.c: Capitalize acronyms, replace `could not' by
 	`couldn't' and `can not' by `cannot'.
 	* commands/i386/pc/drivemap.c: Likewise.

=== modified file 'commands/help.c'
--- commands/help.c	2009-06-10 21:04:23 +0000
+++ commands/help.c	2009-12-25 12:27:57 +0000
@@ -21,6 +21,7 @@
 #include <grub/misc.h>
 #include <grub/term.h>
 #include <grub/extcmd.h>
+#include <grub/i18n.h>
 
 static grub_err_t
 grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
@@ -44,7 +45,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	     with the description followed by spaces.  */
 	  grub_memset (description, ' ', GRUB_TERM_WIDTH / 2 - 1);
 	  description[GRUB_TERM_WIDTH / 2 - 1] = '\0';
-	  grub_memcpy (description, cmd->summary,
+	  grub_memcpy (description, _(cmd->summary),
 		       (desclen < GRUB_TERM_WIDTH / 2 - 1
 			? desclen : GRUB_TERM_WIDTH / 2 - 1));
 
@@ -65,8 +66,8 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	      if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
 		grub_arg_show_help ((grub_extcmd_t) cmd->data);
 	      else
-		grub_printf ("Usage: %s\n%s\b", cmd->summary,
-			     cmd->description);
+		grub_printf ("%s %s\n%s\b", _("Usage:"), _(cmd->summary),
+			     _(cmd->description));
 	    }
 	}
       return 0;
@@ -94,8 +95,8 @@ GRUB_MOD_INIT(help)
 {
   cmd = grub_register_extcmd ("help", grub_cmd_help,
 			      GRUB_COMMAND_FLAG_CMDLINE,
-			      "help [PATTERN ...]",
-			      "Show a help message.", 0);
+			      N_("help [PATTERN ...]"),
+			      N_("Show a help message."), 0);
 }
 
 GRUB_MOD_FINI(help)

=== modified file 'commands/i386/pc/play.c'
--- commands/i386/pc/play.c	2009-12-21 22:06:04 +0000
+++ commands/i386/pc/play.c	2009-12-25 11:28:02 +0000
@@ -27,6 +27,7 @@
 #include <grub/machine/time.h>
 #include <grub/cpu/io.h>
 #include <grub/command.h>
+#include <grub/i18n.h>
 
 #define BASE_TEMPO 120
 
@@ -207,7 +208,7 @@ static grub_command_t cmd;
 GRUB_MOD_INIT(play)
 {
   cmd = grub_register_command ("play", grub_cmd_play,
-			       "play FILE", "Play a tune.");
+			       N_("play FILE"), N_("Play a tune."));
 }
 
 GRUB_MOD_FINI(play)

=== modified file 'commands/search.c'
--- commands/search.c	2009-12-21 22:06:04 +0000
+++ commands/search.c	2009-12-25 11:28:02 +0000
@@ -26,14 +26,15 @@
 #include <grub/file.h>
 #include <grub/env.h>
 #include <grub/extcmd.h>
+#include <grub/i18n.h>
 
 static const struct grub_arg_option options[] =
   {
-    {"file",		'f', 0, "Search devices by a file.", 0, 0},
-    {"label",		'l', 0, "Search devices by a filesystem label.", 0, 0},
-    {"fs-uuid",		'u', 0, "Search devices by a filesystem UUID.", 0, 0},
-    {"set",		's', GRUB_ARG_OPTION_OPTIONAL, "Set a variable to the first device found.", "VAR", ARG_TYPE_STRING},
-    {"no-floppy",	'n', 0, "Do not probe any floppy drive.", 0, 0},
+    {"file",		'f', 0, N_("Search devices by a file."), 0, 0},
+    {"label",		'l', 0, N_("Search devices by a filesystem label."), 0, 0},
+    {"fs-uuid",		'u', 0, N_("Search devices by a filesystem UUID."), 0, 0},
+    {"set",		's', GRUB_ARG_OPTION_OPTIONAL, N_("Set a variable to the first device found."), "VAR", ARG_TYPE_STRING},
+    {"no-floppy",	'n', 0, N_("Do not probe any floppy drive."), 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -186,11 +187,11 @@ GRUB_MOD_INIT(search)
   cmd =
     grub_register_extcmd ("search", grub_cmd_search,
 			  GRUB_COMMAND_FLAG_BOTH,
-			  "search [-f|-l|-u|-s|-n] NAME",
-			  "Search devices by file, filesystem label or filesystem UUID."
+			  N_("search [-f|-l|-u|-s|-n] NAME"),
+			  N_("Search devices by file, filesystem label or filesystem UUID."
 			  " If --set is specified, the first device found is"
 			  " set to a variable. If no variable name is"
-			  " specified, \"root\" is used.",
+			  " specified, \"root\" is used."),
 			  options);
 }
 

=== modified file 'lib/arg.c'
--- lib/arg.c	2009-12-24 22:53:05 +0000
+++ lib/arg.c	2009-12-25 11:41:40 +0000
@@ -22,6 +22,7 @@
 #include <grub/err.h>
 #include <grub/term.h>
 #include <grub/extcmd.h>
+#include <grub/i18n.h>
 
 /* Built-in parser for default options.  */
 #define SHORT_ARG_HELP	-100
@@ -30,9 +31,9 @@
 static const struct grub_arg_option help_options[] =
   {
     {"help", SHORT_ARG_HELP, 0,
-     "Display this help and exit.", 0, ARG_TYPE_NONE},
+     N_("Display this help and exit."), 0, ARG_TYPE_NONE},
     {"usage", SHORT_ARG_USAGE, 0,
-     "Display the usage of this command and exit.", 0, ARG_TYPE_NONE},
+     N_("Display the usage of this command and exit."), 0, ARG_TYPE_NONE},
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -106,7 +107,7 @@ find_long (const struct grub_arg_option 
 static void
 show_usage (grub_extcmd_t cmd)
 {
-  grub_printf ("Usage: %s\n", cmd->cmd->summary);
+  grub_printf ("%s %s\n", _("Usage:"), _(cmd->cmd->summary));
 }
 
 void
@@ -143,7 +144,7 @@ grub_arg_show_help (grub_extcmd_t cmd)
 		}
 	    }
 
-	  const char *doc = opt->doc;
+	  const char *doc = _(opt->doc);
 	  for (;;)
 	    {
 	      while (spacing-- > 0)
@@ -176,7 +177,7 @@ grub_arg_show_help (grub_extcmd_t cmd)
     }
 
   show_usage (cmd);
-  grub_printf ("%s\n\n", cmd->cmd->description);
+  grub_printf ("%s\n\n", _(cmd->cmd->description));
   if (cmd->options)
     showargs (cmd->options);
   showargs (help_options);

=== modified file 'normal/dyncmd.c'
--- normal/dyncmd.c	2009-11-09 14:50:20 +0000
+++ normal/dyncmd.c	2009-12-25 11:28:02 +0000
@@ -23,6 +23,7 @@
 #include <grub/misc.h>
 #include <grub/command.h>
 #include <grub/normal.h>
+#include <grub/i18n.h>
 
 static grub_err_t
 grub_dyncmd_dispatcher (struct grub_command *cmd,
@@ -132,7 +133,7 @@ read_command_list (void)
 
 		  cmd = grub_register_command_prio (name,
 						    grub_dyncmd_dispatcher,
-						    0, "not loaded", prio);
+						    0, N_("not loaded"), prio);
 		  if (! cmd)
 		    {
 		      grub_free (name);

=== modified file 'po/POTFILES'
--- po/POTFILES	2009-12-21 22:06:04 +0000
+++ po/POTFILES	2009-12-25 11:28:02 +0000
@@ -1,5 +1,12 @@
 # List of files which contain translatable strings.
+commands/i386/pc/play.c
 commands/loadenv.c
+commands/search.c
+commands/help.c
+
+lib/arg.c
+
+normal/dyncmd.c
 
 util/i386/pc/grub-mkimage.c
 util/i386/pc/grub-setup.c


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: gettext: help commands
  2009-12-25 12:29   ` Carles Pina i Estany
@ 2009-12-25 12:33     ` Vladimir 'φ-coder/phcoder' Serbinenko
  2009-12-25 12:40       ` Carles Pina i Estany
  0 siblings, 1 reply; 6+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2009-12-25 12:33 UTC (permalink / raw)
  To: The development of GNU GRUB

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

Carles Pina i Estany wrote:
> Hi,
>
> On Dec/25/2009, Vladimir '??-coder/phcoder' Serbinenko wrote:
>
>   
>>> === modified file 'commands/help.c'
>>> --- commands/help.c	2009-06-10 21:04:23 +0000
>>> +++ commands/help.c	2009-12-25 11:34:16 +0000
>>> grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
>>> @@ -48,7 +49,7 @@ grub_cmd_help (grub_extcmd_t ext __attri
>>> 		       (desclen < GRUB_TERM_WIDTH / 2 - 1
>>> 			? desclen : GRUB_TERM_WIDTH / 2 - 1));
>>>
>>> -	  grub_printf ("%s%s", description, (cnt++) % 2 ? "\n" : " ");
>>> +	  grub_printf ("%s%s", _(description), (cnt++) % 2 ? "\n" : " ");
>>>       
>> At this point description is already cut at half of terminal width.
>> You have to first translate and then cut the message and not the other
>> way round
>>     
>
> See attached one.
>
>   
Now 'desclen' is out of sync with message
>   
> ------------------------------------------------------------------------
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/grub-devel


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: gettext: help commands
  2009-12-25 12:33     ` Vladimir 'φ-coder/phcoder' Serbinenko
@ 2009-12-25 12:40       ` Carles Pina i Estany
  0 siblings, 0 replies; 6+ messages in thread
From: Carles Pina i Estany @ 2009-12-25 12:40 UTC (permalink / raw)
  To: The development of GNU GRUB

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


Hi,

On Dec/25/2009, Vladimir '??-coder/phcoder' Serbinenko wrote:
 
> Now 'desclen' is out of sync with message

(arf, rushing for Christmas lunch :-) )

Now all cmd->summary and cmd->description in commands/help.c are
gettextizzed. I've reviewed lib/arg.c and was fine. 

Thanks Vladimir,

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

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

=== modified file 'commands/help.c'
--- commands/help.c	2009-06-10 21:04:23 +0000
+++ commands/help.c	2009-12-25 12:36:54 +0000
@@ -21,6 +21,7 @@
 #include <grub/misc.h>
 #include <grub/term.h>
 #include <grub/extcmd.h>
+#include <grub/i18n.h>
 
 static grub_err_t
 grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
@@ -38,13 +39,13 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	  (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE))
 	{
 	  char description[GRUB_TERM_WIDTH / 2];
-	  int desclen = grub_strlen (cmd->summary);
+	  int desclen = grub_strlen (_(cmd->summary));
 
 	  /* Make a string with a length of GRUB_TERM_WIDTH / 2 - 1 filled
 	     with the description followed by spaces.  */
 	  grub_memset (description, ' ', GRUB_TERM_WIDTH / 2 - 1);
 	  description[GRUB_TERM_WIDTH / 2 - 1] = '\0';
-	  grub_memcpy (description, cmd->summary,
+	  grub_memcpy (description, _(cmd->summary),
 		       (desclen < GRUB_TERM_WIDTH / 2 - 1
 			? desclen : GRUB_TERM_WIDTH / 2 - 1));
 
@@ -65,8 +66,8 @@ grub_cmd_help (grub_extcmd_t ext __attri
 	      if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
 		grub_arg_show_help ((grub_extcmd_t) cmd->data);
 	      else
-		grub_printf ("Usage: %s\n%s\b", cmd->summary,
-			     cmd->description);
+		grub_printf ("%s %s\n%s\b", _("Usage:"), _(cmd->summary),
+			     _(cmd->description));
 	    }
 	}
       return 0;
@@ -94,8 +95,8 @@ GRUB_MOD_INIT(help)
 {
   cmd = grub_register_extcmd ("help", grub_cmd_help,
 			      GRUB_COMMAND_FLAG_CMDLINE,
-			      "help [PATTERN ...]",
-			      "Show a help message.", 0);
+			      N_("help [PATTERN ...]"),
+			      N_("Show a help message."), 0);
 }
 
 GRUB_MOD_FINI(help)


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-12-25 12:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-25 11:50 gettext: help commands Carles Pina i Estany
2009-12-25 12:16 ` Vladimir 'φ-coder/phcoder' Serbinenko
2009-12-25 12:29   ` Carles Pina i Estany
2009-12-25 12:33     ` Vladimir 'φ-coder/phcoder' Serbinenko
2009-12-25 12:40       ` Carles Pina i Estany
2009-12-25 12:27 ` Carles Pina i Estany

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.