internationalize pavucontrol.cc

This commit is contained in:
Lennart Poettering 2008-08-05 20:45:24 +02:00
parent 808ba48d95
commit c019877a9e
3 changed files with 113 additions and 53 deletions

View File

@ -24,10 +24,10 @@ glade_DATA=pavucontrol.glade
desktop_in_files=pavucontrol.desktop.in
desktop_DATA=$(desktop_in_files:.desktop.in=.desktop)
pavucontrol_SOURCES=pavucontrol.cc
pavucontrol_SOURCES=pavucontrol.cc i18n.h
pavucontrol_LDADD=$(AM_LDADD) $(GUILIBS_LIBS) $(PULSE_LIBS)
pavucontrol_CXXFLAGS=$(AM_CXXFLAGS) $(GUILIBS_CFLAGS) $(PULSE_CFLAGS)
pavucontrol_CXXFLAGS=$(AM_CXXFLAGS) $(GUILIBS_CFLAGS) $(PULSE_CFLAGS) -DLOCALEDIR=\"$(localedir)\"
pavucontrol_CXXFLAGS+=-DGLADE_FILE=\"$(gladedir)/pavucontrol.glade\"
#pavucontrol_CXXFLAGS+=-DGLADE_FILE=\"pavucontrol.glade\"

51
src/i18n.h Normal file
View File

@ -0,0 +1,51 @@
#ifndef fooi18nhfoo
#define fooi18nhfoo
/***
This file is part of pavucontrol.
Copyright 2006-2008 Lennart Poettering
pavucontrol is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
pavucontrol is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with pavucontrol. If not, see <http://www.gnu.org/licenses/>.
***/
#if !defined(GETTEXT_PACKAGE)
#error "Something is very wrong here, config.h needs to be included first"
#endif
#ifdef ENABLE_NLS
#include <libintl.h>
#define _(String) dgettext(GETTEXT_PACKAGE, String)
#ifdef gettext_noop
#define N_(String) gettext_noop(String)
#else
#define N_(String) (String)
#endif
#else /* NLS is disabled */
#define _(String) (String)
#define N_(String) (String)
#define textdomain(String) (String)
#define gettext(String) (String)
#define dgettext(Domain,String) (String)
#define dcgettext(Domain,String,Type) (String)
#define bindtextdomain(Domain,Directory) (Domain)
#define bind_textdomain_codeset(Domain,Codeset) (Codeset)
#endif /* ENABLE_NLS */
#endif

View File

