Different changes following Robert's email 20091121230904.GA29740@thorin
This commit is contained in:
parent
ee99edc809
commit
0648f857ea
8 changed files with 107 additions and 113 deletions
|
@ -25,6 +25,7 @@
|
||||||
#include <grub/normal.h>
|
#include <grub/normal.h>
|
||||||
#include <grub/file.h>
|
#include <grub/file.h>
|
||||||
#include <grub/kernel.h>
|
#include <grub/kernel.h>
|
||||||
|
#include <grub/gzio.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
.mo file information from:
|
.mo file information from:
|
||||||
|
@ -32,7 +33,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static grub_file_t grub_mofile_open (const char *name);
|
|
||||||
static grub_file_t fd_mo;
|
static grub_file_t fd_mo;
|
||||||
|
|
||||||
static int grub_gettext_offsetoriginal;
|
static int grub_gettext_offsetoriginal;
|
||||||
|
@ -53,17 +53,17 @@ grub_gettext_get_info (int offset)
|
||||||
{
|
{
|
||||||
grub_uint32_t value;
|
grub_uint32_t value;
|
||||||
|
|
||||||
grub_file_seek (fd_mo, offset);
|
grub_file_pread (fd_mo, (char *) &value, 4, offset);
|
||||||
grub_file_read (fd_mo, (char*) &value, 4);
|
|
||||||
value = grub_cpu_to_le32 (value);
|
value = grub_cpu_to_le32 (value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
grub_gettext_getstring_from_offset (grub_uint32_t offset, grub_uint32_t length, char *translation)
|
grub_gettext_getstring_from_offset (grub_uint32_t offset,
|
||||||
|
grub_uint32_t length, char *translation)
|
||||||
{
|
{
|
||||||
grub_file_seek (fd_mo, offset);
|
grub_file_pread (fd_mo, translation, length, offset);
|
||||||
grub_file_read (fd_mo, translation, length);
|
|
||||||
translation[length] = '\0';
|
translation[length] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,12 +79,10 @@ grub_gettext_gettranslation_from_position (int position)
|
||||||
|
|
||||||
internal_position = offsettranslation + position * 8;
|
internal_position = offsettranslation + position * 8;
|
||||||
|
|
||||||
grub_file_seek (fd_mo, internal_position);
|
grub_file_pread (fd_mo, (char *) &length, 4, internal_position);
|
||||||
grub_file_read (fd_mo, (char*) &length, 4);
|
|
||||||
length = grub_cpu_to_le32 (length);
|
length = grub_cpu_to_le32 (length);
|
||||||
|
|
||||||
grub_file_seek (fd_mo, internal_position + 4),
|
grub_file_pread (fd_mo, (char *) &offset, 4, internal_position + 4);
|
||||||
grub_file_read (fd_mo, (char*) &offset, 4);
|
|
||||||
offset = grub_cpu_to_le32 (offset);
|
offset = grub_cpu_to_le32 (offset);
|
||||||
|
|
||||||
translation = grub_malloc (length + 1);
|
translation = grub_malloc (length + 1);
|
||||||
|
@ -104,12 +102,10 @@ grub_gettext_getstring_from_position (int position)
|
||||||
internal_position = grub_gettext_offsetoriginal + (position * 8);
|
internal_position = grub_gettext_offsetoriginal + (position * 8);
|
||||||
|
|
||||||
/* Get the length of the string i. */
|
/* Get the length of the string i. */
|
||||||
grub_file_seek (fd_mo, internal_position);
|
grub_file_pread (fd_mo, (char *) &length, 4, internal_position);
|
||||||
grub_file_read (fd_mo, (char *) &length, 4);
|
|
||||||
|
|
||||||
/* Get the offset of the string i. */
|
/* Get the offset of the string i. */
|
||||||
grub_file_seek (fd_mo, internal_position + 4);
|
grub_file_pread (fd_mo, (char *) &offset, 4, internal_position + 4);
|
||||||
grub_file_read (fd_mo, (char *) &offset, 4);
|
|
||||||
|
|
||||||
/* Get the string i. */
|
/* Get the string i. */
|
||||||
original = grub_malloc (length + 1);
|
original = grub_malloc (length + 1);
|
||||||
|
@ -168,22 +164,28 @@ grub_mofile_open (const char *filename)
|
||||||
{
|
{
|
||||||
int unsigned magic;
|
int unsigned magic;
|
||||||
int version;
|
int version;
|
||||||
|
grub_file_t new_fd;
|
||||||
|
|
||||||
/* Using fd_mo and not another variable because
|
/* Using fd_mo and not another variable because
|
||||||
it's needed for grub_gettext_get_info. */
|
it's needed for grub_gettext_get_info. */
|
||||||
|
|
||||||
fd_mo = grub_file_open (filename);
|
new_fd = grub_gzfile_open (filename, 1);
|
||||||
if (! fd_mo)
|
grub_errno = GRUB_ERR_NONE;
|
||||||
|
|
||||||
|
if (!new_fd)
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_FILE_READ_ERROR, "Cannot read %s",filename);
|
grub_dprintf ("gettext: Cannot read %s", filename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fd_mo = new_fd;
|
||||||
|
|
||||||
magic = grub_gettext_get_info (GETTEXT_MAGIC_NUMBER);
|
magic = grub_gettext_get_info (GETTEXT_MAGIC_NUMBER);
|
||||||
|
|
||||||
if (magic != MO_MAGIC_NUMBER)
|
if (magic != MO_MAGIC_NUMBER)
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_FILE_TYPE, "mo: invalid mo file: %s", filename);
|
grub_error (GRUB_ERR_BAD_FILE_TYPE, "mo: invalid mo file: %s",
|
||||||
|
filename);
|
||||||
grub_file_close (fd_mo);
|
grub_file_close (fd_mo);
|
||||||
fd_mo = 0;
|
fd_mo = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -193,22 +195,12 @@ grub_mofile_open (const char *filename)
|
||||||
|
|
||||||
if (version != 0)
|
if (version != 0)
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_FILE_TYPE, "mo: invalid mo version in file: %s", filename);
|
grub_error (GRUB_ERR_BAD_FILE_TYPE,
|
||||||
|
"mo: invalid mo version in file: %s", filename);
|
||||||
fd_mo = 0;
|
fd_mo = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Do we want .mo.gz files? Then, the code:
|
|
||||||
file = grub_gzio_open (io, 0); // 0: transparent
|
|
||||||
if (! file)
|
|
||||||
{
|
|
||||||
grub_printf("Problems opening the file\n");
|
|
||||||
grub_file_close (io);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return fd_mo;
|
return fd_mo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,26 +211,38 @@ grub_gettext_init_ext (const char *lang)
|
||||||
char *locale_dir;
|
char *locale_dir;
|
||||||
|
|
||||||
locale_dir = grub_env_get ("locale_dir");
|
locale_dir = grub_env_get ("locale_dir");
|
||||||
|
if (locale_dir == NULL)
|
||||||
|
{
|
||||||
|
grub_printf ("locale_dir variable is not setted up.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fd_mo = 0;
|
fd_mo = NULL;
|
||||||
|
|
||||||
/* mo_file e.g.: /boot/grub/locale/ca.mo */
|
/* mo_file e.g.: /boot/grub/locale/ca.mo */
|
||||||
|
|
||||||
mo_file = grub_malloc (grub_strlen (locale_dir) + sizeof ("/") + grub_strlen (lang) + sizeof(".mo"));
|
mo_file =
|
||||||
|
grub_malloc (grub_strlen (locale_dir) + grub_strlen ("/") +
|
||||||
|
grub_strlen (lang) + grub_strlen (".mo") + 1);
|
||||||
|
|
||||||
/* Warning: if changing some paths in the below line, change the grub_malloc
|
/* Warning: if changing some paths in the below line, change the grub_malloc
|
||||||
contents below. */
|
contents below. */
|
||||||
|
|
||||||
grub_sprintf (mo_file, "%s/%s.mo", locale_dir, lang);
|
grub_sprintf (mo_file, "%s/%s.mo", locale_dir, lang);
|
||||||
|
|
||||||
grub_dprintf("gettext", "Will try to open file: %s " ,mo_file);
|
|
||||||
|
|
||||||
fd_mo = grub_mofile_open (mo_file);
|
fd_mo = grub_mofile_open (mo_file);
|
||||||
grub_free (mo_file);
|
|
||||||
|
/* Will try adding .gz as well. */
|
||||||
|
if (fd_mo == NULL)
|
||||||
|
{
|
||||||
|
grub_sprintf (mo_file, "%s.gz", mo_file);
|
||||||
|
fd_mo = grub_mofile_open (mo_file);
|
||||||
|
}
|
||||||
|
|
||||||
if (fd_mo)
|
if (fd_mo)
|
||||||
{
|
{
|
||||||
grub_gettext_offsetoriginal = grub_gettext_get_info(GETTEXT_OFFSET_ORIGINAL);
|
grub_gettext_offsetoriginal =
|
||||||
|
grub_gettext_get_info (GETTEXT_OFFSET_ORIGINAL);
|
||||||
grub_gettext_max = grub_gettext_get_info (GETTEXT_NUMBER_OF_STRINGS);
|
grub_gettext_max = grub_gettext_get_info (GETTEXT_NUMBER_OF_STRINGS);
|
||||||
|
|
||||||
grub_gettext_original = grub_gettext;
|
grub_gettext_original = grub_gettext;
|
||||||
|
@ -247,8 +251,8 @@ grub_gettext_init_ext (const char *lang)
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
grub_gettext_env_write_lang (struct grub_env_var *var __attribute__ ((unused)),
|
grub_gettext_env_write_lang (struct grub_env_var *var
|
||||||
const char *val)
|
__attribute__ ((unused)), const char *val)
|
||||||
{
|
{
|
||||||
grub_gettext_init_ext (val);
|
grub_gettext_init_ext (val);
|
||||||
|
|
||||||
|
@ -265,11 +269,6 @@ GRUB_MOD_INIT(gettext)
|
||||||
|
|
||||||
grub_gettext_init_ext (lang);
|
grub_gettext_init_ext (lang);
|
||||||
|
|
||||||
/* Testing:
|
|
||||||
grub_register_command ("_", grub_cmd_translate, GRUB_COMMAND_FLAG_BOTH,
|
|
||||||
"_", "internalization support trans", 0);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Reload .mo file information if lang changes. */
|
/* Reload .mo file information if lang changes. */
|
||||||
grub_register_variable_hook ("lang", NULL, grub_gettext_env_write_lang);
|
grub_register_variable_hook ("lang", NULL, grub_gettext_env_write_lang);
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,8 @@ grub_file_t EXPORT_FUNC(grub_file_open) (const char *name);
|
||||||
grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, void *buf,
|
grub_ssize_t EXPORT_FUNC(grub_file_read) (grub_file_t file, void *buf,
|
||||||
grub_size_t len);
|
grub_size_t len);
|
||||||
grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset);
|
grub_off_t EXPORT_FUNC(grub_file_seek) (grub_file_t file, grub_off_t offset);
|
||||||
|
grub_ssize_t EXPORT_FUNC(grub_file_pread) (grub_file_t file, void *buf, grub_size_t len, grub_off_t offset);
|
||||||
|
|
||||||
grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file);
|
grub_err_t EXPORT_FUNC(grub_file_close) (grub_file_t file);
|
||||||
|
|
||||||
static inline grub_off_t
|
static inline grub_off_t
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
# include <libintl.h>
|
# include <libintl.h>
|
||||||
# define _(str) gettext(str)
|
# define _(str) gettext(str)
|
||||||
#else
|
#else
|
||||||
# define _(str) str
|
# define _(str) grub_gettext(str)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* GRUB_I18N_H */
|
#endif /* GRUB_I18N_H */
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*
|
|
||||||
* GRUB -- GRand Unified Bootloader
|
|
||||||
* Copyright (C) 2009 Free Software Foundation, Inc.
|
|
||||||
*
|
|
||||||
* GRUB is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* GRUB is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GRUB_I18N_GRUB_H
|
|
||||||
#define GRUB_I18N_GRUB_H 1
|
|
||||||
|
|
||||||
# define _(str) grub_gettext(str)
|
|
||||||
|
|
||||||
#endif /* GRUB_I18N_GRUB_H */
|
|
10
kern/file.c
10
kern/file.c
|
@ -164,3 +164,13 @@ grub_file_seek (grub_file_t file, grub_off_t offset)
|
||||||
file->offset = offset;
|
file->offset = offset;
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
grub_ssize_t
|
||||||
|
grub_file_pread (grub_file_t file, void *buf, grub_size_t len, grub_off_t offset)
|
||||||
|
{
|
||||||
|
if (grub_file_seek (file, offset) == (grub_off_t)-1)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return grub_file_read (file, buf, len);
|
||||||
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <grub/time.h>
|
#include <grub/time.h>
|
||||||
#include <grub/env.h>
|
#include <grub/env.h>
|
||||||
#include <grub/menu_viewer.h>
|
#include <grub/menu_viewer.h>
|
||||||
#include <grub/i18n_grub.h>
|
#include <grub/i18n.h>
|
||||||
|
|
||||||
/* Time to delay after displaying an error message about a default/fallback
|
/* Time to delay after displaying an error message about a default/fallback
|
||||||
entry failing to boot. */
|
entry failing to boot. */
|
||||||
|
@ -267,7 +267,7 @@ print_timeout (int timeout, int offset, int second_stage)
|
||||||
{
|
{
|
||||||
/* NOTE: Do not remove the trailing space characters.
|
/* NOTE: Do not remove the trailing space characters.
|
||||||
They are required to clear the line. */
|
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. ");
|
||||||
char *msg_end = grub_strchr (msg, '%');
|
char *msg_end = grub_strchr (msg, '%');
|
||||||
|
|
||||||
grub_gotoxy (second_stage ? (msg_end - msg) : 0, GRUB_TERM_HEIGHT - 3);
|
grub_gotoxy (second_stage ? (msg_end - msg) : 0, GRUB_TERM_HEIGHT - 3);
|
||||||
|
|
7
po/ca.po
7
po/ca.po
|
@ -6,7 +6,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: GNU GRUB\n"
|
"Project-Id-Version: GNU GRUB\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2009-11-19 21:37+0000\n"
|
"POT-Creation-Date: 2009-11-22 11:45+0000\n"
|
||||||
"PO-Revision-Date: 2009-11-17 12:26+0100\n"
|
"PO-Revision-Date: 2009-11-17 12:26+0100\n"
|
||||||
"Last-Translator: Robert Millan <rmh.grub@aybabtu.com>\n"
|
"Last-Translator: Robert Millan <rmh.grub@aybabtu.com>\n"
|
||||||
"Language-Team: None <no-team-yet@li.org>\n"
|
"Language-Team: None <no-team-yet@li.org>\n"
|
||||||
|
@ -891,6 +891,11 @@ msgstr ""
|
||||||
"\n"
|
"\n"
|
||||||
" Utilitzeu les tecles %C i %C per a seleccionar l'entrada.\n"
|
" Utilitzeu les tecles %C i %C per a seleccionar l'entrada.\n"
|
||||||
|
|
||||||
|
#: normal/menu_text.c:270
|
||||||
|
#, c-format
|
||||||
|
msgid " The highlighted entry will be booted automatically in %ds. "
|
||||||
|
msgstr " L entrada seleccionada sera arrancada automaticament en %ds. "
|
||||||
|
|
||||||
#: util/grub.d/10_kfreebsd.in:40
|
#: util/grub.d/10_kfreebsd.in:40
|
||||||
msgid "%s, with kFreeBSD %s"
|
msgid "%s, with kFreeBSD %s"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -103,11 +103,13 @@ EOF
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Gettext variables and module
|
# Gettext variables and module
|
||||||
|
if [ "x${LANG}" != "xC" ] ; then
|
||||||
cat << EOF
|
cat << EOF
|
||||||
set locale_dir=${locale_dir}
|
set locale_dir=${locale_dir}
|
||||||
set lang=${grub_lang}
|
set lang=${grub_lang}
|
||||||
insmod gettext
|
insmod gettext
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
|
if [ "x${GRUB_HIDDEN_TIMEOUT}" != "x" ] ; then
|
||||||
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
|
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue