]> git.sesse.net Git - vlc/commitdiff
module_gettext: translate a string in the text domain of a module
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 28 Jan 2010 17:25:22 +0000 (19:25 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 28 Jan 2010 17:50:13 +0000 (19:50 +0200)
This is needed for out-of-tree modules. We need to translate their
plugin descriptor strings from their domain.

include/vlc_modules.h
src/libvlccore.sym
src/modules/modules.c

index 8c91e71a8a1de2528271d6e626616bfee2a76dcc..5c250bf12a95776cfc3a65b2ce26cf5f2fae170f 100644 (file)
@@ -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)
 {
index 55caa496bdb232880ef69b98af9da29e5eca72dd..2bcc20c61cb5cb88a93b23bb765e06f50edb259e 100644 (file)
@@ -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
index 27e5254cc000cc1f27ecb6b36249bec3c8c7c756..8c4d009e0d5a4417228ebf137d2707d531e74571 100644 (file)
@@ -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);