From 9b2d077c7f5dca6e4013f04318f7b83531fac387 Mon Sep 17 00:00:00 2001 From: Kalle Wallin Date: Sat, 5 Jun 2004 18:51:26 +0000 Subject: Added initial i18n support git-svn-id: https://svn.musicpd.org/ncmpc/trunk@1346 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/Makefile.am | 7 +++- src/colors.c | 9 ++-- src/command.c | 119 ++++++++++++++++++++++++++-------------------------- src/conf.c | 32 +++++++------- src/main.c | 25 +++++------ src/screen.c | 69 +++++++++++++----------------- src/screen.h | 6 --- src/screen_file.c | 20 +++++---- src/screen_keydef.c | 38 +++++++++-------- src/screen_play.c | 18 ++++---- src/screen_utils.c | 7 ++-- src/support.c | 11 ++--- 12 files changed, 174 insertions(+), 187 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index abf121cb2..59a7f4a70 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,9 +4,14 @@ bin_PROGRAMS = ncmpc +ncmpc_LDADD = $(GLIB_LIBS) + +AM_CPPFLAGS = $(GLIB_CFLAGS) -DLOCALE_DIR=\""$(datadir)/locale"\" -DSYSCONFDIR=\""$(sysconfdir)"\" + + ncmpc_headers = libmpdclient.h mpc.h options.h conf.h command.h screen.h \ screen_utils.h screen_play.h screen_file.h screen_search.h \ - screen_help.h list_window.h colors.h support.h + screen_help.h list_window.h colors.h support.h ncmpc.h ncmpc_SOURCES = libmpdclient.c main.c mpc.c options.c conf.c command.c \ screen.c screen_utils.c screen_play.c screen_file.c \ diff --git a/src/colors.c b/src/colors.c index f70969390..bfb4c316c 100644 --- a/src/colors.c +++ b/src/colors.c @@ -23,6 +23,7 @@ #include #include "config.h" +#include "ncmpc.h" #include "options.h" #include "support.h" #include "colors.h" @@ -187,7 +188,7 @@ colors_str2color(char *str) return COLOR_BRIGHT_BLACK; else if( !strcasecmp(str,"none") ) return -1; - fprintf(stderr,"Warning: Unknown color - %s\n", str); + fprintf(stderr,_("Warning: Unknown color - %s\n"), str); return -2; } @@ -232,7 +233,7 @@ colors_assign(char *name, char *value) bg = color; return 0; } - fprintf(stderr,"Warning: Unknown color field - %s\n", name); + fprintf(stderr,_("Warning: Unknown color field - %s\n"), name); return -1; } @@ -267,7 +268,7 @@ colors_start(void) } } else if( !can_change_color() ) - fprintf(stderr, "Terminal lacks support for changing colors!\n"); + fprintf(stderr, _("Terminal lacks support for changing colors!\n")); if( options.enable_colors ) { @@ -284,7 +285,7 @@ colors_start(void) } else if( options.enable_colors ) { - fprintf(stderr, "Terminal lacks color capabilities!\n"); + fprintf(stderr, _("Terminal lacks color capabilities!\n")); options.enable_colors = 0; } diff --git a/src/command.c b/src/command.c index bb7dd7bc2..78199f252 100644 --- a/src/command.c +++ b/src/command.c @@ -25,6 +25,7 @@ #include #include "config.h" +#include "ncmpc.h" #include "command.h" #undef DEBUG_KEYS @@ -61,98 +62,98 @@ extern void screen_resize(void); static command_definition_t cmds[] = { { { 13, 0, 0 }, CMD_PLAY, "play", - "Play/Enter directory" }, + N_("Play/Enter directory") }, { { 'P', 0, 0 }, CMD_PAUSE,"pause", - "Pause" }, + N_("Pause") }, { { 's', BS, 0 }, CMD_STOP, "stop", - "Stop" }, + N_("Stop") }, { { '>', 0, 0 }, CMD_TRACK_NEXT, "next", - "Next track" }, + N_("Next track") }, { { '<', 0, 0 }, CMD_TRACK_PREVIOUS, "prev", - "Previous track" }, + N_("Previous track") }, { { 'f', 0, 0 }, CMD_SEEK_FORWARD, "seek-forward", - "Seek forward" }, + N_("Seek forward") }, { { 'b', 0, 0 }, CMD_SEEK_BACKWARD, "seek-backward", - "Seek backward" }, + N_("Seek backward") }, { { '+', RGHT, 0 }, CMD_VOLUME_UP, "volume-up", - "Increase volume" }, + N_("Increase volume") }, { { '-', LEFT, 0 }, CMD_VOLUME_DOWN, "volume-down", - "Decrease volume" }, + N_("Decrease volume") }, { { 'w', 0, 0 }, CMD_TOGGLE_FIND_WRAP, "wrap-mode", - "Toggle find mode" }, + N_("Toggle find mode") }, { { 'U', 0, 0 }, CMD_TOGGLE_AUTOCENTER, "autocenter-mode", - "Toggle auto center mode" }, + N_("Toggle auto center mode") }, { { ' ', 'a', 0 }, CMD_SELECT, "select", - "Select/deselect song in playlist" }, + N_("Select/deselect song in playlist") }, { { DEL, 'd', 0 }, CMD_DELETE, "delete", - "Delete song from playlist" }, + N_("Delete song from playlist") }, { { 'Z', 0, 0 }, CMD_SHUFFLE, "shuffle", - "Shuffle playlist" }, + N_("Shuffle playlist") }, { { 'c', 0, 0 }, CMD_CLEAR, "clear", - "Clear playlist" }, + N_("Clear playlist") }, { { 'r', 0, 0 }, CMD_REPEAT, "repeat", - "Toggle repeat mode" }, + N_("Toggle repeat mode") }, { { 'z', 0, 0 }, CMD_RANDOM, "random", - "Toggle random mode" }, + N_("Toggle random mode") }, { { 'x', 0, 0 }, CMD_CROSSFADE, "crossfade", - "Toggle crossfade mode" }, + N_("Toggle crossfade mode") }, { { 21, 0, 0 }, CMD_DB_UPDATE, "db-update", - "Start a music database update" }, + N_("Start a music database update") }, { { 'S', 0, 0 }, CMD_SAVE_PLAYLIST, "save", - "Save playlist" }, + N_("Save playlist") }, { { 0, 0, 0 }, CMD_LIST_MOVE_UP, "move-up", - "Move item up" }, + N_("Move item up") }, { { 0, 0, 0 }, CMD_LIST_MOVE_DOWN, "move-down", - "Move item down" }, + N_("Move item down") }, { { UP, ',', 0 }, CMD_LIST_PREVIOUS, "up", - "Move cursor up" }, + N_("Move cursor up") }, { { DWN, '.', 0 }, CMD_LIST_NEXT, "down", - "Move cursor down" }, + N_("Move cursor down") }, { { HOME, 0x01, 0 }, CMD_LIST_FIRST, "home", - "Home " }, + N_("Home ") }, { { END, 0x05, 0 }, CMD_LIST_LAST, "end", - "End " }, + N_("End ") }, { { PGUP, 'A', 0 }, CMD_LIST_PREVIOUS_PAGE, "pgup", - "Page up" }, + N_("Page up") }, { { PGDN, 'B', 0 }, CMD_LIST_NEXT_PAGE, "pgdn", - "Page down" }, + N_("Page down") }, { { '/', 0, 0 }, CMD_LIST_FIND, "find", - "Forward find" }, + N_("Forward find") }, { { 'n', 0, 0 }, CMD_LIST_FIND_NEXT, "find-next", - "Forward find next" }, + N_("Forward find next") }, { { '?', 0, 0 }, CMD_LIST_RFIND, "rfind", - "Backward find" }, + N_("Backward find") }, { { 'p', 0, 0 }, CMD_LIST_RFIND_NEXT, "rfind-next", - "Backward find previous" }, + N_("Backward find previous") }, { { TAB, 0, 0 }, CMD_SCREEN_NEXT, "screen-next", - "Next screen" }, + N_("Next screen") }, { { STAB, 0, 0 }, CMD_SCREEN_PREVIOUS, "screen-prev", - "Previous screen" }, + N_("Previous screen") }, { { '1', F1, 'h' }, CMD_SCREEN_HELP, "screen-help", - "Help screen" }, + N_("Help screen") }, { { '2', F2, 0 }, CMD_SCREEN_PLAY, "screen-playlist", - "Playlist screen" }, + N_("Playlist screen") }, { { '3', F3, 0 }, CMD_SCREEN_FILE, "screen-browse", - "Browse screen" }, + N_("Browse screen") }, { {'u', 0, 0 }, CMD_SCREEN_UPDATE, "update", - "Update screen" }, + N_("Update screen") }, #ifdef ENABLE_KEYDEF_SCREEN { {'K', 0, 0 }, CMD_SCREEN_KEYDEF, "screen-keyedit", - "Key configuration screen" }, + N_("Key configuration screen") }, #endif { { 'q', 0, 0 }, CMD_QUIT, "quit", - "Quit " PACKAGE }, + N_("Quit") }, { { -1, -1, -1 }, CMD_NONE, NULL, NULL } }; @@ -173,39 +174,39 @@ key2str(int key) switch(key) { case 0: - return "Undefined"; + return _("Undefined"); case ' ': - return "Space"; + return _("Space"); case 13: - return "Enter"; + return _("Enter"); case BS: - return "Backspace"; + return _("Backspace"); case DEL: - return "Delete"; + return _("Delete"); case UP: - return "Up"; + return _("Up"); case DWN: - return "Down"; + return _("Down"); case LEFT: - return "Left"; + return _("Left"); case RGHT: - return "Right"; + return _("Right"); case HOME: - return "Home"; + return _("Home"); case END: - return "End"; + return _("End"); case PGDN: - return "PageDown"; + return _("PageDown"); case PGUP: - return "PageUp"; + return _("PageUp"); case TAB: - return "Tab"; + return _("Tab"); case STAB: - return "Shift+Tab"; + return _("Shift+Tab"); case ESC: - return "Esc"; + return _("Esc"); case KEY_IC: - return "Insert"; + return _("Insert"); default: for(i=0; i<=63; i++) if( key==KEY_F(i) ) @@ -278,7 +279,7 @@ get_key_description(command_t command) while( cmds[i].description ) { if( cmds[i].command == command ) - return cmds[i].description; + return _(cmds[i].description); i++; } return NULL; @@ -391,7 +392,7 @@ check_key_bindings(void) if( cmds[i].keys[j] && (cmd=get_key_command(cmds[i].keys[j])) != cmds[i].command ) { - fprintf(stderr, "Error: Key %s assigned to %s and %s !!!\n", + fprintf(stderr, _("Error: Key %s assigned to %s and %s !!!\n"), key2str(cmds[i].keys[j]), get_key_command_name(cmds[i].command), get_key_command_name(cmd)); diff --git a/src/conf.c b/src/conf.c index 06866c13e..cb8ba0eb2 100644 --- a/src/conf.c +++ b/src/conf.c @@ -28,20 +28,14 @@ #include #include - #include "config.h" +#include "ncmpc.h" #include "options.h" #include "support.h" #include "command.h" #include "colors.h" #include "conf.h" -#ifdef DEBUG -#define D(x) x -#else -#define D(x) -#endif - #define ENABLE_OLD_COLOR_SYNTAX #define MAX_LINE_LENGTH 1024 @@ -111,14 +105,18 @@ parse_key_value(char *str, size_t len, char **end) else if( isdigit(c) ) state = KEY_PARSER_DEC; else { - fprintf(stderr, "Error: Unsupported key definition - %s\n", str); + fprintf(stderr, + _("Error: Unsupported key definition - %s\n"), + str); return -1; } break; case KEY_PARSER_CHAR: if( next!='\'' ) { - fprintf(stderr, "Error: Unsupported key definition - %s\n", str); + fprintf(stderr, + _("Error: Unsupported key definition - %s\n"), + str); return -1; } value = c; @@ -132,7 +130,7 @@ parse_key_value(char *str, size_t len, char **end) case KEY_PARSER_HEX: if( !isdigit(next) ) { - fprintf(stderr, "Error: Digit expexted after 0x - %s\n", str); + fprintf(stderr,_("Error: Digit expexted after 0x - %s\n"), str); return -1; } value = (int) strtol(str+(i+1), end, 16); @@ -168,7 +166,7 @@ parse_key_definition(char *str) buf[j++] = str[i++]; if( (cmd=get_key_command_from_name(buf)) == CMD_NONE ) { - fprintf(stderr, "Error: Unknown key command %s\n", buf); + fprintf(stderr, _("Error: Unknown key command %s\n"), buf); return -1; } @@ -182,7 +180,7 @@ parse_key_definition(char *str) len = strlen(buf); if( len==0 ) { - fprintf(stderr,"Error: Incomplete key definition - %s\n", str); + fprintf(stderr,_("Error: Incomplete key definition - %s\n"), str); return -1; } @@ -202,7 +200,7 @@ parse_key_definition(char *str) } if( key<0 ) { - fprintf(stderr,"Error: Bad key definition - %s\n", str); + fprintf(stderr,_("Error: Bad key definition - %s\n"), str); return -1; } @@ -254,7 +252,7 @@ parse_color_definition(char *str) color=colors_str2color(buf); if( color<0 ) { - fprintf(stderr, "Error: Bad color %s [%d]\n", buf, color); + fprintf(stderr,_("Error: Bad color %s [%d]\n"), buf, color); return -1; } name = g_strdup(buf); @@ -269,7 +267,7 @@ parse_color_definition(char *str) len = strlen(buf); if( len==0 ) { - fprintf(stderr,"Error: Incomplete color definition - %s\n", str); + fprintf(stderr,_("Error: Incomplete color definition - %s\n"), str); g_free(name); return -1; } @@ -290,7 +288,7 @@ parse_color_definition(char *str) } if( value<0 || i!=3) { - fprintf(stderr,"Error: Bad color definition - %s\n", str); + fprintf(stderr,_("Error: Bad color definition - %s\n"), str); g_free(name); return -1; } @@ -469,7 +467,7 @@ read_rc_file(char *filename, options_t *options) if( !match_found ) fprintf(stderr, - "Unknown configuration parameter: %s\n", + _("Unknown configuration parameter: %s\n"), name); #ifdef DEBUG printf( " %s = %s %s\n", diff --git a/src/main.c b/src/main.c index bb3740b62..15ecf4532 100644 --- a/src/main.c +++ b/src/main.c @@ -23,6 +23,7 @@ #include #include "config.h" +#include "ncmpc.h" #include "libmpdclient.h" #include "support.h" #include "mpc.h" @@ -31,13 +32,6 @@ #include "screen.h" #include "conf.h" -/* time in seconds between mpd updates (double) */ -#define MPD_UPDATE_TIME 0.5 - -/* timout in seconds before trying to reconnect (int) */ -#define MPD_RECONNECT_TIMEOUT 3 - - static mpd_client_t *mpc = NULL; static GTimer *timer = NULL; @@ -62,7 +56,7 @@ exit_and_cleanup(void) void catch_sigint( int sig ) { - printf( "\nExiting...\n"); + printf( _("\nExiting...\n")); exit(EXIT_SUCCESS); } @@ -73,6 +67,13 @@ main(int argc, const char *argv[]) struct sigaction act; gboolean connected; + /* initialize i18n support */ +#ifdef ENABLE_NLS + setlocale(LC_MESSAGES, ""); + bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR); + textdomain(GETTEXT_PACKAGE); +#endif + /* initialize options */ options = options_init(); @@ -85,7 +86,7 @@ main(int argc, const char *argv[]) /* check key bindings */ if( check_key_bindings() ) { - fprintf(stderr, "Confusing key bindings - exiting!\n"); + fprintf(stderr, _("Confusing key bindings - exiting!\n")); exit(EXIT_FAILURE); } @@ -149,7 +150,7 @@ main(int argc, const char *argv[]) } else if( mpc_error(mpc) ) { - screen_status_printf("Lost connection to %s", options->host); + screen_status_printf(_("Lost connection to %s"), options->host); connected = FALSE; doupdate(); mpd_clearError(mpc->connection); @@ -179,14 +180,14 @@ main(int argc, const char *argv[]) else if( options->reconnect ) { sleep(MPD_RECONNECT_TIMEOUT); - screen_status_printf("Connecting to %s... [Press Ctrl-C to abort]", + screen_status_printf(_("Connecting to %s... [Press Ctrl-C to abort]"), options->host); if( mpc_reconnect(mpc, options->host, options->port, options->password) == 0 ) { - screen_status_printf("Connected to %s!", options->host); + screen_status_printf(_("Connected to %s!"), options->host); connected = TRUE; } doupdate(); diff --git a/src/screen.c b/src/screen.c index 4059ac24f..94b3dc860 100644 --- a/src/screen.c +++ b/src/screen.c @@ -21,12 +21,12 @@ #include #include #include -//#include #include #include #include #include "config.h" +#include "ncmpc.h" #include "libmpdclient.h" #include "mpc.h" #include "command.h" @@ -128,23 +128,23 @@ paint_top_window(char *header, mpd_client_t *c, int clear) colors_use(w, COLOR_TITLE_BOLD); waddstr(w, get_key_names(CMD_SCREEN_HELP, FALSE)); colors_use(w, COLOR_TITLE); - waddstr(w, ":Help "); + waddstr(w, _(":Help ")); colors_use(w, COLOR_TITLE_BOLD); waddstr(w, get_key_names(CMD_SCREEN_PLAY, FALSE)); colors_use(w, COLOR_TITLE); - waddstr(w, ":Playlist "); + waddstr(w, _(":Playlist ")); colors_use(w, COLOR_TITLE_BOLD); waddstr(w, get_key_names(CMD_SCREEN_FILE, FALSE)); colors_use(w, COLOR_TITLE); - waddstr(w, ":Browse"); + waddstr(w, _(":Browse")); } if( c->status->volume==MPD_STATUS_NO_VOLUME ) { - snprintf(buf, 32, "Volume n/a "); + snprintf(buf, 32, _("Volume n/a ")); } else { - snprintf(buf, 32, " Volume %d%%", c->status->volume); + snprintf(buf, 32, _(" Volume %d%%"), c->status->volume); } colors_use(w, COLOR_TITLE); mvwaddstr(w, 0, screen->top_window.cols-strlen(buf), buf); @@ -263,13 +263,13 @@ paint_status_window(mpd_client_t *c) switch(status->state) { case MPD_STATUS_STATE_STOP: - waddstr(w, "Stopped! "); + waddstr(w, _("Stopped! ")); break; case MPD_STATUS_STATE_PLAY: - waddstr(w, "Playing:"); + waddstr(w, _("Playing:")); break; case MPD_STATUS_STATE_PAUSE: - waddstr(w, "[Paused]"); + waddstr(w, _("[Paused]")); break; default: break; @@ -330,20 +330,6 @@ paint_status_window(mpd_client_t *c) mvwaddstr(w, 0, x, screen->buf); } -#ifdef ENABLE_STATUS_LINE_CLOCK - else if( c->status->state == MPD_STATUS_STATE_STOP ) - { - time_t timep; - - /* Note: setlocale(LC_TIME,"") should be used first */ - time(&timep); - strftime(screen->buf, screen->buf_size, "%X ", localtime(&timep)); - x = screen->status_window.cols - strlen(screen->buf) ; - colors_use(w, COLOR_STATUS_TIME); - mvwaddstr(w, 0, x, screen->buf); - } -#endif - wnoutrefresh(w); } @@ -393,7 +379,7 @@ screen_resize(void) if( COLSstatus->updatingDb; } if( repeat != c->status->repeat ) - screen_status_printf("Repeat is %s", - c->status->repeat ? "On" : "Off"); + screen_status_printf(c->status->repeat ? + _("Repeat is on") : + _("Repeat is off")); if( random != c->status->random ) - screen_status_printf("Random is %s", - c->status->random ? "On" : "Off"); + screen_status_printf(c->status->random ? + _("Random is on") : + _("Random is off")); + if( crossfade != c->status->crossfade ) - screen_status_printf("Crossfade %d seconds", c->status->crossfade); + screen_status_printf(_("Crossfade %d seconds"), c->status->crossfade); if( dbupdate && dbupdate != c->status->updatingDb ) - screen_status_printf("Database updated!"); + screen_status_printf(_("Database updated!")); repeat = c->status->repeat; random = c->status->random; @@ -775,13 +764,13 @@ screen_cmd(mpd_client_t *c, command_t cmd) case CMD_SHUFFLE: mpd_sendShuffleCommand(c->connection); mpd_finishCommand(c->connection); - screen_status_message("Shuffled playlist!"); + screen_status_message(_("Shuffled playlist!")); break; case CMD_CLEAR: mpd_sendClearCommand(c->connection); mpd_finishCommand(c->connection); file_clear_highlights(c); - screen_status_message("Cleared playlist!"); + screen_status_message(_("Cleared playlist!")); break; case CMD_REPEAT: n = !c->status->repeat; @@ -808,10 +797,10 @@ screen_cmd(mpd_client_t *c, command_t cmd) n = mpd_getUpdateId(c->connection); mpd_finishCommand(c->connection); if( !mpc_error(c) ) - screen_status_printf("Database update started [%d]", n); + screen_status_printf(_("Database update started [%d]"), n); } else - screen_status_printf("Database update running..."); + screen_status_printf(_("Database update running...")); break; case CMD_VOLUME_UP: if( c->status->volume!=MPD_STATUS_NO_VOLUME && c->status->volume<100 ) @@ -831,13 +820,15 @@ screen_cmd(mpd_client_t *c, command_t cmd) break; case CMD_TOGGLE_FIND_WRAP: options.find_wrap = !options.find_wrap; - screen_status_printf("Find mode: %s", - options.find_wrap ? "Wrapped" : "Normal"); + screen_status_printf(options.find_wrap ? + _("Find mode: Wrapped") : + _("Find mode: Normal")); break; case CMD_TOGGLE_AUTOCENTER: options.auto_center = !options.auto_center; - screen_status_printf("Auto center mode: %s", - options.auto_center ? "On" : "Off"); + screen_status_printf(options.auto_center ? + _("Auto center mode: On") : + _("Auto center mode: Off")); break; case CMD_SCREEN_PREVIOUS: if( screen->mode > SCREEN_PLAY_WINDOW ) diff --git a/src/screen.h b/src/screen.h index a7e6b7250..00cd35530 100644 --- a/src/screen.h +++ b/src/screen.h @@ -14,12 +14,6 @@ #define SCREEN_MIN_COLS 14 #define SCREEN_MIN_ROWS 5 -/* timeout for non blocking read [ms] */ -#define SCREEN_TIMEOUT 500 - -/* welcome message time [s] */ -#define SCREEN_WELCOME_TIME 10 - #define IS_PLAYING(s) (s==MPD_STATUS_STATE_PLAY) #define IS_PAUSED(s) (s==MPD_STATUS_STATE_PAUSE) #define IS_STOPPED(s) (!(IS_PLAYING(s) | IS_PAUSED(s))) diff --git a/src/screen_file.c b/src/screen_file.c index d2b1f7844..be5e1eb9e 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -23,6 +23,7 @@ #include #include "config.h" +#include "ncmpc.h" #include "support.h" #include "libmpdclient.h" #include "mpc.h" @@ -147,7 +148,7 @@ load_playlist(screen_t *screen, mpd_client_t *c, filelist_entry_t *entry) mpd_sendLoadCommand(c->connection, plf->path); mpd_finishCommand(c->connection); - screen_status_printf("Loading playlist %s...", filename); + screen_status_printf(_("Loading playlist %s..."), filename); g_free(filename); return 0; } @@ -169,21 +170,21 @@ handle_delete(screen_t *screen, mpd_client_t *c) if( entity->type!=MPD_INFO_ENTITY_TYPE_PLAYLISTFILE ) { - screen_status_printf("You can only delete playlists!"); + screen_status_printf(_("You can only delete playlists!")); beep(); return -1; } plf = entity->info.playlistFile; str = utf8_to_locale(basename(plf->path)); - snprintf(buf, BUFSIZE, "Delete playlist %s [y/n] ? ", str); + snprintf(buf, BUFSIZE, _("Delete playlist %s [y/n] ? "), str); g_free(str); key = tolower(screen_getch(screen->status_window.w, buf)); if( key==KEY_RESIZE ) screen_resize(); if( key!='y' ) { - screen_status_printf("Aborted!"); + screen_status_printf(_("Aborted!")); return 0; } @@ -197,7 +198,7 @@ handle_delete(screen_t *screen, mpd_client_t *c) beep(); return -1; } - screen_status_printf("Playlist deleted!"); + screen_status_printf(_("Playlist deleted!")); mpc_update_filelist(c); list_window_check_selected(lw, c->filelist_length); return 0; @@ -231,7 +232,7 @@ add_directory(mpd_client_t *c, char *dir) char *dirname; dirname = utf8_to_locale(dir); - screen_status_printf("Adding directory %s...\n", dirname); + screen_status_printf(_("Adding directory %s...\n"), dirname); doupdate(); g_free(dirname); dirname = NULL; @@ -301,7 +302,7 @@ handle_select(screen_t *screen, mpd_client_t *c) playlist_add_song(c, song); - screen_status_printf("Adding \'%s\' to playlist\n", + screen_status_printf(_("Adding \'%s\' to playlist\n"), mpc_get_song_name(song)); } } @@ -366,7 +367,8 @@ file_title(void) tmp = utf8_to_locale(basename(mpc->cwd)); snprintf(buf, TITLESIZE, - TOP_HEADER_FILE ": %s ", + "%s : %s ", + _(TOP_HEADER_FILE) , tmp ); g_free(tmp); @@ -418,7 +420,7 @@ file_cmd(screen_t *screen, mpd_client_t *c, command_t cmd) case CMD_SCREEN_UPDATE: mpc_update_filelist(c); list_window_check_selected(lw, c->filelist_length); - screen_status_printf("Screen updated!"); + screen_status_printf(_("Screen updated!")); return 1; case CMD_LIST_FIND: case CMD_LIST_RFIND: diff --git a/src/screen_keydef.c b/src/screen_keydef.c index 4bda6ea21..3e2c921bc 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -25,6 +25,7 @@ #include "config.h" #ifdef ENABLE_KEYDEF_SCREEN +#include "ncmpc.h" #include "libmpdclient.h" #include "options.h" #include "conf.h" @@ -41,8 +42,8 @@ #define LIST_ITEM_SAVE() (LIST_ITEM_APPLY()+1) #define LIST_LENGTH() (LIST_ITEM_SAVE()+1) -#define LIST_ITEM_SAVE_LABEL "===> Apply & Save key bindings " -#define LIST_ITEM_APPLY_LABEL "===> Apply key bindings " +#define LIST_ITEM_SAVE_LABEL _("===> Apply & Save key bindings ") +#define LIST_ITEM_APPLY_LABEL _("===> Apply key bindings ") static list_window_t *lw = NULL; @@ -71,10 +72,10 @@ apply_keys(void) size_t size = command_list_length*sizeof(command_definition_t); memcpy(orginal_cmds, cmds, size); - screen_status_printf("You have new key bindings!"); + screen_status_printf(_("You have new key bindings!")); } else - screen_status_printf("Keybindings unchanged."); + screen_status_printf(_("Keybindings unchanged.")); } static int @@ -85,7 +86,7 @@ save_keys(void) if( check_user_conf_dir() ) { - screen_status_printf("Error: Unable to create direcory ~/.ncmpc - %s", + screen_status_printf(_("Error: Unable to create direcory ~/.ncmpc - %s"), strerror(errno)); beep(); return -1; @@ -95,15 +96,15 @@ save_keys(void) if( (f=fopen(filename,"w")) == NULL ) { - screen_status_printf("Error: %s - %s", filename, strerror(errno)); + screen_status_printf(_("Error: %s - %s"), filename, strerror(errno)); beep(); g_free(filename); return -1; } if( write_key_bindings(f) ) - screen_status_printf("Error: %s - %s", filename, strerror(errno)); + screen_status_printf(_("Error: %s - %s"), filename, strerror(errno)); else - screen_status_printf("Wrote %s", filename); + screen_status_printf(_("Wrote %s"), filename); g_free(filename); return fclose(f); @@ -131,7 +132,7 @@ delete_key(int cmd_index, int key_index) { int i = key_index+1; - screen_status_printf("Delete..."); + screen_status_printf(_("Deleted")); while( irepaint = 1; } @@ -202,7 +204,7 @@ list_callback(int index, int *highlight, void *data) } else if ( index==subcmd_addpos ) { - snprintf(buf, BUFSIZE, "%d. Add new key ", index+1 ); + snprintf(buf, BUFSIZE, _("%d. Add new key "), index+1 ); return buf; } } @@ -249,7 +251,7 @@ keydef_open(screen_t *screen, mpd_client_t *c) cmds = g_malloc0(cmds_size); memcpy(cmds, current_cmds, cmds_size); command_list_length += STATIC_ITEMS; - screen_status_printf("Welcome to the key editor!"); + screen_status_printf(_("Welcome to the key editor!")); } subcmd = -1; @@ -265,7 +267,7 @@ keydef_close(void) cmds = NULL; } else - screen_status_printf("Note: Did you forget to \'Apply\' your changes?"); + screen_status_printf(_("Note: Did you forget to \'Apply\' your changes?")); } static char * @@ -274,10 +276,10 @@ keydef_title(void) static char buf[BUFSIZE]; if( subcmd<0 ) - return (TOP_HEADER_PREFIX "Edit key bindings"); + return _(TOP_HEADER_PREFIX "Edit key bindings"); snprintf(buf, BUFSIZE, - TOP_HEADER_PREFIX "Edit keys for %s", + _(TOP_HEADER_PREFIX "Edit keys for %s"), cmds[subcmd].name); return buf; } diff --git a/src/screen_play.c b/src/screen_play.c index cdec4f77e..b4ff58cbe 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -22,6 +22,7 @@ #include #include "config.h" +#include "ncmpc.h" #include "options.h" #include "support.h" #include "libmpdclient.h" @@ -32,12 +33,6 @@ #include "screen_file.h" #include "screen_play.h" -#ifdef DEBUG -#define D(x) x -#else -#define D(x) -#endif - #define BUFSIZE 256 static list_window_t *lw = NULL; @@ -93,7 +88,7 @@ handle_save_playlist(screen_t *screen, mpd_client_t *c) { char *filename, *filename_utf8; - filename=screen_getstr(screen->status_window.w, "Save playlist as: "); + filename=screen_getstr(screen->status_window.w, _("Save playlist as: ")); filename=trim(filename); if( filename==NULL || filename[0]=='\0' ) return -1; @@ -113,13 +108,14 @@ handle_save_playlist(screen_t *screen, mpd_client_t *c) g_free(str); } else - screen_status_printf("Error: Unable to save playlist as %s", filename); + screen_status_printf(_("Error: Unable to save playlist as %s"), + filename); mpd_clearError(c->connection); beep(); return -1; } /* success */ - screen_status_printf("Saved %s", filename); + screen_status_printf(_("Saved %s"), filename); g_free(filename); /* update the file list if it has been initalized */ if( c->filelist ) @@ -155,7 +151,7 @@ play_exit(void) static char * play_title(void) { - return (TOP_HEADER_PREFIX "Playlist"); + return _(TOP_HEADER_PREFIX "Playlist"); } static void @@ -340,7 +336,7 @@ playlist_delete_song(mpd_client_t *c, int index) return -1; /* print a status message */ - screen_status_printf("Removed \'%s\' from playlist!", + screen_status_printf(_("Removed \'%s\' from playlist!"), mpc_get_song_name(song)); /* clear selected highlight in the browse screen */ file_set_highlight(c, song, 0); diff --git a/src/screen_utils.c b/src/screen_utils.c index f8dfa4c1d..080b118b1 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -23,6 +23,7 @@ #include #include "config.h" +#include "ncmpc.h" #include "libmpdclient.h" #include "mpc.h" #include "support.h" @@ -32,8 +33,8 @@ #include "colors.h" #include "screen.h" -#define FIND_PROMPT "Find: " -#define RFIND_PROMPT "Find backward: " +#define FIND_PROMPT _("Find: ") +#define RFIND_PROMPT _("Find backward: ") int screen_getch(WINDOW *w, char *prompt) @@ -140,7 +141,7 @@ screen_find(screen_t *screen, } else { - screen_status_printf("Unable to find \'%s\'", screen->findbuf); + screen_status_printf(_("Unable to find \'%s\'"), screen->findbuf); beep(); } return 1; diff --git a/src/support.c b/src/support.c index d292e8462..8cb4ecafd 100644 --- a/src/support.c +++ b/src/support.c @@ -23,18 +23,13 @@ #include #include "config.h" +#include "ncmpc.h" #include "support.h" #ifdef HAVE_LOCALE_H #include #endif -#ifdef DEBUG -#define D(x) x -#else -#define D(x) -#endif - #define BUFSIZE 1024 extern void screen_status_printf(char *format, ...); @@ -174,7 +169,7 @@ utf8_to_locale(char *utf8str) &error); if( error ) { - screen_status_printf("Error: Unable to convert characters to %s", + screen_status_printf(_("Error: Unable to convert characters to %s"), charset); D(g_printerr("utf8_to_locale(): %s\n", error->message)); g_error_free(error); @@ -203,7 +198,7 @@ locale_to_utf8(char *localestr) &error); if( error ) { - screen_status_printf("Error: Unable to convert characters to UTF-8"); + screen_status_printf(_("Error: Unable to convert characters to UTF-8")); D(g_printerr("locale_to_utf8: %s\n", error->message)); g_error_free(error); return g_strdup(localestr); -- cgit v1.2.3