/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2002 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
# include <locale.h>
#endif
+#if !defined(LC_MESSAGES) && defined(G_OS_WIN32)
+#include <libintl.h>
+#endif
+
#include "prefs_common.h"
#include "manual.h"
#include "utils.h"
-static gchar *sylpheeddoc_manuals[] =
-{
- "en",
- "es",
- "fr",
- "de",
-};
static gchar *get_language()
{
gchar *language;
gchar *c;
+#ifdef G_OS_WIN32
+ language = g_strdup(gtk_set_locale());
+#else
+ /* FIXME: Why not using gtk_set_locale here too? -wk */
language = g_strdup(setlocale(LC_MESSAGES, NULL));
+#endif
+ /* At least under W32 it is possible that gtk_set_locate
+ returns NULL. This is not documented but well, it happens
+ and g_strdup is happy with a NULL argument. We return a
+ standard language string in this case. */
+ if (!language)
+ return g_strdup("en");
if((c = strchr(language, ',')) != NULL)
*c = '\0';
if((c = strchr(language, '_')) != NULL)
gboolean manual_available(ManualType type)
{
gboolean ret = FALSE;
- gchar *dir = NULL;
+ gchar *dir = NULL, *uri = NULL;
switch (type) {
case MANUAL_MANUAL_LOCAL:
dir = get_local_path_with_locale(MANUALDIR);
if (dir != NULL) {
+ uri = g_strconcat(dir, G_DIR_SEPARATOR_S, MANUAL_HTML_INDEX, NULL);
g_free(dir);
- ret = TRUE;
- }
- break;
- case MANUAL_FAQ_LOCAL:
- dir = get_local_path_with_locale(FAQDIR);
- if (dir != NULL) {
- g_free(dir);
- ret = TRUE;
+ if (is_file_exist(uri))
+ ret = TRUE;
+ else
+ ret = FALSE;
+ g_free(uri);
}
break;
default:
return ret;
}
-static gchar *get_syldoc_language()
-{
- gchar *language;
- int i;
-
- language = get_language();
- for (i = 0; i < sizeof(sylpheeddoc_manuals) / sizeof(sylpheeddoc_manuals[0]); i++) {
- if (strcmp(language, sylpheeddoc_manuals[i]) == 0) {
- return language;
- }
- }
- g_free(language);
-
- return g_strdup("en");
-}
-
void manual_open(ManualType type)
{
gchar *uri = NULL;
gchar *dir;
- gchar *lang_str;
switch (type) {
case MANUAL_MANUAL_LOCAL:
g_free(dir);
}
break;
-
- case MANUAL_FAQ_LOCAL:
- dir = get_local_path_with_locale(FAQDIR);
- if (dir != NULL) {
- uri = g_strconcat("file://", dir, G_DIR_SEPARATOR_S, FAQ_HTML_INDEX, NULL);
- g_free(dir);
- }
- break;
-
- case MANUAL_MANUAL_SYLDOC:
- lang_str = get_syldoc_language();
- uri = g_strconcat(SYLDOC_URI, lang_str, SYLDOC_MANUAL_HTML_INDEX, NULL);
- g_free(lang_str);
- break;
-
- case MANUAL_FAQ_SYLDOC:
- lang_str = get_syldoc_language();
- uri = g_strconcat(SYLDOC_URI, lang_str, SYLDOC_FAQ_HTML_INDEX, NULL);
- g_free(lang_str);
- break;
-
case MANUAL_FAQ_CLAWS:
uri = g_strconcat(FAQ_URI, NULL);
break;