Adonthell  0.4
nls.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002/2016 Kai Sterker <kai.sterker@gmail.com>
3  Part of the Adonthell Project <http://adonthell.nongnu.org>
4 
5  Adonthell 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 
10  Adonthell is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with Adonthell. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 /**
20  * @file nls.h
21  *
22  * @author Kai Sterker
23  * @brief National Language Support
24  */
25 
26 #ifndef __NLS_H__
27 #define __NLS_H__
28 
29 #include "prefs.h"
30 
31 #ifndef SWIG
32 using std::string;
33 #endif
34 
35 /**
36  * Provides various services for i18n and l10n.
37  */
38 class nls
39 {
40 public:
41  /**
42  * Initialize national language support.
43  * @param myconfig The Engine's configuration
44  */
45  static void init (config &myconfig);
46 
47  /**
48  * Set or change the language to use. Setting the language will
49  * never fail, but only if there is a binary message catalogue
50  * in <gamedir>/po/<country code>LC_MESSAGES/ named <gamename>.mo
51  * the desired language will be actually used.
52  * @param language The country code of the desired language.
53  */
54  static void set_language (const string &language);
55 
56  /**
57  * Translate the given string if it's found in the message
58  * catalogue. This is just a wrapper around the GNU gettext
59  * function for older versions of Python.
60  * @param text The text to translate
61  * @return either the translated text, or the given text if
62  * no translation was found.
63  */
64  static const string translate (const string &text);
65 
66 private:
67 #ifndef SWIG
68  /** current content of the LANGUAGE environment variable */
69  static std::string current_lang;
70 #endif
71 };
72 
73 #endif // __NLS_H__
Adonthell&#39;s configuration.
static void init(config &myconfig)
Initialize national language support.
Definition: nls.cc:37
static const string translate(const string &text)
Translate the given string if it&#39;s found in the message catalogue.
Definition: nls.cc:76
static void set_language(const string &language)
Set or change the language to use.
Definition: nls.cc:59
Provides various services for i18n and l10n.
Definition: nls.h:38
This class contains the engine&#39;s configuration read either from the config file or from the command l...
Definition: prefs.h:74