degesch: little step towards localisation

We don't use LC_MESSAGES, though, so it doesn't really matter as of now.

liberty currently isn't prepared for non-ASCII errors or filenames,
and just silently expects everything to be in the same all-compatible
encoding.  degesch further expects the encoding to be UTF-8.

All strings should ideally be converted to UTF-8 as soon as possible.
This commit is contained in:
Přemysl Eric Janouch 2015-12-25 21:22:59 +01:00
parent e101afab38
commit b7dd384048
1 changed files with 16 additions and 7 deletions

View File

@ -2548,6 +2548,7 @@ irc_to_term (struct app_context *ctx, const char *text)
// Format strings use a #-quoted notation, to differentiate from printf:
// #s inserts a string (expected to be in UTF-8)
// #d inserts a signed integer
// #l inserts a locale-encoded string
//
// #S inserts a string from the server with unknown encoding
// #m inserts a mIRC-formatted string (auto-resets at boundaries)
@ -2767,6 +2768,14 @@ restart:
case 's':
str_append (buf, (s = va_arg (*ap, char *)));
break;
case 'l':
if (!(tmp = iconv_xstrdup (self->ctx->term_to_utf8,
(s = va_arg (*ap, char *)), -1, NULL)))
print_error ("character conversion failed for: %s", "output");
else
str_append (buf, tmp);
free (tmp);
break;
case 'S':
tmp = irc_to_utf8 (self->ctx, (s = va_arg (*ap, char *)));
@ -3228,7 +3237,7 @@ buffer_open_log_file (struct app_context *ctx, struct buffer *buffer)
char *path = buffer_get_log_path (buffer);
if (!(buffer->log_file = fopen (path, "ab")))
log_global_error (ctx, "Couldn't open log file `#s': #s",
log_global_error (ctx, "Couldn't open log file `#s': #l",
path, strerror (errno));
else
set_cloexec (fileno (buffer->log_file));
@ -9664,7 +9673,7 @@ process_input (struct app_context *ctx, char *user_input)
{
char *input;
if (!(input = iconv_xstrdup (ctx->term_to_utf8, user_input, -1, NULL)))
print_error ("character conversion failed for `%s'", "user input");
print_error ("character conversion failed for: %s", "user input");
else
{
struct str_vector lines;
@ -10173,7 +10182,7 @@ launch_backlog_helper (struct app_context *ctx, FILE *backlog)
"Failed to launch backlog helper", strerror (errno));
_exit (EXIT_FAILURE);
case -1:
log_global_error (ctx, "#s: #s",
log_global_error (ctx, "#s: #l",
"Failed to launch backlog helper", strerror (errno));
break;
default:
@ -10187,7 +10196,7 @@ display_backlog (struct app_context *ctx)
FILE *backlog = tmpfile ();
if (!backlog)
{
log_global_error (ctx, "#s: #s",
log_global_error (ctx, "#s: #l",
"Failed to create a temporary file", strerror (errno));
return;
}
@ -10211,7 +10220,7 @@ display_full_log (struct app_context *ctx)
if (!full_log)
{
log_global_error (ctx, "Failed to open log file for #s: #s",
log_global_error (ctx, "Failed to open log file for #s: #l",
ctx->current_buffer->name, strerror (errno));
return;
}
@ -10280,7 +10289,7 @@ launch_input_editor (struct app_context *ctx)
"Failed to launch editor", strerror (errno));
_exit (EXIT_FAILURE);
case -1:
log_global_error (ctx, "#s: #s",
log_global_error (ctx, "#s: #l",
"Failed to launch editor", strerror (errno));
free (filename);
break;
@ -10310,7 +10319,7 @@ process_edited_input (struct app_context *ctx)
"could not re-insert the modified text");
if (unlink (ctx->editor_filename))
log_global_error (ctx, "Could not unlink `#s': #s",
log_global_error (ctx, "Could not unlink `#s': #l",
ctx->editor_filename, strerror (errno));
free (ctx->editor_filename);