aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltrans.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/lltrans.h')
-rw-r--r--linden/indra/newview/lltrans.h92
1 files changed, 92 insertions, 0 deletions
diff --git a/linden/indra/newview/lltrans.h b/linden/indra/newview/lltrans.h
new file mode 100644
index 0000000..eb159f2
--- /dev/null
+++ b/linden/indra/newview/lltrans.h
@@ -0,0 +1,92 @@
1/**
2 * @file lltrans.h
3 * @brief LLTrans definition
4 *
5 * $LicenseInfo:firstyear=2000&license=viewergpl$
6 *
7 * Copyright (c) 2000-2008, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LL_TRANS_H
33#define LL_TRANS_H
34
35#include <map>
36
37/**
38 * @brief String template loaded from strings.xml
39 */
40class LLTransTemplate
41{
42public:
43 LLTransTemplate(const LLString& name = "", const LLString& text = "") : mName(name), mText(text) {}
44
45 LLString mName;
46 LLString mText;
47};
48
49/**
50 * @brief Localized strings class
51 * This class is used to retrieve translations of strings used to build larger ones, as well as
52 * strings with a general usage that don't belong to any specific floater. For example,
53 * "Owner:", "Retrieving..." used in the place of a not yet known name, etc.
54 */
55class LLTrans
56{
57public:
58 LLTrans();
59
60 /**
61 * @brief Parses the xml file that holds the strings. Used once on startup
62 * @param xml_filename Filename to parse
63 * @returns true if the file was parsed successfully, true if something went wrong
64 */
65 static bool parseStrings(const LLString& xml_filename);
66
67 /**
68 * @brief Returns a translated string
69 * @param xml_desc String's description
70 * @param args A list of substrings to replace in the string
71 * @returns Translated string
72 */
73 static LLString getString(const LLString &xml_desc, const LLString::format_map_t& args);
74
75 /**
76 * @brief Returns a translated string
77 * @param xml_desc String's description
78 * @returns Translated string
79 */
80 static LLString getString(const LLString &xml_desc)
81 {
82 LLString::format_map_t empty;
83 return getString(xml_desc, empty);
84 }
85
86
87private:
88 typedef std::map<LLString, LLTransTemplate > template_map_t;
89 static template_map_t sStringTemplates;
90};
91
92#endif