1
1
/**************************************************************************
3
(C) 2008 - 2011 Alexander Shaduri <ashaduri 'at' gmail.com>
3
(C) 2008 - 2012 Alexander Shaduri <ashaduri 'at' gmail.com>
4
4
License: See LICENSE_zlib.txt file
5
5
***************************************************************************/
7
/// \author Alexander Shaduri
10
15
#include "hz_config.h" // feature macros
13
// Gettext bridge for internationalization. Sort of like gettext.h,
14
// but a lot simpler / lighter.
15
// This file is for internal use in hz. The application is expected
16
// to use gettext.h or similar mechanisms.
20
Gettext bridge for internationalization. Sort of like gettext.h,
21
but a lot simpler / lighter.
22
This file is for internal use in hz. The application is expected
23
to use gettext.h or similar mechanisms.
18
// Note: If you are using UTF-8 to display messages in your application
19
// but system locale is not UTF-8, then you need to call gettext's
20
// bind_textdomain_codeset(package, "UTF-8");
21
// to enable locale -> UTF-8 conversion for translated messages.
25
Note: If you are using UTF-8 to display messages in your application
26
but system locale is not UTF-8, then you need to call gettext's
27
bind_textdomain_codeset(package, "UTF-8");
28
to enable locale -> UTF-8 conversion for translated messages.
27
// Usually NLS can be disabled through the configure --disable-nls option.
36
/// Defined to 0 or 1. If 1, enable native language support.
37
/// Usually NLS can be disabled through the configure --disable-nls option.
28
38
#if defined ENABLE_NLS && ENABLE_NLS
30
40
#include <libintl.h> // gettext functions
67
77
// ------- Mark and translate
69
// The main gettext function. Marks and translates at runtime.
70
// You need to pass --keyword=HZ__ to xgettext when extracting messages.
79
/// The main gettext function. Marks and translates at runtime.
80
/// You need to pass --keyword=HZ__ to xgettext when extracting messages.
71
81
#define HZ__(String) gettext(String)
73
// Same as above, but specifies a context too, to e.g.
74
// disambiguate two "Open" menu entries as ("File", "Open") and ("Printer", "Open").
75
// You MUST pass --keyword=C_:1c,2 to xgettext when extracting messages.
83
/// Same as HZ__(), but specifies a context too, to e.g.
84
/// disambiguate two "Open" menu entries as ("File", "Open") and ("Printer", "Open").
85
/// You MUST pass --keyword=C_:1c,2 to xgettext when extracting messages.
76
86
#define HZ_C_(Context, String) i18n_C_helper((Context "\004" String), (String))
79
89
// ------- Mark only
81
// The no-op marking of a string for translation.
82
// You MUST pass --keyword=HZ_N_ to xgettext when extracting messages.
91
/// The no-op marking of a string for translation.
92
/// You MUST pass --keyword=HZ_N_ to xgettext when extracting messages.
83
93
#define HZ_N_(String) (String)
85
// Same as above, but accepts context too.
86
// --keyword=HZ_NC_:1c,2
95
/// Same as HZ_N_(), but accepts context too.
96
/// --keyword=HZ_NC_:1c,2
87
97
#define HZ_NC_(Context, String) (String)
90
100
// ------- Translate only
92
// Translate a dynamic string.
102
/// Translate a dynamic string.
93
103
#define HZ_R_(String) gettext(String)
95
// Same as above, but accepts context too.
105
/// Same as HZ_R_(), but accepts context too.
96
106
#define HZ_RC_(Context, String) i18n_R_helper((Context), (String))