@ -27,11 +27,14 @@
#include <gtkmm.h>
#include <libglademm.h>
#include <libintl.h>
#include <pulse/pulseaudio.h>
#include <pulse/glib-mainloop.h>
#include <pulse/ext-stream-restore.h>
#include "i18n.h"
#ifndef GLADE_FILE
#define GLADE_FILE "pavucontrol.glade"
#endif
@ -600,7 +603,7 @@ void SinkWidget::executeVolumeUpdate() {
pa_operation* o;
if (!(o = pa_context_set_sink_volume_by_index(context, index, &volume, NULL, NULL))) {
show_error("pa_context_set_sink_volume_by_index() failed");
show_error(_("pa_context_set_sink_volume_by_index() failed"));
return;
}
@ -615,7 +618,7 @@ void SinkWidget::onMuteToggleButton() {
pa_operation* o;
if (!(o = pa_context_set_sink_mute_by_index(context, index, muteToggleButton->get_active(), NULL, NULL))) {
show_error("pa_context_set_sink_mute_by_index() failed");
show_error(_("pa_context_set_sink_mute_by_index() failed"));
return;
}
@ -629,7 +632,7 @@ void SinkWidget::onDefaultToggle() {
return;
if (!(o = pa_context_set_default_sink(context, name.c_str(), NULL, NULL))) {
show_error("pa_context_set_default_sink() failed");
show_error(_("pa_context_set_default_sink() failed"));
return;
}
pa_operation_unref(o);
@ -637,7 +640,7 @@ void SinkWidget::onDefaultToggle() {
SourceWidget::SourceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
StreamWidget(cobject, x),
defaultMenuItem("_Default", true){
defaultMenuItem(_("_Default"), true){
add_events(Gdk::BUTTON_PRESS_MASK);
@ -658,7 +661,7 @@ void SourceWidget::executeVolumeUpdate() {
pa_operation* o;
if (!(o = pa_context_set_source_volume_by_index(context, index, &volume, NULL, NULL))) {
show_error("pa_context_set_source_volume_by_index() failed");
show_error(_("pa_context_set_source_volume_by_index() failed"));
return;
}
@ -673,7 +676,7 @@ void SourceWidget::onMuteToggleButton() {
pa_operation* o;
if (!(o = pa_context_set_source_mute_by_index(context, index, muteToggleButton->get_active(), NULL, NULL))) {
show_error("pa_context_set_source_mute_by_index() failed");
show_error(_("pa_context_set_source_mute_by_index() failed"));
return;
}
@ -687,7 +690,7 @@ void SourceWidget::onDefaultToggle() {
return;
if (!(o = pa_context_set_default_source(context, name.c_str(), NULL, NULL))) {
show_error("pa_context_set_default_source() failed");
show_error(_("pa_context_set_default_source() failed"));
return;
}
pa_operation_unref(o);
@ -696,8 +699,8 @@ void SourceWidget::onDefaultToggle() {
SinkInputWidget::SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
StreamWidget(cobject, x),
mainWindow(NULL),
titleMenuItem("_Move Stream...", true),
killMenuItem("_Terminate Stream", true) {
titleMenuItem(_("_Move Stream..."), true),
killMenuItem(_("_Terminate Stream"), true) {
add_events(Gdk::BUTTON_PRESS_MASK);
@ -723,7 +726,7 @@ void SinkInputWidget::executeVolumeUpdate() {
pa_operation* o;
if (!(o = pa_context_set_sink_input_volume(context, index, &volume, NULL, NULL))) {
show_error("pa_context_set_sink_input_volume() failed");
show_error(_("pa_context_set_sink_input_volume() failed"));
return;
}
@ -738,7 +741,7 @@ void SinkInputWidget::onMuteToggleButton() {
pa_operation* o;
if (!(o = pa_context_set_sink_input_mute(context, index, muteToggleButton->get_active(), NULL, NULL))) {
show_error("pa_context_set_sink_input_mute() failed");
show_error(_("pa_context_set_sink_input_mute() failed"));
return;
}
@ -772,7 +775,7 @@ void SinkInputWidget::buildMenu() {
void SinkInputWidget::onKill() {
pa_operation* o;
if (!(o = pa_context_kill_sink_input(context, index, NULL, NULL))) {
show_error("pa_context_kill_sink_input() failed");
show_error(_("pa_context_kill_sink_input() failed"));
return;
}
@ -789,7 +792,7 @@ void SinkInputWidget::SinkMenuItem::onToggle() {
pa_operation* o;
if (!(o = pa_context_move_sink_input_by_index(context, widget->index, index, NULL, NULL))) {
show_error("pa_context_move_sink_input_by_index() failed");
show_error(_("pa_context_move_sink_input_by_index() failed"));
return;
}
@ -799,8 +802,8 @@ void SinkInputWidget::SinkMenuItem::onToggle() {
SourceOutputWidget::SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
MinimalStreamWidget(cobject, x),
mainWindow(NULL),
titleMenuItem("_Move Stream...", true),
killMenuItem("_Terminate Stream", true) {
titleMenuItem(_("_Move Stream..."), true),
killMenuItem(_("_Terminate Stream"), true) {
add_events(Gdk::BUTTON_PRESS_MASK);
@ -825,7 +828,7 @@ SourceOutputWidget* SourceOutputWidget::create() {
void SourceOutputWidget::onKill() {
pa_operation* o;
if (!(o = pa_context_kill_source_output(context, index, NULL, NULL))) {
show_error("pa_context_kill_source_output() failed");
show_error(_("pa_context_kill_source_output() failed"));
return;
}
@ -866,7 +869,7 @@ void SourceOutputWidget::SourceMenuItem::onToggle() {
pa_operation* o;
if (!(o = pa_context_move_source_output_by_index(context, widget->index, index, NULL, NULL))) {
show_error("pa_context_move_source_output_by_index() failed");
show_error(_("pa_context_move_source_output_by_index() failed"));
return;
}
@ -908,7 +911,7 @@ void RoleWidget::executeVolumeUpdate() {
pa_operation* o;
if (!(o = pa_ext_stream_restore_write(context, PA_UPDATE_REPLACE, &info, 1, TRUE, NULL, NULL))) {
show_error("pa_ext_stream_restore_write() failed");
show_error(_("pa_ext_stream_restore_write() failed"));
return;
}
@ -1029,7 +1032,7 @@ static void read_callback(pa_stream *s, size_t length, void *userdata) {
double v;
if (pa_stream_peek(s, &data, &length) < 0) {
show_error("Failed to read data from stream");
show_error(_("Failed to read data from stream"));
return;
}
@ -1063,8 +1066,8 @@ void MainWindow::createMonitorStreamForSource(uint32_t source_idx) {
snprintf(t, sizeof(t), "%u", source_idx);
if (!(s = pa_stream_new(context, "Peak detect", &ss, NULL))) {
show_error("Failed to create monitoring stream");
if (!(s = pa_stream_new(context, _("Peak detect"), &ss, NULL))) {
show_error(_("Failed to create monitoring stream"));
return;
}
@ -1072,7 +1075,7 @@ void MainWindow::createMonitorStreamForSource(uint32_t source_idx) {
pa_stream_set_suspended_callback(s, suspended_callback, this);
if (pa_stream_connect_record(s, t, &attr, (pa_stream_flags_t) (PA_STREAM_DONT_MOVE|PA_STREAM_PEAK_DETECT|PA_STREAM_ADJUST_LATENCY)) < 0) {
show_error("Failed to connect monitoring stream");
show_error(_("Failed to connect monitoring stream"));
pa_stream_unref(s);
return;
}
@ -1099,8 +1102,8 @@ void MainWindow::createMonitorStreamForSinkInput(uint32_t sink_input_idx, uint32
snprintf(t, sizeof(t), "%u", monitor_source_idx);
if (!(s = pa_stream_new(context, "Peak detect", &ss, NULL))) {
show_error("Failed to create monitoring stream");
if (!(s = pa_stream_new(context, _("Peak detect"), &ss, NULL))) {
show_error(_("Failed to create monitoring stream"));
return;
}
@ -1109,7 +1112,7 @@ void MainWindow::createMonitorStreamForSinkInput(uint32_t sink_input_idx, uint32
pa_stream_set_suspended_callback(s, suspended_callback, this);
if (pa_stream_connect_record(s, t, &attr, (pa_stream_flags_t) (PA_STREAM_DONT_MOVE|PA_STREAM_PEAK_DETECT|PA_STREAM_ADJUST_LATENCY)) < 0) {
show_error("Failed to connect monitoring stream");
show_error(_("Failed to connect monitoring stream"));
pa_stream_unref(s);
return;
}
@ -1349,7 +1352,7 @@ bool MainWindow::createEventRoleWidget() {
eventRoleWidget->setChannelMap(cm, true);
eventRoleWidget->boldNameLabel->set_text("");
eventRoleWidget->nameLabel->set_label("System Sounds");
eventRoleWidget->nameLabel->set_label(_("System Sounds"));
eventRoleWidget->iconImage->set_from_icon_name("multimedia-volume-control", Gtk::ICON_SIZE_SMALL_TOOLBAR);
@ -1628,7 +1631,7 @@ void sink_cb(pa_context *, const pa_sink_info *i, int eol, void *userdata) {
MainWindow *w = static_cast<MainWindow*>(userdata);
if (eol < 0) {
show_error("Sink callback failure");
show_error(_("Sink callback failure"));
return;
}
@ -1644,7 +1647,7 @@ void source_cb(pa_context *, const pa_source_info *i, int eol, void *userdata) {
MainWindow *w = static_cast<MainWindow*>(userdata);
if (eol < 0) {
show_error("Source callback failure");
show_error(_("Source callback failure"));
return;
}
@ -1660,7 +1663,7 @@ void sink_input_cb(pa_context *, const pa_sink_input_info *i, int eol, void *use
MainWindow *w = static_cast<MainWindow*>(userdata);
if (eol < 0) {
show_error("Sink input callback failure");
show_error(_("Sink input callback failure"));
return;
}
@ -1676,7 +1679,7 @@ void source_output_cb(pa_context *, const pa_source_output_info *i, int eol, voi
MainWindow *w = static_cast<MainWindow*>(userdata);
if (eol < 0) {
show_error("Source output callback failure");
show_error(_("Source output callback failure"));
return;
}
@ -1707,7 +1710,7 @@ void client_cb(pa_context *, const pa_client_info *i, int eol, void *userdata) {
MainWindow *w = static_cast<MainWindow*>(userdata);
if (eol < 0) {
show_error("Client callback failure");
show_error(_("Client callback failure"));
return;
}
@ -1723,7 +1726,7 @@ void server_info_cb(pa_context *, const pa_server_info *i, void *userdata) {
MainWindow *w = static_cast<MainWindow*>(userdata);
if (!i) {
show_error("Server info callback failure");
show_error(_("Server info callback failure"));
return;
}
@ -1740,7 +1743,7 @@ void ext_stream_restore_read_cb(
MainWindow *w = static_cast<MainWindow*>(userdata);
if (eol < 0) {
g_debug("Failed to initialized stream_restore extension: %s", pa_strerror(pa_context_errno(context)));
g_debug(_("Failed to initialized stream_restore extension: %s"), pa_strerror(pa_context_errno(context)));
w->deleteEventRoleWidget();
return;
}
@ -1760,7 +1763,7 @@ static void ext_stream_restore_subscribe_cb(pa_context *c, void *userdata) {
pa_operation *o;
if (!(o = pa_ext_stream_restore_read(c, ext_stream_restore_read_cb, w))) {
show_error("pa_ext_stream_restore_read() failed");
show_error(_("pa_ext_stream_restore_read() failed"));
return;
}
@ -1777,7 +1780,7 @@ void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index,
else {
pa_operation *o;
if (!(o = pa_context_get_sink_info_by_index(c, index, sink_cb, w))) {
show_error("pa_context_get_sink_info_by_index() failed");
show_error(_("pa_context_get_sink_info_by_index() failed"));
return;
}
pa_operation_unref(o);
@ -1790,7 +1793,7 @@ void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index,
else {
pa_operation *o;
if (!(o = pa_context_get_source_info_by_index(c, index, source_cb, w))) {
show_error("pa_context_get_source_info_by_index() failed");
show_error(_("pa_context_get_source_info_by_index() failed"));
return;
}
pa_operation_unref(o);
@ -1803,7 +1806,7 @@ void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index,
else {
pa_operation *o;
if (!(o = pa_context_get_sink_input_info(c, index, sink_input_cb, w))) {
show_error("pa_context_get_sink_input_info() failed");
show_error(_("pa_context_get_sink_input_info() failed"));
return;
}
pa_operation_unref(o);
@ -1816,7 +1819,7 @@ void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index,
else {
pa_operation *o;
if (!(o = pa_context_get_source_output_info(c, index, source_output_cb, w))) {
show_error("pa_context_get_sink_input_info() failed");
show_error(_("pa_context_get_sink_input_info() failed"));
return;
}
pa_operation_unref(o);
@ -1829,7 +1832,7 @@ void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index,
else {
pa_operation *o;
if (!(o = pa_context_get_client_info(c, index, client_cb, w))) {
show_error("pa_context_get_client_info() failed");
show_error(_("pa_context_get_client_info() failed"));
return;
}
pa_operation_unref(o);
@ -1839,7 +1842,7 @@ void subscribe_cb(pa_context *c, pa_subscription_event_type_t t, uint32_t index,
case PA_SUBSCRIPTION_EVENT_SERVER: {
pa_operation *o;
if (!(o = pa_context_get_server_info(c, server_info_cb, w))) {
show_error("pa_context_get_server_info() failed");
show_error(_("pa_context_get_server_info() failed"));
return;
}
pa_operation_unref(o);
@ -1871,43 +1874,43 @@ void context_state_callback(pa_context *c, void *userdata) {
PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT|
PA_SUBSCRIPTION_MASK_CLIENT|
PA_SUBSCRIPTION_MASK_SERVER), NULL, NULL))) {
show_error("pa_context_subscribe() failed");
show_error(_("pa_context_subscribe() failed"));
return;
}
pa_operation_unref(o);
if (!(o = pa_context_get_server_info(c, server_info_cb, w))) {
show_error("pa_context_get_server_info() failed");
show_error(_("pa_context_get_server_info() failed"));
return;
}
pa_operation_unref(o);
if (!(o = pa_context_get_client_info_list(c, client_cb, w))) {
show_error("pa_context_client_info_list() failed");
show_error(_("pa_context_client_info_list() failed"));
return;
}
pa_operation_unref(o);
if (!(o = pa_context_get_sink_info_list(c, sink_cb, w))) {
show_error("pa_context_get_sink_info_list() failed");
show_error(_("pa_context_get_sink_info_list() failed"));
return;
}
pa_operation_unref(o);
if (!(o = pa_context_get_source_info_list(c, source_cb, w))) {
show_error("pa_context_get_source_info_list() failed");
show_error(_("pa_context_get_source_info_list() failed"));
return;
}
pa_operation_unref(o);
if (!(o = pa_context_get_sink_input_info_list(c, sink_input_cb, w))) {
show_error("pa_context_get_sink_input_info_list() failed");
show_error(_("pa_context_get_sink_input_info_list() failed"));
return;
}
pa_operation_unref(o);
if (!(o = pa_context_get_source_output_info_list(c, source_output_cb, w))) {
show_error("pa_context_get_source_output_info_list() failed");
show_error(_("pa_context_get_source_output_info_list() failed"));
return;
}
pa_operation_unref(o);
@ -1925,13 +1928,13 @@ void context_state_callback(pa_context *c, void *userdata) {
pa_operation_unref(o);
} else
g_debug("Failed to initialized stream_restore extension: %s", pa_strerror(pa_context_errno(context)));
g_debug(_("Failed to initialized stream_restore extension: %s"), pa_strerror(pa_context_errno(context)));
break;
}
case PA_CONTEXT_FAILED:
show_error("Connection failed");
show_error(_("Connection failed"));
return;
case PA_CONTEXT_TERMINATED:
@ -1942,6 +1945,12 @@ void context_state_callback(pa_context *c, void *userdata) {
}
int main(int argc, char *argv[]) {
/* Initialize the i18n stuff */
bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
signal(SIGPIPE, SIG_IGN);
Gtk::Main kit(argc, argv);
@ -1954,7 +1963,7 @@ int main(int argc, char *argv[]) {
g_assert(api);
pa_proplist *proplist = pa_proplist_new();
pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, "PulseAudio Volume Control");
pa_proplist_sets(proplist, PA_PROP_APPLICATION_NAME, _("PulseAudio Volume Control"));
pa_proplist_sets(proplist, PA_PROP_APPLICATION_ID, "org.PulseAudio.pavucontrol");
pa_proplist_sets(proplist, PA_PROP_APPLICATION_ICON_NAME, "audio-card");
pa_proplist_sets(proplist, PA_PROP_APPLICATION_VERSION, PACKAGE_VERSION);
@ -1967,7 +1976,7 @@ int main(int argc, char *argv[]) {
pa_context_set_state_callback(context, context_state_callback, mainWindow);
if (pa_context_connect(context, NULL, (pa_context_flags_t) 0, NULL) < 0) {
show_error("Connection failed");
show_error(_("Connection failed"));
goto finish;
}