naev 0.12.5
gettext.h
1/*
2 * See Licensing and Copyright notice in naev.h
3 */
4#pragma once
5
7#include <stddef.h>
8#include <stdint.h>
10
11#include "attributes.h"
12
13typedef struct LanguageOption_ {
14 char *language;
15 double coverage;
17
18void gettext_init( void );
19void gettext_exit( void );
20const char *gettext_getSystemLanguage( void );
21const char *gettext_getLanguage( void );
22void gettext_setLanguage( const char *lang );
24double gettext_languageCoverage( const char *lang );
25
26const char *gettext_ngettext( const char *msgid, const char *msgid_plural,
27 uint64_t n );
28FORMAT_ARG( 2 )
29const char *gettext_pgettext_impl( const char *lookup, const char *msgid );
30
39#define gettext_noop( String ) String
40
45FORMAT_ARG( 1 ) static inline const char *_( const char *msgid )
46{
47 return gettext_ngettext( msgid, NULL, 1 );
48}
49
51#define N_( msgid ) gettext_noop( msgid )
52
54FORMAT_ARG( 1 )
55static inline const char *n_( const char *msgid, const char *msgid_plural,
56 uint64_t n )
57{
58 return gettext_ngettext( msgid, msgid_plural, n );
59}
60
62#define GETTEXT_CONTEXT_GLUE "\004"
63
69#define p_( msgctxt, msgid ) \
70 gettext_pgettext_impl( msgctxt GETTEXT_CONTEXT_GLUE msgid, msgid )
71
75const char *pgettext_var( const char *msgctxt, const char *msgid );
const char * gettext_ngettext(const char *msgid, const char *msgid_plural, uint64_t n)
Return a translated version of the input, using the current language catalogs.
Definition gettext.c:238
void gettext_exit(void)
Free resources associated with the translation system. This invalidates previously returned pointers ...
Definition gettext.c:89
double gettext_languageCoverage(const char *lang)
Return the fraction of strings which have a translation into the given language.
Definition gettext.c:312
void gettext_setLanguage(const char *lang)
Set the translation language.
Definition gettext.c:135
const char * gettext_getLanguage(void)
Gets the active (primary) translation language. Even in case of a complex locale, this will be the na...
Definition gettext.c:122
const char * pgettext_var(const char *msgctxt, const char *msgid)
Definition gettext.c:346
LanguageOption * gettext_languageOptions(void)
List the available languages, with completeness statistics.
Definition gettext.c:289
const char * gettext_getSystemLanguage(void)
Gets the current system language as detected by Naev.
Definition gettext.c:110
void gettext_init(void)
Initialize the translation system. There's no presumption that PhysicsFS is available,...
Definition gettext.c:53
const char * gettext_pgettext_impl(const char *lookup, const char *msgid)
Helper function for p_(): Return _(lookup) with a fallback of msgid rather than lookup.
Definition gettext.c:259
char * language
Definition gettext.h:14
double coverage
Definition gettext.h:15