From ee98209ab84a338525e0dde9f62633bcf0b08078 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Tue, 12 Jan 2010 12:16:00 +0200 Subject: translations: add infrastructure for translated OSD messages Add function set_osd_tmsg() which is a version of set_osd_msg that translates its format argument. Pass OSD message strings in the command.c property_osd_display table through mp_gtext before they're used. --- mplayer.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index ac97aed389..2668bd07f0 100644 --- a/mplayer.c +++ b/mplayer.c @@ -1356,10 +1356,10 @@ static mp_osd_msg_t* osd_msg_stack = NULL; * it is pulled on top of the stack, otherwise a new message is created. * */ - -void set_osd_msg(int id, int level, int time, const char* fmt, ...) { +static void set_osd_msg_va(int id, int level, int time, const char *fmt, + va_list ap) +{ mp_osd_msg_t *msg,*last=NULL; - va_list va; int r; // look if the id is already in the stack @@ -1376,9 +1376,7 @@ void set_osd_msg(int id, int level, int time, const char* fmt, ...) { osd_msg_stack = msg; } // write the msg - va_start(va,fmt); - r = vsnprintf(msg->msg, 128, fmt, va); - va_end(va); + r = vsnprintf(msg->msg, 128, fmt, ap); if(r >= 128) msg->msg[127] = 0; // set id and time msg->id = id; @@ -1387,6 +1385,23 @@ void set_osd_msg(int id, int level, int time, const char* fmt, ...) { } +void set_osd_msg(int id, int level, int time, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + set_osd_msg_va(id, level, time, fmt, ap); + va_end(ap); +} + +void set_osd_tmsg(int id, int level, int time, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + set_osd_msg_va(id, level, time, mp_gtext(fmt), ap); + va_end(ap); +} + + /** * \brief Remove a message from the OSD stack * -- cgit v1.2.3