diff --git a/apps/language.c b/apps/language.c index 2b9b6ff30b..847100e7da 100644 --- a/apps/language.c +++ b/apps/language.c @@ -25,9 +25,21 @@ extern int printf(const char *format, ...); #include "language.h" #include "lang.h" #include "debug.h" +#include "string.h" 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(ptr) + 1; /* advance pointer to next string */ + } +} + int lang_load(const char *filename) { int filesize; @@ -39,6 +51,7 @@ int lang_load(const char *filename) if(filesize != MAX_LANGUAGE_SIZE) { if((language_buffer[0] == LANGUAGE_COOKIE) && (language_buffer[1] == LANGUAGE_VERSION)) { + lang_init(); /* initialize with builtin */ unsigned char *ptr=&language_buffer[2]; int id; filesize-=2; diff --git a/apps/language.h b/apps/language.h index 62974459a5..80242962ea 100644 --- a/apps/language.h +++ b/apps/language.h @@ -24,5 +24,8 @@ #define LANGUAGE_COOKIE 0x1a #define LANGUAGE_VERSION 0x02 +/* Initialize language array with the builtin strings */ +void lang_init(void); + /* load a given language file */ int lang_load(const char *filename); diff --git a/apps/main.c b/apps/main.c index cc270ba136..ef8ca7bea7 100644 --- a/apps/main.c +++ b/apps/main.c @@ -126,6 +126,7 @@ void init(void) lcd_init(); font_init(); show_logo(); + lang_init(); settings_reset(); settings_calc_config_sector(); settings_load(SETTINGS_ALL); @@ -171,6 +172,7 @@ void init(void) font_init(); show_logo(); + lang_init(); set_irq_level(0); #ifdef DEBUG diff --git a/tools/genlang b/tools/genlang index e13cd3faf9..2677735d2e 100755 --- a/tools/genlang +++ b/tools/genlang @@ -30,8 +30,11 @@ print HFILE <) { } else { push @hfile, $set{'id'}; - print CFILE " $value,\n"; + $value =~ s/\"$/\\0\"/; + print CFILE " $value\n"; } undef %set; @@ -118,7 +125,7 @@ MOO ; print CFILE <