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> YYYY-MM-DD Carles Pina i Estany <carles@pina.cat>
* conf/common.rmk: Add grub-gettext_lib target, dependency and * conf/common.rmk: Add grub-gettext_lib target and updates
SOURCES, CFLAGS, LDFLAGS lib_DATA and CLEANFILES. Adds gettext.mod SOURCES, CFLAGS,
* gettext/gettext.c: New file with gettext implementation LDFLAGS.
* include/grub/i18n_grub.h: New file with grub_gettext macros * gettext/gettext.c: New file. (Reads mo files).
* include/grub/misc.h: Define macro _(char *s). Declare * include/grub/file.h (grub_file_pread): New prototype.
grub_gettext_dummy and grub_gettext * include/grub/i18n.h (_): New prototype.
* kern/misc.c: Define grub_gettext symbol implementation of the * include/grub/misc.h (grub_gettext_dummy, grub_gettext): New
grub_gettext_dummy function prototypes.
* normal/menu_text.c: Gettextize one message in print_message * kern/misc.c (grub_gettext_dummy): New function.
* po/POTFILES: Adds normal/menu_text.c * menu/menu_text.c: Include <grub/i18n.h>.
* po/ca.po: Adds the new string * menu/menu_text.c (print_timeout): Gettexttize string.
* util/grub.d/00_header.in: defines gettext variables and loads * menu/menu_text.c (print_message): Gettexttize string.
the module * 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 \ 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 \ ntfscomp.mod minix.mod hfs.mod jfs.mod iso9660.mod xfs.mod \
affs.mod sfs.mod hfsplus.mod reiserfs.mod cpio.mod tar.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. # For fshelp.mod.
fshelp_mod_SOURCES = fs/fshelp.c 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 #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 static grub_uint32_t
grub_gettext_get_info (int offset) grub_gettext_get_info (int offset)
{ {
grub_uint32_t value; 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); value = grub_cpu_to_le32 (value);
return value; return value;
@ -63,7 +74,7 @@ static void
grub_gettext_getstring_from_offset (grub_uint32_t offset, grub_gettext_getstring_from_offset (grub_uint32_t offset,
grub_uint32_t length, char *translation) 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'; translation[length] = '\0';
} }
@ -79,10 +90,10 @@ grub_gettext_gettranslation_from_position (int position)
internal_position = offsettranslation + position * 8; 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); 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); offset = grub_cpu_to_le32 (offset);
translation = grub_malloc (length + 1); translation = grub_malloc (length + 1);
@ -102,10 +113,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_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. */ /* 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. */ /* Get the string i. */
original = grub_malloc (length + 1); 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_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

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); grub_uint32_t d, grub_uint32_t *r);
const char *EXPORT_FUNC(grub_gettext_dummy) (const char *s); 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 #ifdef NEED_ENABLE_EXECUTE_STACK
void EXPORT_FUNC(__enable_execute_stack) (void *addr); 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; 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);
}