[vlc-devel] commit: module_gettext: translate a string in the text domain of a module ( Rémi Denis-Courmont )
git version control
git at videolan.org
Thu Jan 28 19:00:03 CET 2010
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jan 28 19:25:22 2010 +0200| [1cf900257c53220308faef51a94a52f4db01173d] | committer: 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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1cf900257c53220308faef51a94a52f4db01173d
---
include/vlc_modules.h | 1 +
src/libvlccore.sym | 1 +
src/modules/modules.c | 21 +++++++++++++++++++++
3 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/include/vlc_modules.h b/include/vlc_modules.h
index 8c91e71..5c250bf 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 55caa49..2bcc20c 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 27e5254..8c4d009 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -49,6 +49,9 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
+#ifdef ENABLE_NLS
+# include <libintl.h>
+#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);
More information about the vlc-devel
mailing list