PipeWire 1.0.4
Loading...
Searching...
No Matches
i18n.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2021 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_I18N_H
6#define SPA_I18N_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
12#include <spa/utils/hook.h>
13#include <spa/utils/defs.h>
14
24#define SPA_TYPE_INTERFACE_I18N SPA_TYPE_INFO_INTERFACE_BASE "I18N"
25
26#define SPA_VERSION_I18N 0
27struct spa_i18n { struct spa_interface iface; };
28
29struct spa_i18n_methods {
30#define SPA_VERSION_I18N_METHODS 0
31 uint32_t version;
32
40 const char *(*text) (void *object, const char *msgid);
41
51 const char *(*ntext) (void *object, const char *msgid,
52 const char *msgid_plural, unsigned long int n);
53};
54
56static inline const char *
57spa_i18n_text(struct spa_i18n *i18n, const char *msgid)
58{
59 const char *res = msgid;
60 if (SPA_LIKELY(i18n != NULL))
61 spa_interface_call_res(&i18n->iface,
62 struct spa_i18n_methods, res,
63 text, 0, msgid);
64 return res;
66
67static inline const char *
68spa_i18n_ntext(struct spa_i18n *i18n, const char *msgid,
69 const char *msgid_plural, unsigned long int n)
70{
71 const char *res = n == 1 ? msgid : msgid_plural;
72 if (SPA_LIKELY(i18n != NULL))
74 struct spa_i18n_methods, res,
75 ntext, 0, msgid, msgid_plural, n);
76 return res;
77}
78
83#ifdef __cplusplus
84} /* extern "C" */
85#endif
86
87#endif /* SPA_I18N_H */
spa/utils/defs.h
static const char * spa_i18n_ntext(struct spa_i18n *i18n, const char *msgid, const char *msgid_plural, unsigned long int n)
Definition i18n.h:76
static const char * spa_i18n_text(struct spa_i18n *i18n, const char *msgid)
Definition i18n.h:65
#define spa_interface_call_res(iface, method_type, res, method, vers,...)
Invoke method named method in the callbacks on the given interface object.
Definition hook.h:251
#define SPA_LIKELY(x)
Definition defs.h:349
#define SPA_FORMAT_ARG_FUNC(arg1)
Definition defs.h:279
spa/utils/hook.h
Definition i18n.h:36
uint32_t version
Definition i18n.h:39
Definition i18n.h:34
struct spa_interface iface
Definition i18n.h:34
Definition hook.h:138