summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-09-22 11:25:08 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-09-22 11:25:08 +0000
commitbb507a8b85aaa04a6f8861592c31ebad4ca30df8 (patch)
tree23e9dc5262fa5ef54e8005b71f0b4c2bd33eda6c /src
parentd246f862e89f088b914083e5e573e6194b9a0fd0 (diff)
downloadirssi-bb507a8b85aaa04a6f8861592c31ebad4ca30df8.zip
/SET translation now says if there were any errors
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1810 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/fe-common/core/module-formats.c2
-rw-r--r--src/fe-common/core/module-formats.h4
-rw-r--r--src/fe-common/core/translation.c36
3 files changed, 38 insertions, 4 deletions
diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c
index a65af6ef..8049df02 100644
--- a/src/fe-common/core/module-formats.c
+++ b/src/fe-common/core/module-formats.c
@@ -248,6 +248,8 @@ FORMAT_REC fecommon_core_formats[] = {
{ "set_item", "$0 = $1", 2, { 0, 0 } },
{ "set_unknown", "Unknown setting $0", 1, { 0 } },
{ "set_not_boolean", "Setting {hilight $0} isn't boolean, use /SET", 1, { 0 } },
+ { "translation_not_found", "Error opening translation table file $0: $1", 2, { 0, 0 } },
+ { "translation_file_error", "Error parsing translation table file $0", 1, { 0 } },
{ NULL, NULL, 0 }
};
diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h
index 6e93f70c..40ff4ef4 100644
--- a/src/fe-common/core/module-formats.h
+++ b/src/fe-common/core/module-formats.h
@@ -213,7 +213,9 @@ enum {
TXT_SET_TITLE,
TXT_SET_ITEM,
TXT_SET_UNKNOWN,
- TXT_SET_NOT_BOOLEAN
+ TXT_SET_NOT_BOOLEAN,
+ TXT_TRANSLATION_NOT_FOUND,
+ TXT_TRANSLATION_FILE_ERROR
};
extern FORMAT_REC fecommon_core_formats[];
diff --git a/src/fe-common/core/translation.c b/src/fe-common/core/translation.c
index 2713cc73..a4828117 100644
--- a/src/fe-common/core/translation.c
+++ b/src/fe-common/core/translation.c
@@ -19,12 +19,17 @@
*/
#include "module.h"
+#include "module-formats.h"
#include "signals.h"
#include "line-split.h"
#include "misc.h"
+#include "levels.h"
#include "settings.h"
+#include "printtext.h"
+
unsigned char translation_in[256], translation_out[256];
+static char *current_translation;
void translation_reset(void)
{
@@ -81,7 +86,12 @@ int translation_read(const char *file)
f = open(file, O_RDONLY);
g_free(path);
- if (f == -1) return FALSE;
+ if (f == -1) {
+ printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
+ TXT_TRANSLATION_NOT_FOUND, file,
+ g_strerror(errno));
+ return FALSE;
+ }
pos = 0; buffer = NULL;
while (pos < 512) {
@@ -95,20 +105,40 @@ int translation_read(const char *file)
line_split_free(buffer);
close(f);
- if (pos != 512)
+ if (pos != 512) {
translation_reset();
+ printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
+ TXT_TRANSLATION_FILE_ERROR, file);
+ }
return pos == 512;
}
static void read_settings(void)
{
- translation_read(settings_get_str("translation"));
+ const char *translation;
+
+ translation = settings_get_str("translation");
+ if (*translation == '\0') {
+ if (current_translation != NULL) {
+ g_free_and_null(current_translation);
+ translation_reset();
+ }
+ return;
+ }
+
+ if (current_translation != NULL &&
+ strcmp(translation, current_translation) != 0) {
+ g_free_not_null(current_translation);
+ current_translation = g_strdup(translation);
+ translation_read(translation);
+ }
}
void translation_init(void)
{
translation_reset();
+ current_translation = NULL;
settings_add_str("misc", "translation", "");
signal_add("setup changed", (SIGNAL_FUNC) read_settings);