PipeWire  0.3.33
build-12683127/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
29 extern "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
43 struct 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 
71 /* static */ inline const char *
72 spa_i18n_text(struct spa_i18n *i18n, const char *msgid)
73 {
74  const char *res = msgid;
75  if (SPA_LIKELY(i18n != NULL))
77  struct spa_i18n_methods, res,
78  text, 0, msgid);
79  return res;
80 }
81 
82 /* static */ inline const char *
83 spa_i18n_ntext(struct spa_i18n *i18n, const char *msgid,
84  const char *msgid_plural, unsigned long int n)
85 {
86  const char *res = n == 1 ? msgid : msgid_plural;
87  if (SPA_LIKELY(i18n != NULL))
89  struct spa_i18n_methods, res,
90  ntext, 0, msgid, msgid_plural, n);
91  return res;
92 }
93 
98 #ifdef __cplusplus
99 } /* extern "C" */
100 #endif
101 
102 #endif /* SPA_I18N_H */
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:208
spa_interface
Definition: hook.h:146
spa_i18n_ntext
const char * spa_i18n_ntext(struct spa_i18n *i18n, const char *msgid, const char *msgid_plural, unsigned long int n)
Definition: build-12683127/doc/spa/support/i18n.h:83
spa_i18n_methods
Definition: build-12683127/doc/spa/support/i18n.h:45
spa_i18n
Definition: build-12683127/doc/spa/support/i18n.h:43
SPA_LIKELY
#define SPA_LIKELY(x)
Definition: defs.h:234
spa_i18n_methods::version
uint32_t version
Definition: build-12683127/doc/spa/support/i18n.h:47
spa_i18n_text
const char * spa_i18n_text(struct spa_i18n *i18n, const char *msgid)
Definition: build-12683127/doc/spa/support/i18n.h:72
defs.h
spa_i18n::iface
struct spa_interface iface
Definition: build-12683127/doc/spa/support/i18n.h:43
hook.h