diff --git a/src/pipewire/pipewire.c b/src/pipewire/pipewire.c index d845fcdd7..a2441dd3b 100644 --- a/src/pipewire/pipewire.c +++ b/src/pipewire/pipewire.c @@ -36,8 +36,11 @@ #include #include +#include + #include #include +#include #include "pipewire.h" #include "private.h" @@ -72,6 +75,8 @@ struct support { const char *plugin_dir; const char *support_lib; struct registry *registry; + const char *i18n_domain; + struct spa_interface i18n_iface; struct spa_support support[MAX_SUPPORT]; uint32_t n_support; unsigned int in_valgrind:1; @@ -340,6 +345,35 @@ static void *add_interface(struct support *support, return iface; } +static const char *i18n_text(void *object, const char *msgid) +{ + struct support *support = object; + return dgettext(support->i18n_domain, msgid); +} + +static const char *i18n_ntext(void *object, const char *msgid, const char *msgid_plural, + unsigned long int n) +{ + struct support *support = object; + return dngettext(support->i18n_domain, msgid, msgid_plural, n); +} + +static void *add_i18n(struct support *support) +{ + static struct spa_i18n_methods i18n_methods = { + SPA_VERSION_I18N_METHODS, + .text = i18n_text, + .ntext = i18n_ntext, + }; + support->i18n_iface = SPA_INTERFACE_INIT( + SPA_TYPE_INTERFACE_I18N, + SPA_VERSION_I18N, + &i18n_methods, support); + support->support[support->n_support++] = + SPA_SUPPORT_INIT(SPA_TYPE_INTERFACE_I18N, &support->i18n_iface); + return 0; +} + #ifdef HAVE_SYSTEMD static struct spa_log *load_journal_logger(struct support *support) { @@ -459,6 +493,9 @@ void pw_init(int *argc, char **argv[]) info = SPA_DICT_INIT(items, n_items); add_interface(support, SPA_NAME_SUPPORT_CPU, SPA_TYPE_INTERFACE_CPU, &info); + + add_i18n(support); + pw_log_info("version %s", pw_get_library_version()); }