PipeWire 0.3.38
aarch64-kylin-linux-gnu/doc/spa/support/i18n.h
Go to the documentation of this file.
1/* Simple Plugin API
2 *
3 * Copyright © 2021 Wim Taymans
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#ifndef SPA_I18N_H
26#define SPA_I18N_H
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <spa/utils/hook.h>
33#include <spa/utils/defs.h>
34
40#define SPA_TYPE_INTERFACE_I18N SPA_TYPE_INFO_INTERFACE_BASE "I18N"
41
42#define SPA_VERSION_I18N 0
43struct spa_i18n { struct spa_interface iface; };
44
46#define SPA_VERSION_I18N_METHODS 0
47 uint32_t version;
48
56 const char *(*text) (void *object, const char *msgid);
57
67 const char *(*ntext) (void *object, const char *msgid,
68 const char *msgid_plural, unsigned long int n);
69};
70
72/* static */ inline const char *
73spa_i18n_text(struct spa_i18n *i18n, const char *msgid)
74{
75 const char *res = msgid;
76 if (SPA_LIKELY(i18n != NULL))
77 spa_interface_call_res(&i18n->iface,
78 struct spa_i18n_methods, res,
79 text, 0, msgid);
80 return res;
81}
82
83/* static */ inline const char *
84spa_i18n_ntext(struct spa_i18n *i18n, const char *msgid,
85 const char *msgid_plural, unsigned long int n)
86{
87 const char *res = n == 1 ? msgid : msgid_plural;
88 if (SPA_LIKELY(i18n != NULL))
90 struct spa_i18n_methods, res,
91 ntext, 0, msgid, msgid_plural, n);
92 return res;
93}
94
99#ifdef __cplusplus
100} /* extern "C" */
101#endif
102
103#endif /* SPA_I18N_H */
#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:226
const char * spa_i18n_ntext(struct spa_i18n *i18n, const char *msgid, const char *msgid_plural, unsigned long int n)
Definition: aarch64-kylin-linux-gnu/doc/spa/support/i18n.h:84
const char * spa_i18n_text(struct spa_i18n *i18n, const char *msgid)
Definition: aarch64-kylin-linux-gnu/doc/spa/support/i18n.h:73
#define SPA_LIKELY(x)
Definition: defs.h:241
SPA_FORMAT_ARG_FUNC(1) const char *pw_gettext(const char *msgid)
const char * msgid_plural
Definition: src/pipewire/i18n.h:35
const char unsigned long int n
Definition: src/pipewire/i18n.h:35
Definition: aarch64-kylin-linux-gnu/doc/spa/support/i18n.h:45
uint32_t version
Definition: aarch64-kylin-linux-gnu/doc/spa/support/i18n.h:47
Definition: aarch64-kylin-linux-gnu/doc/spa/support/i18n.h:43
struct spa_interface iface
Definition: aarch64-kylin-linux-gnu/doc/spa/support/i18n.h:43
Definition: hook.h:149