This commit is the same than gettext08.patch (see mailing list)

This commit is contained in:
Carles Pina i Estany 2009-11-22 12:50:46 +00:00
parent 39eaee93f1
commit e5fb78c684
6 changed files with 35 additions and 33 deletions

View file

@ -1,15 +1,18 @@
YYYY-MM-DD Carles Pina i Estany <carles@pina.cat>
* conf/common.rmk: Add grub-gettext_lib target, dependency and
SOURCES, CFLAGS, LDFLAGS
* gettext/gettext.c: New file with gettext implementation
* include/grub/i18n_grub.h: New file with grub_gettext macros
* include/grub/misc.h: Define macro _(char *s). Declare
grub_gettext_dummy and grub_gettext
* kern/misc.c: Define grub_gettext symbol implementation of the
grub_gettext_dummy function
* normal/menu_text.c: Gettextize one message in print_message
* po/POTFILES: Adds normal/menu_text.c
* po/ca.po: Adds the new string
* util/grub.d/00_header.in: defines gettext variables and loads
the module
* conf/common.rmk: Add grub-gettext_lib target and updates
lib_DATA and CLEANFILES. Adds gettext.mod SOURCES, CFLAGS,
LDFLAGS.
* gettext/gettext.c: New file. (Reads mo files).
* include/grub/file.h (grub_file_pread): New prototype.
* include/grub/i18n.h (_): New prototype.
* include/grub/misc.h (grub_gettext_dummy, grub_gettext): New
prototypes.
* kern/misc.c (grub_gettext_dummy): New function.
* menu/menu_text.c: Include <grub/i18n.h>.
* menu/menu_text.c (print_timeout): Gettexttize string.
* menu/menu_text.c (print_message): Gettexttize string.
* po/POTFILES: Add `normal/menu_text.c'.
* po/ca.po: Add new translations.
* util/grub.d/00_header.in: Define locale_dir and lang. insmod
gettext module and defines locale_dir and lang in grub.cfg.

View file

@ -185,7 +185,7 @@ grub-mkconfig_DATA += util/grub.d/README
pkglib_MODULES += fshelp.mod fat.mod ufs1.mod ufs2.mod ext2.mod ntfs.mod \
ntfscomp.mod minix.mod hfs.mod jfs.mod iso9660.mod xfs.mod \
affs.mod sfs.mod hfsplus.mod reiserfs.mod cpio.mod tar.mod \
udf.mod afs.mod afs_be.mod befs.mod befs_be.mod
udf.mod afs.mod afs_be.mod befs.mod befs_be.mod
# For fshelp.mod.
fshelp_mod_SOURCES = fs/fshelp.c

View file

@ -48,12 +48,23 @@ static const char *(*grub_gettext_original) (const char *s);
#define MO_MAGIC_NUMBER 0x950412de
static grub_ssize_t
grub_gettext_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);
}
static grub_uint32_t
grub_gettext_get_info (int offset)
{
grub_uint32_t value;
grub_file_pread (fd_mo, (char *) &value, 4, offset);
grub_gettext_pread (fd_mo, (char *) &value, 4, offset);
value = grub_cpu_to_le32 (value);
return value;
@ -63,7 +74,7 @@ static void
grub_gettext_getstring_from_offset (grub_uint32_t offset,
grub_uint32_t length, char *translation)
{
grub_file_pread (fd_mo, translation, length, offset);
grub_gettext_pread (fd_mo, translation, length, offset);
translation[length] = '\0';
}
@ -79,10 +90,10 @@ grub_gettext_gettranslation_from_position (int position)
internal_position = offsettranslation + position * 8;
grub_file_pread (fd_mo, (char *) &length, 4, internal_position);
grub_gettext_pread (fd_mo, (char *) &length, 4, internal_position);
length = grub_cpu_to_le32 (length);
grub_file_pread (fd_mo, (char *) &offset, 4, internal_position + 4);
grub_gettext_pread (fd_mo, (char *) &offset, 4, internal_position + 4);
offset = grub_cpu_to_le32 (offset);
translation = grub_malloc (length + 1);
@ -102,10 +113,10 @@ grub_gettext_getstring_from_position (int position)
internal_position = grub_gettext_offsetoriginal + (position * 8);
/* Get the length of the string i. */
grub_file_pread (fd_mo, (char *) &length, 4, internal_position);
grub_gettext_pread (fd_mo, (char *) &length, 4, internal_position);
/* Get the offset of the string i. */
grub_file_pread (fd_mo, (char *) &offset, 4, internal_position + 4);
grub_gettext_pread (fd_mo, (char *) &offset, 4, internal_position + 4);
/* Get the string i. */
original = grub_malloc (length + 1);

View file

@ -55,8 +55,6 @@ 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_size_t len);
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);
static inline grub_off_t

View file

@ -192,7 +192,7 @@ grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
grub_uint32_t d, grub_uint32_t *r);
const char *EXPORT_FUNC(grub_gettext_dummy) (const char *s);
extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s);// = grub_gettext_dummy;
extern const char *(*EXPORT_VAR(grub_gettext)) (const char *s);
#ifdef NEED_ENABLE_EXECUTE_STACK
void EXPORT_FUNC(__enable_execute_stack) (void *addr);

View file

@ -164,13 +164,3 @@ grub_file_seek (grub_file_t file, grub_off_t offset)
file->offset = offset;
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);
}