Freeciv21
Develop your civilization from humble roots to a global empire
fcintl.h
Go to the documentation of this file.
1 /*__ ___ ***************************************
2 / \ / \ Copyright (c) 1996-2020 Freeciv21 and Freeciv
3 \_ \ / __/ contributors. This file is part of Freeciv21.
4  _\ \ / /__ Freeciv21 is free software: you can redistribute it
5  \___ \____/ __/ and/or modify it under the terms of the GNU General
6  \_ _/ Public License as published by the Free Software
7  | @ @ \_ Foundation, either version 3 of the License,
8  | or (at your option) any later version.
9  _/ /\ You should have received a copy of the GNU
10  /o) (o/\ \_ General Public License along with Freeciv21.
11  \_____/ / If not, see https://www.gnu.org/licenses/.
12  \____/ ********************************************************/
13 #pragma once
14 
15 #include "fc_config.h" // FREECIV_ENABLE_NLS
16 #include "support.h" // fc__attribute
17 
18 #ifdef FREECIV_ENABLE_NLS
19 
20 /* Include libintl.h only if nls enabled.
21  * It defines some wrapper macros that
22  * we don't want defined when nls is disabled. */
23 #include <libintl.h>
24 
25 // MSYS libintl redefines asprintf/vasprintf as macros, and this clashes with
26 // QString::asprintf and QString::vasprintf.
27 #ifdef asprintf
28 #undef asprintf
29 #endif
30 
31 #ifdef vasprintf
32 #undef vasprintf
33 #endif
34 
35 // Core freeciv
36 #define _(String) gettext(String)
37 #define DG_(domain, String) dgettext(domain, String)
38 #define N_(String) String
39 #define Q_(String) skip_intl_qualifier_prefix(gettext(String))
40 #define PL_(String1, String2, n) ngettext((String1), (String2), (n))
41 
42 // Ruledit
43 #define R__(String) dgettext("freeciv-ruledit", String)
44 #define RQ_(String) \
45  skip_intl_qualifier_prefix(dgettext("freeciv-ruledit", String))
46 
47 #else // FREECIV_ENABLE_NLS
48 
49 // Core freeciv
50 #define _(String) (String)
51 #define DG_(domain, String) (String)
52 #define N_(String) String
53 #define Q_(String) skip_intl_qualifier_prefix(String)
54 #define PL_(String1, String2, n) ((n) == 1 ? (String1) : (String2))
55 #define C_(String) capitalized_string(String)
56 
57 // Ruledit
58 #define R__(String) (String)
59 #define RQ_(String) skip_intl_qualifier_prefix(String)
60 
61 #endif // FREECIV_ENABLE_NLS
62 
63 /* This provides an untranslated version of Q_ that allows the caller to
64  * get access to the original string. This may be needed for comparisons,
65  * for instance. */
66 #define Qn_(String) skip_intl_qualifier_prefix(String)
67 
68 const char *skip_intl_qualifier_prefix(const char *str)
69  fc__attribute((__format_arg__(1)));
70 
71 char *capitalized_string(const char *str);
72 void free_capitalized(char *str);
73 void capitalization_opt_in(bool opt_in);
75 
76 const char *get_locale_dir();
const char * get_locale_dir()
Return directory containing locales.
Definition: fcintl.cpp:94
const char * skip_intl_qualifier_prefix(const char *str) fc__attribute((__format_arg__(1)))
Some strings are ambiguous for translation.
Definition: fcintl.cpp:39
char * capitalized_string(const char *str)
This function tries to capitalize first letter of the string.
Definition: fcintl.cpp:57
void free_capitalized(char *str)
Free capitalized string.
Definition: fcintl.cpp:75
void capitalization_opt_in(bool opt_in)
Translation opts in to automatic capitalization features.
Definition: fcintl.cpp:84
bool is_capitalization_enabled()
Automatic capitalization features requested.
Definition: fcintl.cpp:89
int fc__attribute((nonnull(1, 3)))