Commit 1cf90025 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

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.
parent e2828c39
...@@ -52,6 +52,7 @@ VLC_EXPORT( const char *, module_get_name, ( const module_t *m, bool long_name ) ...@@ -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_help, ( const module_t *m ) );
VLC_EXPORT( const char *, module_get_capability, ( 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( 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) static inline module_t *module_get_main (void)
{ {
......
...@@ -237,6 +237,7 @@ module_get_help ...@@ -237,6 +237,7 @@ module_get_help
module_get_name module_get_name
module_get_object module_get_object
module_get_score module_get_score
module_gettext
module_hold module_hold
module_list_free module_list_free
module_list_get module_list_get
......
...@@ -49,6 +49,9 @@ ...@@ -49,6 +49,9 @@
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
# include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef ENABLE_NLS
# include <libintl.h>
#endif
#include "config/configuration.h" #include "config/configuration.h"
...@@ -293,6 +296,24 @@ int module_get_score( const module_t *m ) ...@@ -293,6 +296,24 @@ int module_get_score( const module_t *m )
return m->i_score; 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) module_t *module_hold (module_t *m)
{ {
vlc_hold (&m->vlc_gc_data); vlc_hold (&m->vlc_gc_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment