* gettextize normal/menu_text.c (print_timeout)
@ 2009-11-22 23:50 Carles Pina i Estany
2009-11-23 12:04 ` Robert Millan
0 siblings, 1 reply; 9+ messages in thread
From: Carles Pina i Estany @ 2009-11-22 23:50 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 389 bytes --]
Hello,
Attached a proposal of gettextize for normal/menu_text.c
------
2009-11-22 Carles Pina i Estany <carles@pina.cat>
* normal/menu_text.c (get_spaces): New function.
(print_timeout): Gettexttize and uses get_spaces.
------
If accepted I can combine with the previous patch gettextizing some
files in normal/*
Cheers,
--
Carles Pina i Estany
http://pinux.info
[-- Attachment #2: gettext_print_timeout.patch --]
[-- Type: text/x-diff, Size: 1231 bytes --]
=== modified file 'normal/menu_text.c'
--- normal/menu_text.c 2009-11-22 22:24:54 +0000
+++ normal/menu_text.c 2009-11-22 23:40:20 +0000
@@ -262,12 +262,34 @@
return entry;
}
+static char*
+get_spaces (int number_spaces)
+{
+ char* spaces = grub_malloc(number_spaces + 1);
+ int i;
+
+ spaces[0] = '\0';
+
+ for (i=0;i<number_spaces;i++)
+ {
+ grub_strcat(spaces, " ");
+ }
+ return spaces;
+}
+
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_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;
+
+ char *msg = grub_malloc (msg_localized_len + number_spaces + 1);
+ char *spaces = get_spaces (number_spaces);
+
+ grub_sprintf (msg,"%s%s", msg_localized, spaces);
+ grub_free (spaces);
+
char *msg_end = grub_strchr (msg, '%');
grub_gotoxy (second_stage ? (msg_end - msg) : 0, GRUB_TERM_HEIGHT - 3);
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gettextize normal/menu_text.c (print_timeout)
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
0 siblings, 1 reply; 9+ messages in thread
From: Robert Millan @ 2009-11-23 12:04 UTC (permalink / raw)
To: The development of GNU GRUB
On Sun, Nov 22, 2009 at 11:50:13PM +0000, Carles Pina i Estany wrote:
> === modified file 'normal/menu_text.c'
> --- normal/menu_text.c 2009-11-22 22:24:54 +0000
> +++ normal/menu_text.c 2009-11-22 23:40:20 +0000
> @@ -262,12 +262,34 @@
> return entry;
> }
>
> +static char*
> +get_spaces (int number_spaces)
> +{
> + char* spaces = grub_malloc(number_spaces + 1);
> + int i;
> +
> + spaces[0] = '\0';
> +
> + for (i=0;i<number_spaces;i++)
> + {
> + grub_strcat(spaces, " ");
> + }
> + return spaces;
> +}
> [...]
> + grub_sprintf (msg,"%s%s", msg_localized, spaces);
This could be made much simpler. For example:
void
print_spaces (int number_spaces)
{
int i;
for (i = 0; i < number_spaces; i++)
grub_putchar (' ');
}
> + 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...
--
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."
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gettextize normal/menu_text.c (print_timeout)
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
0 siblings, 1 reply; 9+ messages in thread
From: Carles Pina i Estany @ 2009-11-25 0:08 UTC (permalink / raw)
To: The development of GNU GRUB
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
Would be ok to apply? Any comments?
(Wed and Thu I will not have lot of time, but on Friday-weekend I hope
to push more strings)
--
Carles Pina i Estany
http://pinux.info
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gettextize normal/menu_text.c (print_timeout)
2009-11-25 0:08 ` Carles Pina i Estany
@ 2009-11-25 0:30 ` Carles Pina i Estany
2009-11-25 18:55 ` Robert Millan
0 siblings, 1 reply; 9+ messages in thread
From: Carles Pina i Estany @ 2009-11-25 0:30 UTC (permalink / raw)
To: The development of GNU GRUB
[-- 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 ();
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gettextize normal/menu_text.c (print_timeout)
2009-11-25 0:30 ` Carles Pina i Estany
@ 2009-11-25 18:55 ` Robert Millan
2009-11-25 22:09 ` Carles Pina i Estany
0 siblings, 1 reply; 9+ messages in thread
From: Robert Millan @ 2009-11-25 18:55 UTC (permalink / raw)
To: The development of GNU GRUB
On Wed, Nov 25, 2009 at 12:30:59AM +0000, Carles Pina i Estany wrote:
> 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 (" ");
> ).
Yes.
> - 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."));
These are still not right. We can't have newlines in the middle of a
translatable string.
--
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."
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gettextize normal/menu_text.c (print_timeout)
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
0 siblings, 1 reply; 9+ messages in thread
From: Carles Pina i Estany @ 2009-11-25 22:09 UTC (permalink / raw)
To: The development of GNU GRUB
Hi,
On Nov/25/2009, Robert Millan wrote:
> On Wed, Nov 25, 2009 at 12:30:59AM +0000, Carles Pina i Estany wrote:
> > 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 (" ");
> > ).
>
> Yes.
ok!
> > - 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."));
>
> These are still not right. We can't have newlines in the middle of a
> translatable string.
I disagree. We have to give to the translators the minimum unit of
"sense", and in this case it's three lines. We cannot force translators
to translate the same sentence line by line because:
a) they will not have enough context
b) they cannot rephrase enough
c) maybe in other language the first line would be longer and the second
shorter, and if we split they cannot fix (less flexibility for them).
Agree with me?
--
Carles Pina i Estany
http://pinux.info
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gettextize normal/menu_text.c (print_timeout)
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
0 siblings, 1 reply; 9+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2009-11-25 22:21 UTC (permalink / raw)
To: The development of GNU GRUB
[-- Attachment #1: Type: text/plain, Size: 1503 bytes --]
Carles Pina i Estany wrote:
> Hi,
>
> On Nov/25/2009, Robert Millan wrote:
>
>> On Wed, Nov 25, 2009 at 12:30:59AM +0000, Carles Pina i Estany wrote:
>>
>>> 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 (" ");
>>> ).
>>>
>> Yes.
>>
>
> ok!
>
>
>
>>> - 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."));
>>>
>> These are still not right. We can't have newlines in the middle of a
>> translatable string.
>>
>
> I disagree. We have to give to the translators the minimum unit of
> "sense", and in this case it's three lines. We cannot force translators
> to translate the same sentence line by line because:
>
> a) they will not have enough context
> b) they cannot rephrase enough
> c) maybe in other language the first line would be longer and the second
> shorter, and if we split they cannot fix (less flexibility for them).
>
> Agree with me?
>
>
The real problem is that these newlines are hardcoded into string
whereas they should be put on runtime since terminal width may vary (the
string as is is tailored for 80 columns terminal)
--
Regards
Vladimir 'φ-coder/phcoder' Serbinenko
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gettextize normal/menu_text.c (print_timeout)
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
0 siblings, 1 reply; 9+ messages in thread
From: Carles Pina i Estany @ 2009-11-25 22:54 UTC (permalink / raw)
To: The development of GNU GRUB
Hi,
On Nov/25/2009, Vladimir '??-coder/phcoder' Serbinenko wrote:
> Carles Pina i Estany wrote:
> > Hi,
> >
> > On Nov/25/2009, Robert Millan wrote:
> >
> >> On Wed, Nov 25, 2009 at 12:30:59AM +0000, Carles Pina i Estany wrote:
> >>
> >>> 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 (" ");
> >>> ).
> >>>
> >> Yes.
> >>
> >
> > ok!
> >
> >
> >
> >>> - 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."));
> >>>
> >> These are still not right. We can't have newlines in the middle of a
> >> translatable string.
> >>
> >
> > I disagree. We have to give to the translators the minimum unit of
> > "sense", and in this case it's three lines. We cannot force translators
> > to translate the same sentence line by line because:
> >
> > a) they will not have enough context
> > b) they cannot rephrase enough
> > c) maybe in other language the first line would be longer and the second
> > shorter, and if we split they cannot fix (less flexibility for them).
> >
> > Agree with me?
> >
> >
> The real problem is that these newlines are hardcoded into string
> whereas they should be put on runtime since terminal width may vary (the
> string as is is tailored for 80 columns terminal)
this makes more sense (I didn't had in mind that the terminal width can
vary). I will delete the new lines and make a function that splits the
string after WIDTH_TERMINAL without splitting words.
I thought that Robert wanted to have 3 strings to translate, one per
line, not one long dynamic string.
Thanks,
--
Carles Pina i Estany
http://pinux.info
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: gettextize normal/menu_text.c (print_timeout)
2009-11-25 22:54 ` Carles Pina i Estany
@ 2009-11-26 1:50 ` Robert Millan
0 siblings, 0 replies; 9+ messages in thread
From: Robert Millan @ 2009-11-26 1:50 UTC (permalink / raw)
To: The development of GNU GRUB
On Wed, Nov 25, 2009 at 10:54:22PM +0000, Carles Pina i Estany wrote:
>
> I thought that Robert wanted to have 3 strings to translate, one per
> line, not one long dynamic string.
Not at all! That would be even worse :-)
The problem is if we don't remove the newlines, we're putting a burden on
translators: they would have to check that their string fits well with our
terminal layout.
--
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."
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-11-26 1:50 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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.