PipeWire: i18n.h Source File

PipeWire 0.3.71

Loading...
Searching...
No Matches
spa/include/spa/support/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
55 SPA_FORMAT_ARG_FUNC(2)
56static inline const char *
57 spa_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;
65}
66
67static inline const char *
68 spa_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))
73 spa_interface_call_res(&i18n->iface,
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 */
defs.h
spa/utils/defs.h
spa_i18n_ntext
static const char * spa_i18n_ntext(struct spa_i18n *i18n, const char *msgid, const char *msgid_plural, unsigned long int n)
Definition spa/include/spa/support/i18n.h:76
spa_i18n_text
static const char * spa_i18n_text(struct spa_i18n *i18n, const char *msgid)
Definition spa/include/spa/support/i18n.h:65
spa_interface_call_res
#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
SPA_LIKELY
#define SPA_LIKELY(x)
Definition defs.h:345
SPA_FORMAT_ARG_FUNC
#define SPA_FORMAT_ARG_FUNC(arg1)
Definition defs.h:275
hook.h
spa/utils/hook.h
spa_i18n_methods
Definition spa/include/spa/support/i18n.h:36
spa_i18n_methods::version
uint32_t version
Definition spa/include/spa/support/i18n.h:39
spa_i18n
Definition spa/include/spa/support/i18n.h:34
spa_i18n::iface
struct spa_interface iface
Definition spa/include/spa/support/i18n.h:34
spa_interface
Definition hook.h:138