diff options
-rw-r--r-- | amiga/gui.c | 4 | ||||
-rw-r--r-- | amiga/theme.c | 2 | ||||
-rw-r--r-- | atari/gui.c | 4 | ||||
-rw-r--r-- | beos/gui.cpp | 8 | ||||
-rw-r--r-- | cocoa/NetsurfApp.m | 4 | ||||
-rw-r--r-- | desktop/netsurf.c | 4 | ||||
-rw-r--r-- | desktop/netsurf.h | 3 | ||||
-rw-r--r-- | framebuffer/gui.c | 7 | ||||
-rw-r--r-- | gtk/gui.c | 35 | ||||
-rw-r--r-- | monkey/main.c | 9 | ||||
-rw-r--r-- | riscos/gui.c | 7 | ||||
-rw-r--r-- | utils/messages.c | 8 | ||||
-rw-r--r-- | utils/messages.h | 19 | ||||
-rw-r--r-- | windows/main.c | 7 |
14 files changed, 90 insertions, 31 deletions
diff --git a/amiga/gui.c b/amiga/gui.c index f0132f37e..5c671e1e2 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -5499,7 +5499,9 @@ int main(int argc, char** argv) return RETURN_FAIL; } - ret = netsurf_init(messages, current_user_cache); + ret = messages_add_from_file(messages); + + ret = netsurf_init(current_user_cache); if (ret != NSERROR_OK) { ami_misc_fatal_error("NetSurf failed to initialise"); return RETURN_FAIL; diff --git a/amiga/theme.c b/amiga/theme.c index 4d6107ab4..0b77dc560 100644 --- a/amiga/theme.c +++ b/amiga/theme.c @@ -152,7 +152,7 @@ void ami_theme_init(void) if(lock) { UnLock(lock); - messages_load(themefile); + messages_add_from_file(themefile); } } diff --git a/atari/gui.c b/atari/gui.c index 23d31420d..265ae5ace 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -1169,9 +1169,11 @@ int main(int argc, char** argv) nsoption_read(options, NULL); nsoption_commandline(&argc, argv, NULL); + ret = messages_add_from_file(messages); + /* common initialisation */ LOG("Initialising core..."); - ret = netsurf_init(messages, store); + ret = netsurf_init(store); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); } diff --git a/beos/gui.cpp b/beos/gui.cpp index 36cc92248..5eabfa848 100644 --- a/beos/gui.cpp +++ b/beos/gui.cpp @@ -1035,7 +1035,9 @@ int main(int argc, char** argv) /* common initialisation */ BPath messages = get_messages_path(); - ret = netsurf_init(messages.Path(), NULL); + ret = messages_add_from_file(messages.Path()); + + ret = netsurf_init(NULL); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); } @@ -1096,7 +1098,9 @@ int gui_init_replicant(int argc, char** argv) /* common initialisation */ BPath messages = get_messages_path(); - ret = netsurf_init(messages.Path(), NULL); + ret = messages_add_from_file(messages.Path()); + + ret = netsurf_init(NULL); if (ret != NSERROR_OK) { // FIXME: must not die when in replicant! die("NetSurf failed to initialise"); diff --git a/cocoa/NetsurfApp.m b/cocoa/NetsurfApp.m index ac26c9cf4..d9c711ab9 100644 --- a/cocoa/NetsurfApp.m +++ b/cocoa/NetsurfApp.m @@ -248,8 +248,10 @@ int main( int argc, char **argv ) nsoption_read(options, NULL); nsoption_commandline(&argc, argv, NULL); + error = messages_add_from_file(messages); + /* common initialisation */ - error = netsurf_init(messages, NULL); + error = netsurf_init(NULL); if (error != NSERROR_OK) { die("NetSurf failed to initialise"); } diff --git a/desktop/netsurf.c b/desktop/netsurf.c index bf8ff86aa..0fd7b7bbd 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -122,7 +122,7 @@ static nserror netsurf_llcache_query_handler(const llcache_query *query, } /* exported interface documented in desktop/netsurf.h */ -nserror netsurf_init(const char *messages, const char *store_path) +nserror netsurf_init(const char *store_path) { nserror ret; struct hlcache_parameters hlcache_parameters = { @@ -151,8 +151,6 @@ nserror netsurf_init(const char *messages, const char *store_path) signal(SIGPIPE, SIG_IGN); #endif - messages_load(messages); - /* corestrings init */ ret = corestrings_init(); if (ret != NSERROR_OK) diff --git a/desktop/netsurf.h b/desktop/netsurf.h index 4f3721945..ee6e53a7f 100644 --- a/desktop/netsurf.h +++ b/desktop/netsurf.h @@ -40,11 +40,10 @@ nserror netsurf_register(struct netsurf_table *table); /** * Initialise netsurf core. * - * @param messages path to translation mesage file. * @param store_path path to persistant storage. * @return NSERROR_OK on success or error code on faliure. */ -nserror netsurf_init(const char *messages, const char *store_path); +nserror netsurf_init(const char *store_path); /** * Finalise NetSurf core diff --git a/framebuffer/gui.c b/framebuffer/gui.c index 1c60bee2f..dcf487325 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -2107,9 +2107,12 @@ main(int argc, char** argv) free(options); nsoption_commandline(&argc, argv, nsoptions); - /* common initialisation */ + /* message init */ messages = filepath_find(respaths, "Messages"); - ret = netsurf_init(messages, NULL); + ret = messages_add_from_file(messages); + + /* common initialisation */ + ret = netsurf_init(NULL); free(messages); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); @@ -508,7 +508,7 @@ void warn_user(const char *warning, const char *detail) static GtkWindow *nsgtk_warning_window; GtkLabel *WarningLabel; - LOG("%s %s", warning, detail ? detail : ""); + LOG("%s %s", warning, detail ? detail : ""); fflush(stdout); nsgtk_warning_window = GTK_WINDOW(gtk_builder_get_object(warning_builder, "wndWarning")); @@ -553,13 +553,13 @@ static void nsgtk_PDF_set_pass(GtkButton *w, gpointer data) if (op[0] == '\0') { gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(password_builder, "labelInfo")), - "Owner password must be at least 1 character long:"); + "Owner password must be at least 1 character long:"); free(op); free(up); } else if (!strcmp(op, up)) { gtk_label_set_text(GTK_LABEL(gtk_builder_get_object(password_builder, "labelInfo")), - "User and owner passwords must be different:"); + "User and owner passwords must be different:"); free(op); free(up); } else if (!strcmp(op, op1) && !strcmp(up, up1)) { @@ -1043,12 +1043,26 @@ static struct gui_browser_table nsgtk_browser_table = { .pdf_password = nsgtk_pdf_password, }; + +static nserror nsgtk_messages_init(char **respaths) +{ + char *messages; + nserror ret = NSERROR_NOT_FOUND; + + /* Obtain path to messages */ + messages = filepath_find(respaths, "Messages"); + if (messages != NULL) { + ret = messages_add_from_file(messages); + free(messages); + } + return ret; +} + /** * Main entry point from OS. */ int main(int argc, char** argv) { - char *messages; char *cache_home = NULL; nserror ret; struct netsurf_table nsgtk_table = { @@ -1110,8 +1124,14 @@ int main(int argc, char** argv) return 1; } - /* Obtain path to messages */ - messages = filepath_find(respaths, "Messages"); + /* Initialise translated messages */ + ret = nsgtk_messages_init(respaths); + if (ret != NSERROR_OK) { + fprintf(stderr, "Unable to load translated messages (%s)\n", + messages_get_errorcode(ret)); + LOG("Unable to load translated messages"); + /** \todo decide if message load faliure should be fatal */ + } /* Locate the correct user cache directory path */ ret = get_cache_home(&cache_home); @@ -1124,8 +1144,7 @@ int main(int argc, char** argv) } /* core initialisation */ - ret = netsurf_init(messages, cache_home); - free(messages); + ret = netsurf_init(cache_home); free(cache_home); if (ret != NSERROR_OK) { fprintf(stderr, "NetSurf core failed to initialise (%s)\n", diff --git a/monkey/main.c b/monkey/main.c index 81406bc27..2b1a3bc52 100644 --- a/monkey/main.c +++ b/monkey/main.c @@ -172,9 +172,14 @@ main(int argc, char **argv) free(options); nsoption_commandline(&argc, argv, nsoptions); - /* common initialisation */ messages = filepath_find(respaths, "Messages"); - ret = netsurf_init(messages, NULL); + ret = messages_add_from_file(messages); + if (ret != NSERROR_OK) { + LOG("Messages failed to load"); + } + + /* common initialisation */ + ret = netsurf_init(NULL); free(messages); if (ret != NSERROR_OK) { die("NetSurf failed to initialise"); diff --git a/riscos/gui.c b/riscos/gui.c index 3a47d088b..2dd94337c 100644 --- a/riscos/gui.c +++ b/riscos/gui.c @@ -2481,11 +2481,14 @@ int main(int argc, char** argv) die("Failed to locate Messages resource."); } + /* initialise messages */ + messages_add_from_file(path); + /* obtain cache path */ cachepath = get_cachepath(); /* common initialisation */ - ret = netsurf_init(path, cachepath); + ret = netsurf_init(cachepath); free(cachepath); if (ret != NSERROR_OK) { die("NetSurf failed to initialise core"); @@ -2496,7 +2499,7 @@ int main(int argc, char** argv) sprite_init(); /* Load some extra RISC OS specific Messages */ - messages_load("NetSurf:Resources.LangNames"); + messages_add_from_file("NetSurf:Resources.LangNames"); ret = gui_init(argc, argv); if (ret != NSERROR_OK) { diff --git a/utils/messages.c b/utils/messages.c index 78b9a79f0..91b41cbc8 100644 --- a/utils/messages.c +++ b/utils/messages.c @@ -142,7 +142,7 @@ messages_get_ctx(const char *key, struct hash_table *ctx) } /* exported interface documented in messages.h */ -nserror messages_load(const char *path) +nserror messages_add_from_file(const char *path) { nserror err; @@ -158,6 +158,12 @@ nserror messages_load(const char *path) } /* exported interface documented in messages.h */ +nserror messages_add_from_inline(const char *data) +{ + return NSERROR_OK; +} + +/* exported interface documented in messages.h */ char *messages_get_buff(const char *key, ...) { const char *msg_fmt; diff --git a/utils/messages.h b/utils/messages.h index c9946e6a9..4d04cd52b 100644 --- a/utils/messages.h +++ b/utils/messages.h @@ -38,13 +38,26 @@ /** * Read keys and values from messages file into the standard Messages hash. * - * The messages are merged with any previously loaded messages. Any keys which - * are present already are replaced with the new value. + * The messages are merged with any previously loaded messages. Any + * keys which are present already are replaced with the new value. The + * file may be gzip compressed. * * \param path pathname of messages file. * \return NSERROR_OK on success or error code on faliure. */ -nserror messages_load(const char *path); +nserror messages_add_from_file(const char *path); + +/** + * Read keys and values from inline message data into the standard Messages hash. + * + * The messages are merged with any previously loaded messages. Any + * keys which are present already are replaced with the new value. The + * data may be gzip compressed. + * + * \param data The inline message data. + * \return NSERROR_OK on success or error code on faliure. + */ +nserror messages_add_from_inline(const char *data); /** * Fast lookup of a message by key from the standard Messages hash. diff --git a/windows/main.c b/windows/main.c index 1997c85d1..b9ef44a3c 100644 --- a/windows/main.c +++ b/windows/main.c @@ -183,10 +183,13 @@ WinMain(HINSTANCE hInstance, HINSTANCE hLastInstance, LPSTR lpcli, int ncmd) nsoption_read(options_file_location, NULL); nsoption_commandline(&argc, argv, NULL); - /* common initialisation */ + /* message init */ messages = filepath_find(respaths, "messages"); - ret = netsurf_init(messages, NULL); + messages_add_from_file(messages); free(messages); + + /* common initialisation */ + ret = netsurf_init(NULL); if (ret != NSERROR_OK) { free(options_file_location); LOG("NetSurf failed to initialise"); |