diff options
author | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:50 -0500 |
commit | 2a4dea528f670b9bb1f77ef27a8a1dd16603d114 (patch) | |
tree | 95c68e362703c9099d571ecbdc6142b1cda1e005 /linden/indra/newview/lltrans.cpp | |
parent | Second Life viewer sources 1.20.6 (diff) | |
download | meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.zip meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.gz meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.bz2 meta-impy-2a4dea528f670b9bb1f77ef27a8a1dd16603d114.tar.xz |
Second Life viewer sources 1.20.7
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/lltrans.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/linden/indra/newview/lltrans.cpp b/linden/indra/newview/lltrans.cpp new file mode 100644 index 0000000..a848250 --- /dev/null +++ b/linden/indra/newview/lltrans.cpp | |||
@@ -0,0 +1,103 @@ | |||
1 | /** | ||
2 | * @file lltrans.cpp | ||
3 | * @brief LLTrans implementation | ||
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 | |||
33 | #include "llviewerprecompiledheaders.h" | ||
34 | #include "lltrans.h" | ||
35 | #include "llxmlnode.h" | ||
36 | #include "lluictrlfactory.h" | ||
37 | #include "llalertdialog.h" | ||
38 | |||
39 | #include <map> | ||
40 | |||
41 | LLTrans::template_map_t LLTrans::sStringTemplates; | ||
42 | |||
43 | //static | ||
44 | bool LLTrans::parseStrings(const LLString& xml_filename) | ||
45 | { | ||
46 | LLXMLNodePtr root; | ||
47 | BOOL success = LLUICtrlFactory::getLayeredXMLNode(xml_filename, root); | ||
48 | |||
49 | if (!success || root.isNull() || !root->hasName( "strings" )) | ||
50 | { | ||
51 | llerrs << "Problem reading strings: " << xml_filename << llendl; | ||
52 | return false; | ||
53 | } | ||
54 | |||
55 | for (LLXMLNode* string = root->getFirstChild(); | ||
56 | string != NULL; string = string->getNextSibling()) | ||
57 | { | ||
58 | if (!string->hasName("string")) | ||
59 | { | ||
60 | continue; | ||
61 | } | ||
62 | |||
63 | LLString string_name; | ||
64 | |||
65 | if (! string->getAttributeString("name", string_name)) | ||
66 | { | ||
67 | llwarns << "Unable to parse string with no name" << llendl; | ||
68 | continue; | ||
69 | } | ||
70 | |||
71 | LLTransTemplate xml_template(string_name, string->getTextContents()); | ||
72 | sStringTemplates[xml_template.mName] = xml_template; | ||
73 | } | ||
74 | |||
75 | return true; | ||
76 | } | ||
77 | |||
78 | //static | ||
79 | LLString LLTrans::getString(const LLString &xml_desc, const LLString::format_map_t& args) | ||
80 | { | ||
81 | template_map_t::iterator iter = sStringTemplates.find(xml_desc); | ||
82 | |||
83 | if (iter != sStringTemplates.end()) | ||
84 | { | ||
85 | LLString text = iter->second.mText; | ||
86 | LLString::format(text, args); | ||
87 | |||
88 | return text; | ||
89 | } | ||
90 | else | ||
91 | { | ||
92 | LLString::format_map_t args; | ||
93 | args["[STRING_NAME]"] = xml_desc; | ||
94 | llwarns << "Missing String: [" << xml_desc << "]" << llendl; | ||
95 | LLAlertDialog* dialogp = LLAlertDialog::showXml("MissingString", args); | ||
96 | if (dialogp == NULL) | ||
97 | { | ||
98 | llerrs << "Bad or missing alerts.xml!" << llendl; | ||
99 | } | ||
100 | return ""; | ||
101 | } | ||
102 | } | ||
103 | |||