From f1d2bf84089b1e5b5988a5e5d6d571a507a52337 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 6 Aug 2008 18:54:13 +0200 Subject: add i18n support --- src/utils/pacat.c | 109 ++++++++++++++++----------------- src/utils/pacmd.c | 26 ++++---- src/utils/pactl.c | 152 ++++++++++++++++++++++++----------------------- src/utils/paplay.c | 43 +++++++------- src/utils/pasuspender.c | 44 +++++++------- src/utils/pax11publish.c | 35 ++++++----- 6 files changed, 214 insertions(+), 195 deletions(-) (limited to 'src/utils') diff --git a/src/utils/pacat.c b/src/utils/pacat.c index 78b9cef8..32fa6bcf 100644 --- a/src/utils/pacat.c +++ b/src/utils/pacat.c @@ -33,15 +33,13 @@ #include #include #include +#include +#include #include #define TIME_EVENT_USEC 50000 -#if PA_API_VERSION < 10 -#error Invalid PulseAudio API version -#endif - #define CLEAR_LINE "\x1B[K" static enum { RECORD, PLAYBACK } mode = PLAYBACK; @@ -92,7 +90,7 @@ static void do_stream_write(size_t length) { l = buffer_length; if (pa_stream_write(stream, (uint8_t*) buffer + buffer_index, l, NULL, 0, PA_SEEK_RELATIVE) < 0) { - fprintf(stderr, "pa_stream_write() failed: %s\n", pa_strerror(pa_context_errno(context))); + fprintf(stderr, _("pa_stream_write() failed: %s\n"), pa_strerror(pa_context_errno(context))); quit(1); return; } @@ -131,7 +129,7 @@ static void stream_read_callback(pa_stream *s, size_t length, void *userdata) { mainloop_api->io_enable(stdio_event, PA_IO_EVENT_OUTPUT); if (pa_stream_peek(s, &data, &length) < 0) { - fprintf(stderr, "pa_stream_peek() failed: %s\n", pa_strerror(pa_context_errno(context))); + fprintf(stderr, _("pa_stream_peek() failed: %s\n"), pa_strerror(pa_context_errno(context))); quit(1); return; } @@ -140,9 +138,9 @@ static void stream_read_callback(pa_stream *s, size_t length, void *userdata) { assert(length > 0); if (buffer) { - fprintf(stderr, "Buffer overrun, dropping incoming data\n"); + fprintf(stderr, _("Buffer overrun, dropping incoming data\n")); if (pa_stream_drop(s) < 0) { - fprintf(stderr, "pa_stream_drop() failed: %s\n", pa_strerror(pa_context_errno(context))); + fprintf(stderr, _("pa_stream_drop() failed: %s\n"), pa_strerror(pa_context_errno(context))); quit(1); } return; @@ -168,25 +166,25 @@ static void stream_state_callback(pa_stream *s, void *userdata) { const pa_buffer_attr *a; char cmt[PA_CHANNEL_MAP_SNPRINT_MAX], sst[PA_SAMPLE_SPEC_SNPRINT_MAX]; - fprintf(stderr, "Stream successfully created.\n"); + fprintf(stderr, _("Stream successfully created.\n")); if (!(a = pa_stream_get_buffer_attr(s))) - fprintf(stderr, "pa_stream_get_buffer_attr() failed: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s)))); + fprintf(stderr, _("pa_stream_get_buffer_attr() failed: %s\n"), pa_strerror(pa_context_errno(pa_stream_get_context(s)))); else { if (mode == PLAYBACK) - fprintf(stderr, "Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n", a->maxlength, a->tlength, a->prebuf, a->minreq); + fprintf(stderr, _("Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"), a->maxlength, a->tlength, a->prebuf, a->minreq); else { assert(mode == RECORD); - fprintf(stderr, "Buffer metrics: maxlength=%u, fragsize=%u\n", a->maxlength, a->fragsize); + fprintf(stderr, _("Buffer metrics: maxlength=%u, fragsize=%u\n"), a->maxlength, a->fragsize); } } - fprintf(stderr, "Using sample spec '%s', channel map '%s'.\n", + fprintf(stderr, _("Using sample spec '%s', channel map '%s'.\n"), pa_sample_spec_snprint(sst, sizeof(sst), pa_stream_get_sample_spec(s)), pa_channel_map_snprint(cmt, sizeof(cmt), pa_stream_get_channel_map(s))); - fprintf(stderr, "Connected to device %s (%u, %ssuspended).\n", + fprintf(stderr, _("Connected to device %s (%u, %ssuspended).\n"), pa_stream_get_device_name(s), pa_stream_get_device_index(s), pa_stream_is_suspended(s) ? "" : "not "); @@ -196,7 +194,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) { case PA_STREAM_FAILED: default: - fprintf(stderr, "Stream error: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s)))); + fprintf(stderr, _("Stream error: %s\n"), pa_strerror(pa_context_errno(pa_stream_get_context(s)))); quit(1); } } @@ -206,9 +204,9 @@ static void stream_suspended_callback(pa_stream *s, void *userdata) { if (verbose) { if (pa_stream_is_suspended(s)) - fprintf(stderr, "Stream device suspended." CLEAR_LINE " \n"); + fprintf(stderr, _("Stream device suspended.%s \n"), CLEAR_LINE); else - fprintf(stderr, "Stream device resumed." CLEAR_LINE " \n"); + fprintf(stderr, _("Stream device resumed.%s \n"), CLEAR_LINE); } } @@ -216,28 +214,28 @@ static void stream_underflow_callback(pa_stream *s, void *userdata) { assert(s); if (verbose) - fprintf(stderr, "Stream underrun." CLEAR_LINE " \n"); + fprintf(stderr, _("Stream underrun.%s \n"), CLEAR_LINE); } static void stream_overflow_callback(pa_stream *s, void *userdata) { assert(s); if (verbose) - fprintf(stderr, "Stream overrun." CLEAR_LINE " \n"); + fprintf(stderr, _("Stream overrun.%s \n"), CLEAR_LINE); } static void stream_started_callback(pa_stream *s, void *userdata) { assert(s); if (verbose) - fprintf(stderr, "Stream started." CLEAR_LINE " \n"); + fprintf(stderr, _("Stream started.%s \n"), CLEAR_LINE); } static void stream_moved_callback(pa_stream *s, void *userdata) { assert(s); if (verbose) - fprintf(stderr, "Stream moved to device %s (%u, %ssuspended)." CLEAR_LINE " \n", pa_stream_get_device_name(s), pa_stream_get_device_index(s), pa_stream_is_suspended(s) ? "" : "not "); + fprintf(stderr, _("Stream moved to device %s (%u, %ssuspended).%s \n"), pa_stream_get_device_name(s), pa_stream_get_device_index(s), pa_stream_is_suspended(s) ? "" : _("not "), CLEAR_LINE); } /* This is called whenever the context status changes */ @@ -258,10 +256,10 @@ static void context_state_callback(pa_context *c, void *userdata) { assert(!stream); if (verbose) - fprintf(stderr, "Connection established." CLEAR_LINE " \n"); + fprintf(stderr, _("Connection established.%s \n"), CLEAR_LINE); if (!(stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL))) { - fprintf(stderr, "pa_stream_new() failed: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("pa_stream_new() failed: %s\n"), pa_strerror(pa_context_errno(c))); goto fail; } @@ -286,13 +284,13 @@ static void context_state_callback(pa_context *c, void *userdata) { if (mode == PLAYBACK) { pa_cvolume cv; if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, pa_cvolume_set(&cv, sample_spec.channels, volume), NULL)) < 0) { - fprintf(stderr, "pa_stream_connect_playback() failed: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("pa_stream_connect_playback() failed: %s\n"), pa_strerror(pa_context_errno(c))); goto fail; } } else { if ((r = pa_stream_connect_record(stream, device, latency > 0 ? &buffer_attr : NULL, flags)) < 0) { - fprintf(stderr, "pa_stream_connect_record() failed: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("pa_stream_connect_record() failed: %s\n"), pa_strerror(pa_context_errno(c))); goto fail; } } @@ -306,7 +304,7 @@ static void context_state_callback(pa_context *c, void *userdata) { case PA_CONTEXT_FAILED: default: - fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Connection failure: %s\n"), pa_strerror(pa_context_errno(c))); goto fail; } @@ -327,12 +325,12 @@ static void stream_drain_complete(pa_stream*s, int success, void *userdata) { pa_operation *o; if (!success) { - fprintf(stderr, "Failed to drain stream: %s\n", pa_strerror(pa_context_errno(context))); + fprintf(stderr, _("Failed to drain stream: %s\n"), pa_strerror(pa_context_errno(context))); quit(1); } if (verbose) - fprintf(stderr, "Playback stream drained.\n"); + fprintf(stderr, _("Playback stream drained.\n")); pa_stream_disconnect(stream); pa_stream_unref(stream); @@ -342,7 +340,7 @@ static void stream_drain_complete(pa_stream*s, int success, void *userdata) { pa_context_disconnect(context); else { if (verbose) - fprintf(stderr, "Draining connection to server.\n"); + fprintf(stderr, _("Draining connection to server.\n")); } } @@ -368,13 +366,13 @@ static void stdin_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_even if ((r = read(fd, buffer, l)) <= 0) { if (r == 0) { if (verbose) - fprintf(stderr, "Got EOF.\n"); + fprintf(stderr, _("Got EOF.\n")); if (stream) { pa_operation *o; if (!(o = pa_stream_drain(stream, stream_drain_complete, NULL))) { - fprintf(stderr, "pa_stream_drain(): %s\n", pa_strerror(pa_context_errno(context))); + fprintf(stderr, _("pa_stream_drain(): %s\n"), pa_strerror(pa_context_errno(context))); quit(1); return; } @@ -384,7 +382,7 @@ static void stdin_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_even quit(0); } else { - fprintf(stderr, "read() failed: %s\n", strerror(errno)); + fprintf(stderr, _("read() failed: %s\n"), strerror(errno)); quit(1); } @@ -416,7 +414,7 @@ static void stdout_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_eve assert(buffer_length); if ((r = write(fd, (uint8_t*) buffer+buffer_index, buffer_length)) <= 0) { - fprintf(stderr, "write() failed: %s\n", strerror(errno)); + fprintf(stderr, _("write() failed: %s\n"), strerror(errno)); quit(1); mainloop_api->io_free(stdio_event); @@ -437,7 +435,7 @@ static void stdout_callback(pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_eve /* UNIX signal to quit recieved */ static void exit_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) { if (verbose) - fprintf(stderr, "Got signal, exiting.\n"); + fprintf(stderr, _("Got signal, exiting.\n")); quit(0); } @@ -451,12 +449,12 @@ static void stream_update_timing_callback(pa_stream *s, int success, void *userd if (!success || pa_stream_get_time(s, &usec) < 0 || pa_stream_get_latency(s, &l, &negative) < 0) { - fprintf(stderr, "Failed to get latency: %s\n", pa_strerror(pa_context_errno(context))); + fprintf(stderr, _("Failed to get latency: %s\n"), pa_strerror(pa_context_errno(context))); quit(1); return; } - fprintf(stderr, "Time: %0.3f sec; Latency: %0.0f usec. \r", + fprintf(stderr, _("Time: %0.3f sec; Latency: %0.0f usec. \r"), (float) usec / 1000000, (float) l * (negative?-1:1)); } @@ -476,7 +474,7 @@ static void time_event_callback(pa_mainloop_api*m, pa_time_event *e, const struc if (stream && pa_stream_get_state(stream) == PA_STREAM_READY) { pa_operation *o; if (!(o = pa_stream_update_timing_info(stream, stream_update_timing_callback, NULL))) - fprintf(stderr, "pa_stream_update_timing_info() failed: %s\n", pa_strerror(pa_context_errno(context))); + fprintf(stderr, _("pa_stream_update_timing_info() failed: %s\n"), pa_strerror(pa_context_errno(context))); else pa_operation_unref(o); } @@ -489,7 +487,7 @@ static void time_event_callback(pa_mainloop_api*m, pa_time_event *e, const struc static void help(const char *argv0) { - printf("%s [options]\n\n" + printf(_("%s [options]\n\n" " -h, --help Show this help\n" " --version Show version\n\n" " -r, --record Create a connection for recording\n" @@ -515,7 +513,7 @@ static void help(const char *argv0) { " --no-remix Don't upmix or downmix channels.\n" " --no-remap Map channels by index instead of name.\n" " --latency=BYTES Request the specified latency in bytes.\n" - " --process-time=BYTES Request the specified process time per request in bytes.\n" + " --process-time=BYTES Request the specified process time per request in bytes.\n") , argv0); } @@ -568,6 +566,9 @@ int main(int argc, char *argv[]) { {NULL, 0, NULL, 0} }; + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR); + if (!(bn = strrchr(argv[0], '/'))) bn = argv[0]; else @@ -587,7 +588,7 @@ int main(int argc, char *argv[]) { goto quit; case ARG_VERSION: - printf("pacat "PACKAGE_VERSION"\nCompiled with libpulse %s\nLinked with libpulse %s\n", pa_get_headers_version(), pa_get_library_version()); + printf(_("pacat %s\nCompiled with libpulse %s\nLinked with libpulse %s\n"), PACKAGE_VERSION, pa_get_headers_version(), pa_get_library_version()); ret = 0; goto quit; @@ -643,7 +644,7 @@ int main(int argc, char *argv[]) { case ARG_CHANNELMAP: if (!pa_channel_map_parse(&channel_map, optarg)) { - fprintf(stderr, "Invalid channel map '%s'\n", optarg); + fprintf(stderr, _("Invalid channel map '%s'\n"), optarg); goto quit; } @@ -672,14 +673,14 @@ int main(int argc, char *argv[]) { case ARG_LATENCY: if (((latency = atoi(optarg))) <= 0) { - fprintf(stderr, "Invalid latency specification '%s'\n", optarg); + fprintf(stderr, _("Invalid latency specification '%s'\n"), optarg); goto quit; } break; case ARG_PROCESS_TIME: if (((process_time = atoi(optarg))) <= 0) { - fprintf(stderr, "Invalid process time specification '%s'\n", optarg); + fprintf(stderr, _("Invalid process time specification '%s'\n"), optarg); goto quit; } break; @@ -690,19 +691,19 @@ int main(int argc, char *argv[]) { } if (!pa_sample_spec_valid(&sample_spec)) { - fprintf(stderr, "Invalid sample specification\n"); + fprintf(stderr, _("Invalid sample specification\n")); goto quit; } if (channel_map_set && channel_map.channels != sample_spec.channels) { - fprintf(stderr, "Channel map doesn't match sample specification\n"); + fprintf(stderr, _("Channel map doesn't match sample specification\n")); goto quit; } if (verbose) { char t[PA_SAMPLE_SPEC_SNPRINT_MAX]; pa_sample_spec_snprint(t, sizeof(t), &sample_spec); - fprintf(stderr, "Opening a %s stream with sample specification '%s'.\n", mode == RECORD ? "recording" : "playback", t); + fprintf(stderr, _("Opening a %s stream with sample specification '%s'.\n"), mode == RECORD ? _("recording") : _("playback"), t); } if (!(optind >= argc)) { @@ -710,12 +711,12 @@ int main(int argc, char *argv[]) { int fd; if ((fd = open(argv[optind], mode == PLAYBACK ? O_RDONLY : O_WRONLY|O_TRUNC|O_CREAT, 0666)) < 0) { - fprintf(stderr, "open(): %s\n", strerror(errno)); + fprintf(stderr, _("open(): %s\n"), strerror(errno)); goto quit; } if (dup2(fd, mode == PLAYBACK ? 0 : 1) < 0) { - fprintf(stderr, "dup2(): %s\n", strerror(errno)); + fprintf(stderr, _("dup2(): %s\n"), strerror(errno)); goto quit; } @@ -725,7 +726,7 @@ int main(int argc, char *argv[]) { stream_name = pa_xstrdup(argv[optind]); } else { - fprintf(stderr, "Too many arguments.\n"); + fprintf(stderr, _("Too many arguments.\n")); goto quit; } } @@ -738,7 +739,7 @@ int main(int argc, char *argv[]) { /* Set up a new main loop */ if (!(m = pa_mainloop_new())) { - fprintf(stderr, "pa_mainloop_new() failed.\n"); + fprintf(stderr, _("pa_mainloop_new() failed.\n")); goto quit; } @@ -759,13 +760,13 @@ int main(int argc, char *argv[]) { mode == PLAYBACK ? STDIN_FILENO : STDOUT_FILENO, mode == PLAYBACK ? PA_IO_EVENT_INPUT : PA_IO_EVENT_OUTPUT, mode == PLAYBACK ? stdin_callback : stdout_callback, NULL))) { - fprintf(stderr, "io_new() failed.\n"); + fprintf(stderr, _("io_new() failed.\n")); goto quit; } /* Create a new connection context */ if (!(context = pa_context_new(mainloop_api, client_name))) { - fprintf(stderr, "pa_context_new() failed.\n"); + fprintf(stderr, _("pa_context_new() failed.\n")); goto quit; } @@ -781,14 +782,14 @@ int main(int argc, char *argv[]) { pa_timeval_add(&tv, TIME_EVENT_USEC); if (!(time_event = mainloop_api->time_new(mainloop_api, &tv, time_event_callback, NULL))) { - fprintf(stderr, "time_new() failed.\n"); + fprintf(stderr, _("time_new() failed.\n")); goto quit; } } /* Run the main loop */ if (pa_mainloop_run(m, &ret) < 0) { - fprintf(stderr, "pa_mainloop_run() failed.\n"); + fprintf(stderr, _("pa_mainloop_run() failed.\n")); goto quit; } diff --git a/src/utils/pacmd.c b/src/utils/pacmd.c index 67d95252..24cddaa3 100644 --- a/src/utils/pacmd.c +++ b/src/utils/pacmd.c @@ -31,10 +31,12 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -50,13 +52,16 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { fd_set ifds, ofds; char *cli; + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR); + if (pa_pid_file_check_running(&pid, "pulseaudio") < 0) { - pa_log("no PulseAudio daemon running"); + pa_log("No PulseAudio daemon running"); goto fail; } if ((fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) { - pa_log("socket(PF_UNIX, SOCK_STREAM, 0): %s", strerror(errno)); + pa_log(_("socket(PF_UNIX, SOCK_STREAM, 0): %s"), strerror(errno)); goto fail; } @@ -73,7 +78,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { int r; if ((r = connect(fd, (struct sockaddr*) &sa, sizeof(sa))) < 0 && (errno != ECONNREFUSED && errno != ENOENT)) { - pa_log("connect(): %s", strerror(errno)); + pa_log(_("connect(): %s"), strerror(errno)); goto fail; } @@ -81,7 +86,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { break; if (pa_pid_file_kill(SIGUSR2, NULL, "pulseaudio") < 0) { - pa_log("failed to kill PulseAudio daemon."); + pa_log(_("Failed to kill PulseAudio daemon.")); goto fail; } @@ -89,7 +94,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { } if (i >= 5) { - pa_log("daemon not responding."); + pa_log(_("Daemon not responding.")); goto fail; } @@ -104,7 +109,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { for (;;) { if (select(FD_SETSIZE, &ifds, &ofds, NULL, NULL) < 0) { - pa_log("select(): %s", strerror(errno)); + pa_log(_("select(): %s"), strerror(errno)); goto fail; } @@ -116,7 +121,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { if (r == 0) break; - pa_log("read(): %s", strerror(errno)); + pa_log(_("read(): %s"), strerror(errno)); goto fail; } @@ -132,7 +137,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { if (r == 0) break; - pa_log("read(): %s", strerror(errno)); + pa_log(_("read(): %s"), strerror(errno)); goto fail; } @@ -145,7 +150,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { assert(obuf_length); if ((r = write(1, obuf + obuf_index, obuf_length)) < 0) { - pa_log("write(): %s", strerror(errno)); + pa_log(_("write(): %s"), strerror(errno)); goto fail; } @@ -159,7 +164,7 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { assert(ibuf_length); if ((r = write(fd, ibuf + ibuf_index, ibuf_length)) < 0) { - pa_log("write(): %s", strerror(errno)); + pa_log(_("write(): %s"), strerror(errno)); goto fail; } @@ -182,7 +187,6 @@ int main(PA_GCC_UNUSED int argc, PA_GCC_UNUSED char*argv[]) { FD_SET(fd, &ofds); } - ret = 0; fail: diff --git a/src/utils/pactl.c b/src/utils/pactl.c index 4cca2f86..f5961a1b 100644 --- a/src/utils/pactl.c +++ b/src/utils/pactl.c @@ -32,16 +32,14 @@ #include #include #include +#include #include +#include #include #include -#if PA_API_VERSION < 10 -#error Invalid PulseAudio API version -#endif - #define BUFSIZE 1024 static pa_context *context = NULL; @@ -106,19 +104,19 @@ static void complete_action(void) { static void stat_callback(pa_context *c, const pa_stat_info *i, void *userdata) { char s[128]; if (!i) { - fprintf(stderr, "Failed to get statistics: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failed to get statistics: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } pa_bytes_snprint(s, sizeof(s), i->memblock_total_size); - printf("Currently in use: %u blocks containing %s bytes total.\n", i->memblock_total, s); + printf(_("Currently in use: %u blocks containing %s bytes total.\n"), i->memblock_total, s); pa_bytes_snprint(s, sizeof(s), i->memblock_allocated_size); - printf("Allocated during whole lifetime: %u blocks containing %s bytes total.\n", i->memblock_allocated, s); + printf(_("Allocated during whole lifetime: %u blocks containing %s bytes total.\n"), i->memblock_allocated, s); pa_bytes_snprint(s, sizeof(s), i->scache_size); - printf("Sample cache size: %s\n", s); + printf(_("Sample cache size: %s\n"), s); complete_action(); } @@ -127,21 +125,21 @@ static void get_server_info_callback(pa_context *c, const pa_server_info *i, voi char s[PA_SAMPLE_SPEC_SNPRINT_MAX]; if (!i) { - fprintf(stderr, "Failed to get server information: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failed to get server information: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec); - printf("User name: %s\n" + printf(_("User name: %s\n" "Host Name: %s\n" "Server Name: %s\n" "Server Version: %s\n" "Default Sample Specification: %s\n" "Default Sink: %s\n" "Default Source: %s\n" - "Cookie: %08x\n", + "Cookie: %08x\n"), i->user_name, i->host_name, i->server_name, @@ -159,7 +157,7 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_ char *pl; if (is_last < 0) { - fprintf(stderr, "Failed to get sink information: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failed to get sink information: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -175,7 +173,7 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_ printf("\n"); nl = 1; - printf("*** Sink #%u ***\n" + printf(_("*** Sink #%u ***\n" "Name: %s\n" "Driver: %s\n" "Sample Specification: %s\n" @@ -185,14 +183,14 @@ static void get_sink_info_callback(pa_context *c, const pa_sink_info *i, int is_ "Monitor Source: %s\n" "Latency: %0.0f usec, configured %0.0f usec\n" "Flags: %s%s%s%s%s%s\n" - "Properties:\n%s", + "Properties:\n%s"), i->index, i->name, pa_strnull(i->driver), pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec), pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), i->owner_module, - i->mute ? "muted" : pa_cvolume_snprint(cv, sizeof(cv), &i->volume), + i->mute ? _("muted") : pa_cvolume_snprint(cv, sizeof(cv), &i->volume), pa_strnull(i->monitor_source_name), (double) i->latency, (double) i->configured_latency, i->flags & PA_SINK_HARDWARE ? "HARDWARE " : "", @@ -211,7 +209,7 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int char *pl; if (is_last < 0) { - fprintf(stderr, "Failed to get source information: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failed to get source information: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -227,7 +225,7 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int printf("\n"); nl = 1; - printf("*** Source #%u ***\n" + printf(_("*** Source #%u ***\n" "Name: %s\n" "Driver: %s\n" "Sample Specification: %s\n" @@ -237,7 +235,7 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int "Monitor of Sink: %s\n" "Latency: %0.0f usec, configured %0.0f usec\n" "Flags: %s%s%s%s%s%s\n" - "Properties:\n%s", + "Properties:\n%s"), i->index, i->name, pa_strnull(i->driver), @@ -245,7 +243,7 @@ static void get_source_info_callback(pa_context *c, const pa_source_info *i, int pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), i->owner_module, i->mute ? "muted" : pa_cvolume_snprint(cv, sizeof(cv), &i->volume), - i->monitor_of_sink_name ? i->monitor_of_sink_name : "n/a", + i->monitor_of_sink_name ? i->monitor_of_sink_name : _("n/a"), (double) i->latency, (double) i->configured_latency, i->flags & PA_SOURCE_HARDWARE ? "HARDWARE " : "", i->flags & PA_SOURCE_NETWORK ? "NETWORK " : "", @@ -262,7 +260,7 @@ static void get_module_info_callback(pa_context *c, const pa_module_info *i, int char t[32]; if (is_last < 0) { - fprintf(stderr, "Failed to get module information: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failed to get module information: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -280,15 +278,15 @@ static void get_module_info_callback(pa_context *c, const pa_module_info *i, int snprintf(t, sizeof(t), "%u", i->n_used); - printf("*** Module #%u ***\n" + printf(_("*** Module #%u ***\n" "Name: %s\n" "Argument: %s\n" "Usage counter: %s\n" - "Auto unload: %s\n", + "Auto unload: %s\n"), i->index, i->name, i->argument ? i->argument : "", - i->n_used != PA_INVALID_INDEX ? t : "n/a", + i->n_used != PA_INVALID_INDEX ? t : _("n/a"), pa_yes_no(i->auto_unload)); } @@ -297,7 +295,7 @@ static void get_client_info_callback(pa_context *c, const pa_client_info *i, int char *pl; if (is_last < 0) { - fprintf(stderr, "Failed to get client information: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failed to get client information: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -315,13 +313,13 @@ static void get_client_info_callback(pa_context *c, const pa_client_info *i, int snprintf(t, sizeof(t), "%u", i->owner_module); - printf("*** Client #%u ***\n" + printf(_("*** Client #%u ***\n" "Driver: %s\n" "Owner Module: %s\n" - "Properties:\n%s", + "Properties:\n%s"), i->index, pa_strnull(i->driver), - i->owner_module != PA_INVALID_INDEX ? t : "n/a", + i->owner_module != PA_INVALID_INDEX ? t : _("n/a"), pl = pa_proplist_to_string(i->proplist)); pa_xfree(pl); @@ -332,7 +330,7 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info char *pl; if (is_last < 0) { - fprintf(stderr, "Failed to get sink input information: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failed to get sink input information: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -351,7 +349,7 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info snprintf(t, sizeof(t), "%u", i->owner_module); snprintf(k, sizeof(k), "%u", i->client); - printf("*** Sink Input #%u ***\n" + printf(_("*** Sink Input #%u ***\n" "Driver: %s\n" "Owner Module: %s\n" "Client: %s\n" @@ -362,18 +360,18 @@ static void get_sink_input_info_callback(pa_context *c, const pa_sink_input_info "Buffer Latency: %0.0f usec\n" "Sink Latency: %0.0f usec\n" "Resample method: %s\n" - "Properties:\n%s", + "Properties:\n%s"), i->index, pa_strnull(i->driver), - i->owner_module != PA_INVALID_INDEX ? t : "n/a", - i->client != PA_INVALID_INDEX ? k : "n/a", + i->owner_module != PA_INVALID_INDEX ? t : _("n/a"), + i->client != PA_INVALID_INDEX ? k : _("n/a"), i->sink, pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec), pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), - i->mute ? "muted" : pa_cvolume_snprint(cv, sizeof(cv), &i->volume), + i->mute ? _("muted") : pa_cvolume_snprint(cv, sizeof(cv), &i->volume), (double) i->buffer_usec, (double) i->sink_usec, - i->resample_method ? i->resample_method : "n/a", + i->resample_method ? i->resample_method : _("n/a"), pl = pa_proplist_to_string(i->proplist)); pa_xfree(pl); @@ -384,7 +382,7 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu char *pl; if (is_last < 0) { - fprintf(stderr, "Failed to get source output information: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failed to get source output information: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -404,7 +402,7 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu snprintf(t, sizeof(t), "%u", i->owner_module); snprintf(k, sizeof(k), "%u", i->client); - printf("*** Source Output #%u ***\n" + printf(_("*** Source Output #%u ***\n" "Driver: %s\n" "Owner Module: %s\n" "Client: %s\n" @@ -414,17 +412,17 @@ static void get_source_output_info_callback(pa_context *c, const pa_source_outpu "Buffer Latency: %0.0f usec\n" "Source Latency: %0.0f usec\n" "Resample method: %s\n" - "Properties:\n%s", + "Properties:\n%s"), i->index, pa_strnull(i->driver), - i->owner_module != PA_INVALID_INDEX ? t : "n/a", - i->client != PA_INVALID_INDEX ? k : "n/a", + i->owner_module != PA_INVALID_INDEX ? t : _("n/a"), + i->client != PA_INVALID_INDEX ? k : _("n/a"), i->source, pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec), pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map), (double) i->buffer_usec, (double) i->source_usec, - i->resample_method ? i->resample_method : "n/a", + i->resample_method ? i->resample_method : _("n/a"), pl = pa_proplist_to_string(i->proplist)); pa_xfree(pl); @@ -435,7 +433,7 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int char *pl; if (is_last < 0) { - fprintf(stderr, "Failed to get sample information: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failed to get sample information: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -454,7 +452,7 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int pa_bytes_snprint(t, sizeof(t), i->bytes); - printf("*** Sample #%u ***\n" + printf(_("*** Sample #%u ***\n" "Name: %s\n" "Volume: %s\n" "Sample Specification: %s\n" @@ -463,16 +461,16 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int "Size: %s\n" "Lazy: %s\n" "Filename: %s\n" - "Properties:\n%s", + "Properties:\n%s"), i->index, i->name, pa_cvolume_snprint(cv, sizeof(cv), &i->volume), - pa_sample_spec_valid(&i->sample_spec) ? pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec) : "n/a", - pa_sample_spec_valid(&i->sample_spec) ? pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map) : "n/a", + pa_sample_spec_valid(&i->sample_spec) ? pa_sample_spec_snprint(s, sizeof(s), &i->sample_spec) : _("n/a"), + pa_sample_spec_valid(&i->sample_spec) ? pa_channel_map_snprint(cm, sizeof(cm), &i->channel_map) : _("n/a"), (double) i->duration/1000000, t, pa_yes_no(i->lazy), - i->filename ? i->filename : "n/a", + i->filename ? i->filename : _("n/a"), pl = pa_proplist_to_string(i->proplist)); pa_xfree(pl); @@ -480,7 +478,7 @@ static void get_sample_info_callback(pa_context *c, const pa_sample_info *i, int static void get_autoload_info_callback(pa_context *c, const pa_autoload_info *i, int is_last, void *userdata) { if (is_last < 0) { - fprintf(stderr, "Failed to get autoload information: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failed to get autoload information: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -496,21 +494,21 @@ static void get_autoload_info_callback(pa_context *c, const pa_autoload_info *i, printf("\n"); nl = 1; - printf("*** Autoload Entry #%u ***\n" + printf(_("*** Autoload Entry #%u ***\n" "Name: %s\n" "Type: %s\n" "Module: %s\n" - "Argument: %s\n", + "Argument: %s\n"), i->index, i->name, - i->type == PA_AUTOLOAD_SINK ? "sink" : "source", + i->type == PA_AUTOLOAD_SINK ? _("sink") : _("source"), i->module, i->argument ? i->argument : ""); } static void simple_callback(pa_context *c, int success, void *userdata) { if (!success) { - fprintf(stderr, "Failure: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failure: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -520,7 +518,7 @@ static void simple_callback(pa_context *c, int success, void *userdata) { static void index_callback(pa_context *c, uint32_t idx, void *userdata) { if (idx == PA_INVALID_INDEX) { - fprintf(stderr, "Failure: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failure: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -544,7 +542,7 @@ static void stream_state_callback(pa_stream *s, void *userdata) { case PA_STREAM_FAILED: default: - fprintf(stderr, "Failed to upload sample: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s)))); + fprintf(stderr, _("Failed to upload sample: %s\n"), pa_strerror(pa_context_errno(pa_stream_get_context(s)))); quit(1); } } @@ -561,7 +559,7 @@ static void stream_write_callback(pa_stream *s, size_t length, void *userdata) { if ((sf_readf_float(sndfile, d, l)) != l) { pa_xfree(d); - fprintf(stderr, "Premature end of file\n"); + fprintf(stderr, _("Premature end of file\n")); quit(1); } @@ -665,19 +663,19 @@ static void context_state_callback(pa_context *c, void *userdata) { case PA_CONTEXT_FAILED: default: - fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Connection failure: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); } } static void exit_signal_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) { - fprintf(stderr, "Got SIGINT, exiting.\n"); + fprintf(stderr, _("Got SIGINT, exiting.\n")); quit(0); } static void help(const char *argv0) { - printf("%s [options] stat\n" + printf(_("%s [options] stat\n" "%s [options] list\n" "%s [options] exit\n" "%s [options] upload-sample FILENAME [NAME]\n" @@ -692,7 +690,7 @@ static void help(const char *argv0) { " -h, --help Show this help\n" " --version Show version\n\n" " -s, --server=SERVER The name of the server to connect to\n" - " -n, --client-name=NAME How to call this client on the server\n", + " -n, --client-name=NAME How to call this client on the server\n"), argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0, argv0); } @@ -712,6 +710,9 @@ int main(int argc, char *argv[]) { {NULL, 0, NULL, 0} }; + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR); + if (!(bn = strrchr(argv[0], '/'))) bn = argv[0]; else @@ -725,7 +726,12 @@ int main(int argc, char *argv[]) { goto quit; case ARG_VERSION: - printf("pactl "PACKAGE_VERSION"\nCompiled with libpulse %s\nLinked with libpulse %s\n", pa_get_headers_version(), pa_get_library_version()); + printf(_("pactl %s\n" + "Compiled with libpulse %s\n" + "Linked with libpulse %s\n"), + PACKAGE_VERSION, + pa_get_headers_version(), + pa_get_library_version()); ret = 0; goto quit; @@ -759,7 +765,7 @@ int main(int argc, char *argv[]) { action = UPLOAD_SAMPLE; if (optind+1 >= argc) { - fprintf(stderr, "Please specify a sample file to load\n"); + fprintf(stderr, _("Please specify a sample file to load\n")); goto quit; } @@ -781,7 +787,7 @@ int main(int argc, char *argv[]) { memset(&sfinfo, 0, sizeof(sfinfo)); if (!(sndfile = sf_open(argv[optind+1], SFM_READ, &sfinfo))) { - fprintf(stderr, "Failed to open sound file.\n"); + fprintf(stderr, _("Failed to open sound file.\n")); goto quit; } @@ -793,7 +799,7 @@ int main(int argc, char *argv[]) { } else if (!strcmp(argv[optind], "play-sample")) { action = PLAY_SAMPLE; if (argc != optind+2 && argc != optind+3) { - fprintf(stderr, "You have to specify a sample name to play\n"); + fprintf(stderr, _("You have to specify a sample name to play\n")); goto quit; } @@ -805,7 +811,7 @@ int main(int argc, char *argv[]) { } else if (!strcmp(argv[optind], "remove-sample")) { action = REMOVE_SAMPLE; if (argc != optind+2) { - fprintf(stderr, "You have to specify a sample name to remove\n"); + fprintf(stderr, _("You have to specify a sample name to remove\n")); goto quit; } @@ -813,7 +819,7 @@ int main(int argc, char *argv[]) { } else if (!strcmp(argv[optind], "move-sink-input")) { action = MOVE_SINK_INPUT; if (argc != optind+3) { - fprintf(stderr, "You have to specify a sink input index and a sink\n"); + fprintf(stderr, _("You have to specify a sink input index and a sink\n")); goto quit; } @@ -822,7 +828,7 @@ int main(int argc, char *argv[]) { } else if (!strcmp(argv[optind], "move-source-output")) { action = MOVE_SOURCE_OUTPUT; if (argc != optind+3) { - fprintf(stderr, "You have to specify a source output index and a source\n"); + fprintf(stderr, _("You have to specify a source output index and a source\n")); goto quit; } @@ -836,7 +842,7 @@ int main(int argc, char *argv[]) { action = LOAD_MODULE; if (argc <= optind+1) { - fprintf(stderr, "You have to specify a module name and arguments.\n"); + fprintf(stderr, _("You have to specify a module name and arguments.\n")); goto quit; } @@ -856,7 +862,7 @@ int main(int argc, char *argv[]) { action = UNLOAD_MODULE; if (argc != optind+2) { - fprintf(stderr, "You have to specify a module index\n"); + fprintf(stderr, _("You have to specify a module index\n")); goto quit; } @@ -866,7 +872,7 @@ int main(int argc, char *argv[]) { action = SUSPEND_SINK; if (argc > optind+3 || optind+1 >= argc) { - fprintf(stderr, "You may not specify more than one sink. You have to specify at least one boolean value.\n"); + fprintf(stderr, _("You may not specify more than one sink. You have to specify at least one boolean value.\n")); goto quit; } @@ -879,7 +885,7 @@ int main(int argc, char *argv[]) { action = SUSPEND_SOURCE; if (argc > optind+3 || optind+1 >= argc) { - fprintf(stderr, "You may not specify more than one source. You have to specify at least one boolean value.\n"); + fprintf(stderr, _("You may not specify more than one source. You have to specify at least one boolean value.\n")); goto quit; } @@ -895,12 +901,12 @@ int main(int argc, char *argv[]) { } if (action == NONE) { - fprintf(stderr, "No valid command specified.\n"); + fprintf(stderr, _("No valid command specified.\n")); goto quit; } if (!(m = pa_mainloop_new())) { - fprintf(stderr, "pa_mainloop_new() failed.\n"); + fprintf(stderr, _("pa_mainloop_new() failed.\n")); goto quit; } @@ -914,7 +920,7 @@ int main(int argc, char *argv[]) { #endif if (!(context = pa_context_new(mainloop_api, client_name))) { - fprintf(stderr, "pa_context_new() failed.\n"); + fprintf(stderr, _("pa_context_new() failed.\n")); goto quit; } @@ -922,7 +928,7 @@ int main(int argc, char *argv[]) { pa_context_connect(context, server, 0, NULL); if (pa_mainloop_run(m, &ret) < 0) { - fprintf(stderr, "pa_mainloop_run() failed.\n"); + fprintf(stderr, _("pa_mainloop_run() failed.\n")); goto quit; } diff --git a/src/utils/paplay.c b/src/utils/paplay.c index 1b6228b1..9264a940 100644 --- a/src/utils/paplay.c +++ b/src/utils/paplay.c @@ -37,10 +37,7 @@ #include #include - -#if PA_API_VERSION < 9 -#error Invalid PulseAudio API version -#endif +#include static pa_context *context = NULL; static pa_stream *stream = NULL; @@ -75,12 +72,12 @@ static void stream_drain_complete(pa_stream*s, int success, void *userdata) { pa_operation *o; if (!success) { - fprintf(stderr, "Failed to drain stream: %s\n", pa_strerror(pa_context_errno(context))); + fprintf(stderr, _("Failed to drain stream: %s\n"), pa_strerror(pa_context_errno(context))); quit(1); } if (verbose) - fprintf(stderr, "Playback stream drained.\n"); + fprintf(stderr, _("Playback stream drained.\n")); pa_stream_disconnect(stream); pa_stream_unref(stream); @@ -92,7 +89,7 @@ static void stream_drain_complete(pa_stream*s, int success, void *userdata) { pa_operation_unref(o); if (verbose) - fprintf(stderr, "Draining connection to server.\n"); + fprintf(stderr, _("Draining connection to server.\n")); } } @@ -139,12 +136,12 @@ static void stream_state_callback(pa_stream *s, void *userdata) { case PA_STREAM_READY: if (verbose) - fprintf(stderr, "Stream successfully created\n"); + fprintf(stderr, _("Stream successfully created\n")); break; case PA_STREAM_FAILED: default: - fprintf(stderr, "Stream errror: %s\n", pa_strerror(pa_context_errno(pa_stream_get_context(s)))); + fprintf(stderr, _("Stream errror: %s\n"), pa_strerror(pa_context_errno(pa_stream_get_context(s)))); quit(1); } } @@ -165,7 +162,7 @@ static void context_state_callback(pa_context *c, void *userdata) { assert(c && !stream); if (verbose) - fprintf(stderr, "Connection established.\n"); + fprintf(stderr, _("Connection established.\n")); stream = pa_stream_new(c, stream_name, &sample_spec, channel_map_set ? &channel_map : NULL); assert(stream); @@ -183,7 +180,7 @@ static void context_state_callback(pa_context *c, void *userdata) { case PA_CONTEXT_FAILED: default: - fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Connection failure: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); } } @@ -191,14 +188,14 @@ static void context_state_callback(pa_context *c, void *userdata) { /* UNIX signal to quit recieved */ static void exit_signal_callback(pa_mainloop_api*m, pa_signal_event *e, int sig, void *userdata) { if (verbose) - fprintf(stderr, "Got SIGINT, exiting.\n"); + fprintf(stderr, _("Got SIGINT, exiting.\n")); quit(0); } static void help(const char *argv0) { - printf("%s [options] [FILE]\n\n" + printf(_("%s [options] [FILE]\n\n" " -h, --help Show this help\n" " --version Show version\n\n" " -v, --verbose Enable verbose operation\n\n" @@ -207,7 +204,7 @@ static void help(const char *argv0) { " -n, --client-name=NAME How to call this client on the server\n" " --stream-name=NAME How to call this stream on the server\n" " --volume=VOLUME Specify the initial (linear) volume in range 0...65536\n" - " --channel-map=CHANNELMAP Set the channel map to the use\n", + " --channel-map=CHANNELMAP Set the channel map to the use\n"), argv0); } @@ -239,6 +236,7 @@ int main(int argc, char *argv[]) { }; setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR); if (!(bn = strrchr(argv[0], '/'))) bn = argv[0]; @@ -254,7 +252,8 @@ int main(int argc, char *argv[]) { goto quit; case ARG_VERSION: - printf("paplay "PACKAGE_VERSION"\nCompiled with libpulse %s\nLinked with libpulse %s\n", pa_get_headers_version(), pa_get_library_version()); + printf(_("paplay %s\nCompiled with libpulse %s\n" + "Linked with libpulse %s\n"), PACKAGE_VERSION, pa_get_headers_version(), pa_get_library_version()); ret = 0; goto quit; @@ -290,7 +289,7 @@ int main(int argc, char *argv[]) { case ARG_CHANNELMAP: if (!pa_channel_map_parse(&channel_map, optarg)) { - fprintf(stderr, "Invalid channel map\n"); + fprintf(stderr, _("Invalid channel map\n")); goto quit; } @@ -312,7 +311,7 @@ int main(int argc, char *argv[]) { sndfile = sf_open_fd(STDIN_FILENO, SFM_READ, &sfinfo, 0); if (!sndfile) { - fprintf(stderr, "Failed to open file '%s'\n", filename); + fprintf(stderr, _("Failed to open file '%s'\n"), filename); goto quit; } @@ -348,7 +347,7 @@ int main(int argc, char *argv[]) { assert(pa_sample_spec_valid(&sample_spec)); if (channel_map_set && channel_map.channels != sample_spec.channels) { - fprintf(stderr, "Channel map doesn't match file.\n"); + fprintf(stderr, _("Channel map doesn't match file.\n")); goto quit; } @@ -374,12 +373,12 @@ int main(int argc, char *argv[]) { if (verbose) { char t[PA_SAMPLE_SPEC_SNPRINT_MAX]; pa_sample_spec_snprint(t, sizeof(t), &sample_spec); - fprintf(stderr, "Using sample spec '%s'\n", t); + fprintf(stderr, _("Using sample spec '%s'\n"), t); } /* Set up a new main loop */ if (!(m = pa_mainloop_new())) { - fprintf(stderr, "pa_mainloop_new() failed.\n"); + fprintf(stderr, _("pa_mainloop_new() failed.\n")); goto quit; } @@ -394,7 +393,7 @@ int main(int argc, char *argv[]) { /* Create a new connection context */ if (!(context = pa_context_new(mainloop_api, client_name))) { - fprintf(stderr, "pa_context_new() failed.\n"); + fprintf(stderr, _("pa_context_new() failed.\n")); goto quit; } @@ -405,7 +404,7 @@ int main(int argc, char *argv[]) { /* Run the main loop */ if (pa_mainloop_run(m, &ret) < 0) { - fprintf(stderr, "pa_mainloop_run() failed.\n"); + fprintf(stderr, _("pa_mainloop_run() failed.\n")); goto quit; } diff --git a/src/utils/pasuspender.c b/src/utils/pasuspender.c index 5b4885db..8a59d5e4 100644 --- a/src/utils/pasuspender.c +++ b/src/utils/pasuspender.c @@ -35,20 +35,16 @@ #include #include #include - -#include +#include #ifdef __linux__ #include #endif +#include #include #include -#if PA_API_VERSION < 10 -#error Invalid PulseAudio API version -#endif - #define BUFSIZE 1024 static pa_context *context = NULL; @@ -82,7 +78,7 @@ static void start_child(void) { if ((child_pid = fork()) < 0) { - fprintf(stderr, "fork(): %s\n", strerror(errno)); + fprintf(stderr, _("fork(): %s\n"), strerror(errno)); quit(1); } else if (child_pid == 0) { @@ -93,7 +89,7 @@ static void start_child(void) { #endif if (execvp(child_argv[0], child_argv) < 0) - fprintf(stderr, "execvp(): %s\n", strerror(errno)); + fprintf(stderr, _("execvp(): %s\n"), strerror(errno)); _exit(1); @@ -110,7 +106,7 @@ static void suspend_complete(pa_context *c, int success, void *userdata) { n++; if (!success) { - fprintf(stderr, "Failure to suspend: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failure to suspend: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -125,7 +121,7 @@ static void resume_complete(pa_context *c, int success, void *userdata) { n++; if (!success) { - fprintf(stderr, "Failure to resume: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Failure to resume: %s\n"), pa_strerror(pa_context_errno(c))); quit(1); return; } @@ -148,7 +144,7 @@ static void context_state_callback(pa_context *c, void *userdata) { pa_operation_unref(pa_context_suspend_sink_by_index(c, PA_INVALID_INDEX, 1, suspend_complete, NULL)); pa_operation_unref(pa_context_suspend_source_by_index(c, PA_INVALID_INDEX, 1, suspend_complete, NULL)); } else { - fprintf(stderr, "WARNING: Sound server is not local, not suspending.\n"); + fprintf(stderr, _("WARNING: Sound server is not local, not suspending.\n")); start_child(); } @@ -160,7 +156,7 @@ static void context_state_callback(pa_context *c, void *userdata) { case PA_CONTEXT_FAILED: default: - fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c))); + fprintf(stderr, _("Connection failure: %s\n"), pa_strerror(pa_context_errno(c))); pa_context_unref(context); context = NULL; @@ -177,7 +173,7 @@ static void context_state_callback(pa_context *c, void *userdata) { } static void sigint_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) { - fprintf(stderr, "Got SIGINT, exiting.\n"); + fprintf(stderr, _("Got SIGINT, exiting.\n")); quit(0); } @@ -195,7 +191,7 @@ static void sigchld_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, vo if (WIFEXITED(status)) child_ret = WEXITSTATUS(status); else if (WIFSIGNALED(status)) { - fprintf(stderr, "WARNING: Child process terminated by signal %u\n", WTERMSIG(status)); + fprintf(stderr, _("WARNING: Child process terminated by signal %u\n"), WTERMSIG(status)); child_ret = 1; } @@ -213,10 +209,10 @@ static void sigchld_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, vo static void help(const char *argv0) { - printf("%s [options] ... \n\n" + printf(_("%s [options] ... \n\n" " -h, --help Show this help\n" " --version Show version\n" - " -s, --server=SERVER The name of the server to connect to\n\n", + " -s, --server=SERVER The name of the server to connect to\n\n"), argv0); } @@ -236,6 +232,9 @@ int main(int argc, char *argv[]) { {NULL, 0, NULL, 0} }; + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR); + if (!(bn = strrchr(argv[0], '/'))) bn = argv[0]; else @@ -249,7 +248,12 @@ int main(int argc, char *argv[]) { goto quit; case ARG_VERSION: - printf("pasuspender "PACKAGE_VERSION"\nCompiled with libpulse %s\nLinked with libpulse %s\n", pa_get_headers_version(), pa_get_library_version()); + printf(_("pasuspender %s\n" + "Compiled with libpulse %s\n" + "Linked with libpulse %s\n"), + PACKAGE_VERSION, + pa_get_headers_version(), + pa_get_library_version()); ret = 0; goto quit; @@ -273,7 +277,7 @@ int main(int argc, char *argv[]) { } if (!(m = pa_mainloop_new())) { - fprintf(stderr, "pa_mainloop_new() failed.\n"); + fprintf(stderr, _("pa_mainloop_new() failed.\n")); goto quit; } @@ -286,7 +290,7 @@ int main(int argc, char *argv[]) { #endif if (!(context = pa_context_new(mainloop_api, bn))) { - fprintf(stderr, "pa_context_new() failed.\n"); + fprintf(stderr, _("pa_context_new() failed.\n")); goto quit; } @@ -294,7 +298,7 @@ int main(int argc, char *argv[]) { pa_context_connect(context, server, PA_CONTEXT_NOAUTOSPAWN, NULL); if (pa_mainloop_run(m, &ret) < 0) { - fprintf(stderr, "pa_mainloop_run() failed.\n"); + fprintf(stderr, _("pa_mainloop_run() failed.\n")); goto quit; } diff --git a/src/utils/pax11publish.c b/src/utils/pax11publish.c index eee7b6a8..50d621d4 100644 --- a/src/utils/pax11publish.c +++ b/src/utils/pax11publish.c @@ -27,11 +27,13 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -47,17 +49,20 @@ int main(int argc, char *argv[]) { Display *d = NULL; enum { DUMP, EXPORT, IMPORT, REMOVE } mode = DUMP; + setlocale(LC_ALL, ""); + bindtextdomain(GETTEXT_PACKAGE, PULSE_LOCALEDIR); + while ((c = getopt(argc, argv, "deiD:S:O:I:c:hr")) != -1) { switch (c) { case 'D' : dname = optarg; break; case 'h': - printf("%s [-D display] [-S server] [-O sink] [-I source] [-c file] [-d|-e|-i|-r]\n\n" + printf(_("%s [-D display] [-S server] [-O sink] [-I source] [-c file] [-d|-e|-i|-r]\n\n" " -d Show current PulseAudio data attached to X11 display (default)\n" " -e Export local PulseAudio data to X11 display\n" " -i Import PulseAudio data from X11 display to local environment variables and cookie file.\n" - " -r Remove PulseAudio data from X11 display\n", + " -r Remove PulseAudio data from X11 display\n"), pa_path_get_filename(argv[0])); ret = 0; goto finish; @@ -86,13 +91,13 @@ int main(int argc, char *argv[]) { server = optarg; break; default: - fprintf(stderr, "Failed to parse command line.\n"); + fprintf(stderr, _("Failed to parse command line.\n")); goto finish; } } if (!(d = XOpenDisplay(dname))) { - pa_log("XOpenDisplay() failed"); + pa_log(_("XOpenDisplay() failed")); goto finish; } @@ -100,13 +105,13 @@ int main(int argc, char *argv[]) { case DUMP: { char t[1024]; if (pa_x11_get_prop(d, "PULSE_SERVER", t, sizeof(t))) - printf("Server: %s\n", t); + printf(_("Server: %s\n"), t); if (pa_x11_get_prop(d, "PULSE_SOURCE", t, sizeof(t))) - printf("Source: %s\n", t); + printf(_("Source: %s\n"), t); if (pa_x11_get_prop(d, "PULSE_SINK", t, sizeof(t))) - printf("Sink: %s\n", t); + printf(_("Sink: %s\n"), t); if (pa_x11_get_prop(d, "PULSE_COOKIE", t, sizeof(t))) - printf("Cookie: %s\n", t); + printf(_("Cookie: %s\n"), t); break; } @@ -124,12 +129,12 @@ int main(int argc, char *argv[]) { uint8_t cookie[PA_NATIVE_COOKIE_LENGTH]; size_t l; if ((l = pa_parsehex(t, cookie, sizeof(cookie))) != sizeof(cookie)) { - fprintf(stderr, "Failed to parse cookie data\n"); + fprintf(stderr, _("Failed to parse cookie data\n")); goto finish; } if (pa_authkey_save(cookie_file, cookie, l) < 0) { - fprintf(stderr, "Failed to save cookie data\n"); + fprintf(stderr, _("Failed to save cookie data\n")); goto finish; } } @@ -144,12 +149,12 @@ int main(int argc, char *argv[]) { assert(conf); if (pa_client_conf_load(conf, NULL) < 0) { - fprintf(stderr, "Failed to load client configuration file.\n"); + fprintf(stderr, _("Failed to load client configuration file.\n")); goto finish; } if (pa_client_conf_env(conf) < 0) { - fprintf(stderr, "Failed to read environment configuration data.\n"); + fprintf(stderr, _("Failed to read environment configuration data.\n")); goto finish; } @@ -166,7 +171,7 @@ int main(int argc, char *argv[]) { else { char hn[256]; if (!pa_get_fqdn(hn, sizeof(hn))) { - fprintf(stderr, "Failed to get FQDN.\n"); + fprintf(stderr, _("Failed to get FQDN.\n")); goto finish; } @@ -186,7 +191,7 @@ int main(int argc, char *argv[]) { pa_client_conf_free(conf); if (pa_authkey_load_auto(cookie_file, cookie, sizeof(cookie)) < 0) { - fprintf(stderr, "Failed to load cookie data\n"); + fprintf(stderr, _("Failed to load cookie data\n")); goto finish; } @@ -203,7 +208,7 @@ int main(int argc, char *argv[]) { break; default: - fprintf(stderr, "No yet implemented.\n"); + fprintf(stderr, _("Not yet implemented.\n")); goto finish; } -- cgit