From 1cf900257c53220308faef51a94a52f4db01173d Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Thu, 28 Jan 2010 19:25:22 +0200 Subject: [PATCH] module_gettext: translate a string in the text domain of a module This is needed for out-of-tree modules. We need to translate their plugin descriptor strings from their domain. --- include/vlc_modules.h | 1 + src/libvlccore.sym | 1 + src/modules/modules.c | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/include/vlc_modules.h b/include/vlc_modules.h index 8c91e71a8a..5c250bf12a 100644 --- a/include/vlc_modules.h +++ b/include/vlc_modules.h @@ -52,6 +52,7 @@ VLC_EXPORT( const char *, module_get_name, ( const module_t *m, bool long_name ) VLC_EXPORT( const char *, module_get_help, ( const module_t *m ) ); VLC_EXPORT( const char *, module_get_capability, ( const module_t *m ) ); VLC_EXPORT( int, module_get_score, ( const module_t *m ) ); +VLC_EXPORT( const char *, module_gettext, ( const module_t *, const char * ) ); static inline module_t *module_get_main (void) { diff --git a/src/libvlccore.sym b/src/libvlccore.sym index 55caa496bd..2bcc20c61c 100644 --- a/src/libvlccore.sym +++ b/src/libvlccore.sym @@ -237,6 +237,7 @@ module_get_help module_get_name module_get_object module_get_score +module_gettext module_hold module_list_free module_list_get diff --git a/src/modules/modules.c b/src/modules/modules.c index 27e5254cc0..8c4d009e0d 100644 --- a/src/modules/modules.c +++ b/src/modules/modules.c @@ -49,6 +49,9 @@ #ifdef HAVE_UNISTD_H # include #endif +#ifdef ENABLE_NLS +# include +#endif #include "config/configuration.h" @@ -293,6 +296,24 @@ int module_get_score( const module_t *m ) return m->i_score; } +/** + * Translate a string using the module's text domain + * + * \param m the module + * \param str the American English ASCII string to localize + * \return the gettext-translated string + */ +const char *module_gettext (const module_t *m, const char *str) +{ +#ifdef ENABLE_NLS + const char *domain = m->domain ? m->domain : PACKAGE_NAME; + return dgettext (domain, str); +#else + (void)m; + return str; +#endif +} + module_t *module_hold (module_t *m) { vlc_hold (&m->vlc_gc_data); -- 2.39.5