]> git.sesse.net Git - vlc/blobdiff - src/modules/modules.c
module_gettext: translate a string in the text domain of a module
[vlc] / src / modules / modules.c
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);