blob: 892a3ed0b6ad674e30ba26a48825b3b504e3862a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
/******************************************************************************
* localemgr.h - definition of class LocaleMgr used to interact with
* registered locales for a sword installation
*
* $Id: localemgr.h,v 1.12 2002/10/01 22:04:58 dglassey Exp $
*
* Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
* P. O. Box 2528
* Tempe, AZ 85280-2528
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
*/
#ifndef LOCALEMGR_H
#define LOCALEMGR_H
#include <string>
#include <map>
#include <list>
#include <swconfig.h>
#include <swlocale.h>
#include <defs.h>
SWORD_NAMESPACE_START
typedef std::map < std::string, SWLocale *, std::less < std::string > >LocaleMap;
/**
* The LocaleMgr class handles all the different locales of Sword.
* It provides functions to get a list of all available locales,
* to get the default locale name and to get it.
* The other functions are not interesting for frontend programmers.
*
* To get the default locale name use @see getDefaultLocaleName
* To set the default locale name use @see setDefaultLocaleName
* To get the locale for a language name use @see getLocale
* To get a list of availble locales use @see getAvailableLocales
*/
class SWDLLEXPORT LocaleMgr
{
private:
void deleteLocales ();
char *defaultLocaleName;
protected:
LocaleMap locales;
public:
/** Default constructor of LocaleMgr
* You do normally not need this constructor, use LocaleMgr::systemLocaleMgr instead.
*/
LocaleMgr (const char *iConfigPath = 0);
/**
* Default destructor of LocaleMgr
*/
virtual ~ LocaleMgr ();
/** Get the locale connected with the name "name".
*
* @param name The name of the locale you want to have. For example use getLocale("de") to get the locale for the German language.
* @return Returns the locale object if the locale with the name given as parameter was found. If it wasn't found return NULL.
*/
virtual SWLocale *getLocale (const char *name);
/** Get the list of available locales.
*
* @ret Returns a list of strings, which contains the names of the available locales.
*/
virtual std::list < std::string > getAvailableLocales ();
/** Returns translated text.
* This function uses both parameters to return the translated version of the given text.
*
* @param The text to translate into the language given by the first parameter.
* @param localeName The name of the locale Sword should use
* @return Returns the translated text.
*/
virtual const char *translate (const char *text, const char *localeName = 0);
/** Get the default locale name. To set it use @see setDefaultLocaleName
*
* @ret Returns the default locale name
*/
virtual const char *getDefaultLocaleName ();
/** Set the new standard locale of Sword.
*
* @param name The name of the new default locale
*/
virtual void setDefaultLocaleName (const char *name);
/** The LocaleMgr object used globally in the Sword world.
* Do not create your own LocaleMgr, use this static object instead.
*/
static LocaleMgr systemLocaleMgr;
/** Augment this localmgr with all locale.conf files in a directory
*/
virtual void loadConfigDir(const char *ipath);
};
SWORD_NAMESPACE_END
#endif
|