Change lang_init() to take a source, destination, and count. Needed for translatable plugins. Minor stylist changes as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23221 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
95e596c340
commit
9fbf346368
3 changed files with 19 additions and 20 deletions
|
@ -43,23 +43,15 @@
|
|||
#define HEADER_SIZE 4
|
||||
|
||||
static unsigned char language_buffer[MAX_LANGUAGE_SIZE];
|
||||
|
||||
void lang_init(void)
|
||||
{
|
||||
int i;
|
||||
unsigned char *ptr = (unsigned char *) language_builtin;
|
||||
|
||||
for (i = 0; i < LANG_LAST_INDEX_IN_ARRAY; i++) {
|
||||
language_strings[i] = ptr;
|
||||
ptr += strlen((char *)ptr) + 1; /* advance pointer to next string */
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned char lang_options = 0;
|
||||
|
||||
int lang_is_rtl(void)
|
||||
void lang_init(const unsigned char *builtin, unsigned char **dest, int count)
|
||||
{
|
||||
return (lang_options & LANGUAGE_FLAG_RTL) != 0;
|
||||
while(count--) {
|
||||
*dest++ = (unsigned char *)builtin;
|
||||
/* advance pointer to next string */
|
||||
builtin += strlen((char *)builtin) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
int lang_load(const char *filename)
|
||||
|
@ -79,7 +71,9 @@ int lang_load(const char *filename)
|
|||
read(fd, language_buffer, MAX_LANGUAGE_SIZE);
|
||||
unsigned char *ptr = language_buffer;
|
||||
int id;
|
||||
lang_init(); /* initialize with builtin */
|
||||
/* initialize with builtin */
|
||||
lang_init(language_builtin, language_strings,
|
||||
LANG_LAST_INDEX_IN_ARRAY);
|
||||
|
||||
while(fsize>3) {
|
||||
id = (ptr[0]<<8) | ptr[1]; /* get two-byte id */
|
||||
|
@ -113,7 +107,7 @@ int lang_load(const char *filename)
|
|||
return retcode;
|
||||
}
|
||||
|
||||
int lang_english_to_id(const char* english)
|
||||
int lang_english_to_id(const char *english)
|
||||
{
|
||||
int i;
|
||||
unsigned char *ptr = (unsigned char *) language_builtin;
|
||||
|
@ -125,3 +119,8 @@ int lang_english_to_id(const char* english)
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int lang_is_rtl(void)
|
||||
{
|
||||
return (lang_options & LANGUAGE_FLAG_RTL) != 0;
|
||||
}
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
****************************************************************************/
|
||||
|
||||
/* Initialize language array with the builtin strings */
|
||||
void lang_init(void);
|
||||
void lang_init(const unsigned char *builtin, unsigned char **dest, int count);
|
||||
|
||||
/* load a given language file */
|
||||
int lang_load(const char *filename);
|
||||
|
||||
/* get the ID of an english string so it can be localised */
|
||||
int lang_english_to_id(const char* english);
|
||||
int lang_english_to_id(const char *english);
|
||||
|
||||
/* returns whether the loaded language is a right-to-left language */
|
||||
int lang_is_rtl(void);
|
||||
|
|
|
@ -312,7 +312,7 @@ static void init(void)
|
|||
button_init();
|
||||
backlight_init();
|
||||
sim_tasks_init();
|
||||
lang_init();
|
||||
lang_init(language_builtin, language_strings, LANG_LAST_INDEX_IN_ARRAY);
|
||||
#ifdef DEBUG
|
||||
debug_init();
|
||||
#endif
|
||||
|
@ -403,7 +403,7 @@ static void init(void)
|
|||
font_init();
|
||||
|
||||
show_logo();
|
||||
lang_init();
|
||||
lang_init(language_builtin, language_strings, LANG_LAST_INDEX_IN_ARRAY);
|
||||
|
||||
#ifdef DEBUG
|
||||
debug_init();
|
||||
|
|
Loading…
Reference in a new issue