The Battle for Wesnoth
1.13.4+dev
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
gettext.hpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2003 - 2016 by David White <
[email protected]
>
3
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
4
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY.
11
12
See the COPYING file for more details.
13
*/
14
15
#ifndef GETTEXT_HPP_INCLUDED
16
#define GETTEXT_HPP_INCLUDED
17
18
/**
19
* How to use gettext for wesnoth source files:
20
* -# include this header file in the .cpp file
21
* -# make sure, that the source file is listed in the respective POTFILES.in
22
* for the textdomain, in the case of wesnoth-lib it is this file:
23
* po/wesnoth-lib/POTFILES.in
24
* -# add the following include to set the correct textdomain, in this example
25
* wesnoth-lib (not required for the domain 'wesnoth', required for all
26
* other textdomains).
27
* @code
28
* #define GETTEXT_DOMAIN "wesnoth-lib"
29
* @endcode
30
*
31
* This should be all that is required to have your strings that are marked
32
* translatable in the po files and translated ingame. So you at least have
33
* to mark the strings translatable, too. ;)
34
*/
35
36
// gettext-related declarations
37
#include "
wesconfig.h
"
38
#include <string>
39
#include <vector>
40
41
#ifndef GETTEXT_DOMAIN
42
# define GETTEXT_DOMAIN PACKAGE
43
#endif
44
45
//A Hack to make the eclipse-cdt parser happy.
46
#ifdef __CDT_PARSER__
47
# define GETTEXT_DOMAIN ""
48
#endif
49
50
#if defined(__GNUCC__) || defined(__clang__) || defined(__MINGW32__)
51
#define UNUSEDNOWARN __attribute__((unused))
52
#else
53
#define UNUSEDNOWARN
54
#endif
55
56
namespace
translation
57
{
58
std::string
dgettext
(
const
char
* domain,
const
char
* msgid);
59
std::string
egettext
(
const
char
*);
60
std::string
dsgettext
(
const
char
* domainname,
const
char
*msgid);
61
//const char* sngettext(const char *singular, const char *plural, int n);
62
std::string
dsngettext
(
const
char
* domainname,
const
char
*singular,
const
char
*plural,
int
n
);
63
64
inline
UNUSEDNOWARN
static
std::string
gettext
(
const
char
* str)
65
{
return
translation::dgettext
(
GETTEXT_DOMAIN
, str); }
66
inline
UNUSEDNOWARN
static
std::string
sgettext
(
const
char
* str)
67
{
return
translation::dsgettext
(
GETTEXT_DOMAIN
, str); }
68
inline
UNUSEDNOWARN
static
std::string
sngettext
(
const
char
* str1,
const
char
* str2,
int
n)
69
{
return
translation::dsngettext
(
GETTEXT_DOMAIN
, str1, str2 , n); }
70
71
72
void
bind_textdomain
(
const
char
* domain,
const
char
* directory,
const
char
* encoding);
73
void
set_default_textdomain
(
const
char
* domain);
74
75
void
set_language
(
const
std::string
&
language
,
const
std::vector<std::string>* alternates);
76
77
void
init
();
78
int
compare
(
const
std::string
& s1,
const
std::string
& s2);
79
}
80
81
//#define _(String) translation::dsgettext(GETTEXT_DOMAIN,String)
82
inline
static
UNUSEDNOWARN
std::string
_
(
const
char
* str)
83
{
return
translation::dsgettext
(
GETTEXT_DOMAIN
, str); }
84
85
//#define _n(String1, String2, Int) translation::dsngettext(GETTEXT_DOMAIN, String1,String2,Int)
86
inline
UNUSEDNOWARN
static
std::string
_n
(
const
char
* str1,
const
char
* str2,
int
n
)
87
{
return
translation::dsngettext
(
GETTEXT_DOMAIN
, str1, str2, n); }
88
89
#define gettext_noop(String) String
90
#define N_(String) gettext_noop (String)
91
92
#endif
UNUSEDNOWARN
#define UNUSEDNOWARN
Definition:
gettext.hpp:53
translation::compare
int compare(const std::string &s1, const std::string &s2)
Definition:
gettext_boost.cpp:270
translation::dsngettext
std::string dsngettext(const char *domainname, const char *singular, const char *plural, int n)
Definition:
gettext.cpp:91
translation::dgettext
std::string dgettext(const char *domain, const char *msgid)
Definition:
gettext.cpp:39
translation::init
void init()
Definition:
gettext.cpp:189
translation::set_language
void set_language(const std::string &slocale, const std::vector< std::string > *alternates)
Definition:
gettext.cpp:126
translation
Definition:
gettext.cpp:37
translation::dsgettext
std::string dsgettext(const char *domainname, const char *msgid)
Definition:
gettext.cpp:48
translation::bind_textdomain
void bind_textdomain(const char *domain, const char *directory, const char *encoding)
Definition:
gettext.cpp:105
_
static UNUSEDNOWARN std::string _(const char *str)
Definition:
gettext.hpp:82
_n
static UNUSEDNOWARN std::string _n(const char *str1, const char *str2, int n)
Definition:
gettext.hpp:86
translation::set_default_textdomain
void set_default_textdomain(const char *domain)
Definition:
gettext.cpp:121
translation::gettext
static UNUSEDNOWARN std::string gettext(const char *str)
Definition:
gettext.hpp:64
translation::egettext
std::string egettext(char const *msgid)
Definition:
gettext.cpp:43
wesconfig.h
Some defines: VERSION, PACKAGE, MIN_SAVEGAME_VERSION.
GETTEXT_DOMAIN
#define GETTEXT_DOMAIN
How to use gettext for wesnoth source files:include this header file in the .cpp filemake sure...
Definition:
gettext.hpp:42
preferences::language
std::string language()
Definition:
preferences.cpp:458
n
GLclampd n
Definition:
glew.h:5903
translation::sgettext
static UNUSEDNOWARN std::string sgettext(const char *str)
Definition:
gettext.hpp:66
translation::sngettext
static UNUSEDNOWARN std::string sngettext(const char *str1, const char *str2, int n)
Definition:
gettext.hpp:68
string
GLsizei const GLcharARB ** string
Definition:
glew.h:4503
Generated by
1.8.8