Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: webkit/api/src/LocalizedStrings.cpp

Issue 149760: Introduce WebLocalizedString and queryLocalizedString methods... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/api/public/WebLocalizedString.h ('k') | webkit/glue/localized_strings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions are
6 * are met: 6 * met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 7 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 8 * * Redistributions of source code must retain the above copyright
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 9 * notice, this list of conditions and the following disclaimer.
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 10 * * Redistributions in binary form must reproduce the above
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 11 * copyright notice, this list of conditions and the following disclaimer
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 12 * in the documentation and/or other materials provided with the
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 13 * distribution.
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 14 * * Neither the name of Google Inc. nor the names of its
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 15 * contributors may be used to endorse or promote products derived from
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 29 */
25 30
26 #include "config.h" 31 #include "config.h"
27 #include "LocalizedStrings.h" 32 #include "LocalizedStrings.h"
33
34 #include "IntSize.h"
35 #include "NotImplemented.h"
28 #include "PlatformString.h" 36 #include "PlatformString.h"
29 #include "IntSize.h" 37
30 38 #include "WebKit.h"
31 #undef LOG 39 #include "WebKitClient.h"
32 40 #include "WebLocalizedString.h"
33 #include "base/logging.h" 41 #include "WebString.h"
34 #include "base/file_util.h" 42
35 #include "base/string16.h" 43 using WebKit::WebLocalizedString;
36 #include "base/string_util.h" 44
37 #include "grit/webkit_strings.h" 45 namespace WebCore {
38 #include "webkit/glue/glue_util.h" 46
39 #include "webkit/glue/webkit_glue.h" 47 static String query(WebLocalizedString::Name name)
40 48 {
41 49 return WebKit::webKitClient()->queryLocalizedString(name);
42 using namespace WebCore; 50 }
43 51
44 inline String GetLocalizedString(int message_id) { 52 static String query(WebLocalizedString::Name name, int numericValue)
45 const string16& str = webkit_glue::GetLocalizedString(message_id); 53 {
46 return webkit_glue::String16ToString(str); 54 return WebKit::webKitClient()->queryLocalizedString(name, numericValue);
47 } 55 }
48 56
49 String WebCore::searchableIndexIntroduction() { 57 String searchableIndexIntroduction()
50 return GetLocalizedString(IDS_SEARCHABLE_INDEX_INTRO); 58 {
51 } 59 return query(WebLocalizedString::SearchableIndexIntroduction);
52 String WebCore::submitButtonDefaultLabel() { 60 }
53 return GetLocalizedString(IDS_FORM_SUBMIT_LABEL); 61
54 } 62 String submitButtonDefaultLabel()
55 String WebCore::inputElementAltText() { 63 {
56 return GetLocalizedString(IDS_FORM_INPUT_ALT); 64 return query(WebLocalizedString::SubmitButtonDefaultLabel);
57 } 65 }
58 String WebCore::resetButtonDefaultLabel() { 66
59 return GetLocalizedString(IDS_FORM_RESET_LABEL); 67 String inputElementAltText()
60 } 68 {
61 String WebCore::fileButtonChooseFileLabel() { 69 return query(WebLocalizedString::InputElementAltText);
62 return GetLocalizedString(IDS_FORM_FILE_BUTTON_LABEL); 70 }
63 } 71
64 String WebCore::fileButtonNoFileSelectedLabel() { 72 String resetButtonDefaultLabel()
65 return GetLocalizedString(IDS_FORM_FILE_NO_FILE_LABEL); 73 {
66 } 74 return query(WebLocalizedString::ResetButtonDefaultLabel);
67 75 }
68 String WebCore::searchMenuNoRecentSearchesText() { 76
69 return GetLocalizedString(IDS_RECENT_SEARCHES_NONE); 77 String fileButtonChooseFileLabel()
70 } 78 {
71 String WebCore::searchMenuRecentSearchesText() { 79 return query(WebLocalizedString::FileButtonChooseFileLabel);
72 return GetLocalizedString(IDS_RECENT_SEARCHES); 80 }
73 } 81
74 String WebCore::searchMenuClearRecentSearchesText() { 82 String fileButtonNoFileSelectedLabel()
75 return GetLocalizedString(IDS_RECENT_SEARCHES_CLEAR); 83 {
76 } 84 return query(WebLocalizedString::FileButtonNoFileSelectedLabel);
77 85 }
78 // A11y strings. 86
79 String WebCore::AXWebAreaText() { 87 String searchMenuNoRecentSearchesText()
80 return GetLocalizedString(IDS_AX_ROLE_WEB_AREA); 88 {
81 } 89 return query(WebLocalizedString::SearchMenuNoRecentSearchesText);
82 String WebCore::AXLinkText() { 90 }
83 return GetLocalizedString(IDS_AX_ROLE_LINK); 91 String searchMenuRecentSearchesText()
84 } 92 {
85 String WebCore::AXListMarkerText() { 93 return query(WebLocalizedString::SearchMenuRecentSearchesText);
86 return GetLocalizedString(IDS_AX_ROLE_LIST_MARKER); 94 }
87 } 95 String searchMenuClearRecentSearchesText()
88 String WebCore::AXImageMapText() { 96 {
89 return GetLocalizedString(IDS_AX_ROLE_IMAGE_MAP); 97 return query(WebLocalizedString::SearchMenuClearRecentSearchesText);
90 } 98 }
91 String WebCore::AXHeadingText() { 99
92 return GetLocalizedString(IDS_AX_ROLE_HEADING); 100 String AXWebAreaText()
93 } 101 {
94 String WebCore::AXDefinitionListTermText() { 102 return query(WebLocalizedString::AXWebAreaText);
95 NOTIMPLEMENTED(); 103 }
96 return String("term"); 104
97 } 105 String AXLinkText()
98 String WebCore::AXDefinitionListDefinitionText() { 106 {
99 NOTIMPLEMENTED(); 107 return query(WebLocalizedString::AXLinkText);
100 return String("definition"); 108 }
101 } 109
102 String WebCore::AXButtonActionVerb() { 110 String AXListMarkerText()
103 return GetLocalizedString(IDS_AX_BUTTON_ACTION_VERB); 111 {
104 } 112 return query(WebLocalizedString::AXListMarkerText);
105 String WebCore::AXRadioButtonActionVerb() { 113 }
106 return GetLocalizedString(IDS_AX_RADIO_BUTTON_ACTION_VERB); 114
107 } 115 String AXImageMapText()
108 String WebCore::AXTextFieldActionVerb() { 116 {
109 return GetLocalizedString(IDS_AX_TEXT_FIELD_ACTION_VERB); 117 return query(WebLocalizedString::AXImageMapText);
110 } 118 }
111 String WebCore::AXCheckedCheckBoxActionVerb() { 119
112 return GetLocalizedString(IDS_AX_CHECKED_CHECK_BOX_ACTION_VERB); 120 String AXHeadingText()
113 } 121 {
114 String WebCore::AXUncheckedCheckBoxActionVerb() { 122 return query(WebLocalizedString::AXHeadingText);
115 return GetLocalizedString(IDS_AX_UNCHECKED_CHECK_BOX_ACTION_VERB); 123 }
116 } 124
117 String WebCore::AXLinkActionVerb() { 125 String AXDefinitionListTermText()
118 return GetLocalizedString(IDS_AX_LINK_ACTION_VERB); 126 {
119 } 127 notImplemented();
120 128 return String("term");
121 String WebCore::multipleFileUploadText(unsigned number_of_files) { 129 }
122 return webkit_glue::String16ToString(ReplaceStringPlaceholders( 130
123 webkit_glue::GetLocalizedString(IDS_FORM_FILE_MULTIPLE_UPLOAD), 131 String AXDefinitionListDefinitionText()
124 WideToUTF16Hack(UintToWString(number_of_files)), 132 {
125 NULL)); 133 notImplemented();
126 } 134 return String("definition");
135 }
136
137 String AXButtonActionVerb()
138 {
139 return query(WebLocalizedString::AXButtonActionVerb);
140 }
141
142 String AXRadioButtonActionVerb()
143 {
144 return query(WebLocalizedString::AXRadioButtonActionVerb);
145 }
146
147 String AXTextFieldActionVerb()
148 {
149 return query(WebLocalizedString::AXTextFieldActionVerb);
150 }
151
152 String AXCheckedCheckBoxActionVerb()
153 {
154 return query(WebLocalizedString::AXCheckedCheckBoxActionVerb);
155 }
156
157 String AXUncheckedCheckBoxActionVerb()
158 {
159 return query(WebLocalizedString::AXUncheckedCheckBoxActionVerb);
160 }
161
162 String AXLinkActionVerb()
163 {
164 return query(WebLocalizedString::AXLinkActionVerb);
165 }
166
167 String multipleFileUploadText(unsigned numberOfFiles)
168 {
169 return query(WebLocalizedString::MultipleFileUploadText, numberOfFiles);
170 }
171
127 // Used in FTPDirectoryDocument.cpp 172 // Used in FTPDirectoryDocument.cpp
128 String WebCore::unknownFileSizeText() { 173 String unknownFileSizeText()
129 return String(); 174 {
175 return String();
130 } 176 }
131 177
132 // The following two functions are not declared in LocalizedStrings.h. 178 // The following two functions are not declared in LocalizedStrings.h.
133 // They are used by the menu for the HTML keygen tag. 179 // They are used by the menu for the HTML keygen tag.
134 namespace WebCore { 180 String keygenMenuHighGradeKeySize()
135 String keygenMenuHighGradeKeySize() { 181 {
136 return GetLocalizedString(IDS_KEYGEN_HIGH_GRADE_KEY); 182 return query(WebLocalizedString::KeygenMenuHighGradeKeySize);
137 } 183 }
138 String keygenMenuMediumGradeKeySize() { 184
139 return GetLocalizedString(IDS_KEYGEN_MED_GRADE_KEY); 185 String keygenMenuMediumGradeKeySize()
186 {
187 return query(WebLocalizedString::KeygenMenuMediumGradeKeySize);
140 } 188 }
141 189
142 // Used in ImageDocument.cpp as the title for pages when that page is an image. 190 // Used in ImageDocument.cpp as the title for pages when that page is an image.
143 String imageTitle(const String& filename, const IntSize& size) { 191 String imageTitle(const String& filename, const IntSize& size)
144 // C3 97 is UTF-8 for U+00D7 (multiplication sign). 192 {
145 std::string size_str = StringPrintf(" (%d\xC3\x97%d)", 193 // C3 97 is UTF-8 for U+00D7 (multiplication sign).
146 size.width(), size.height()); 194 return filename + String::format(" (%d\xC3\x97%d)", size.width(), size.height());
147 return filename + webkit_glue::StdStringToString(size_str); 195 }
148 }
149
150 } //namespace WebCore
151 196
152 // We don't use these strings, so they return an empty String. We can't just 197 // We don't use these strings, so they return an empty String. We can't just
153 // make them asserts because webcore still calls them. 198 // make them asserts because webcore still calls them.
154 String WebCore::contextMenuItemTagOpenLinkInNewWindow() { return String(); } 199 String contextMenuItemTagOpenLinkInNewWindow() { return String(); }
155 String WebCore::contextMenuItemTagDownloadLinkToDisk() { return String(); } 200 String contextMenuItemTagDownloadLinkToDisk() { return String(); }
156 String WebCore::contextMenuItemTagCopyLinkToClipboard() { return String(); } 201 String contextMenuItemTagCopyLinkToClipboard() { return String(); }
157 String WebCore::contextMenuItemTagOpenImageInNewWindow() { return String(); } 202 String contextMenuItemTagOpenImageInNewWindow() { return String(); }
158 String WebCore::contextMenuItemTagDownloadImageToDisk() { return String(); } 203 String contextMenuItemTagDownloadImageToDisk() { return String(); }
159 String WebCore::contextMenuItemTagCopyImageToClipboard() { return String(); } 204 String contextMenuItemTagCopyImageToClipboard() { return String(); }
160 String WebCore::contextMenuItemTagOpenFrameInNewWindow() { return String(); } 205 String contextMenuItemTagOpenFrameInNewWindow() { return String(); }
161 String WebCore::contextMenuItemTagCopy() { return String(); } 206 String contextMenuItemTagCopy() { return String(); }
162 String WebCore::contextMenuItemTagGoBack() { return String(); } 207 String contextMenuItemTagGoBack() { return String(); }
163 String WebCore::contextMenuItemTagGoForward() { return String(); } 208 String contextMenuItemTagGoForward() { return String(); }
164 String WebCore::contextMenuItemTagStop() { return String(); } 209 String contextMenuItemTagStop() { return String(); }
165 String WebCore::contextMenuItemTagReload() { return String(); } 210 String contextMenuItemTagReload() { return String(); }
166 String WebCore::contextMenuItemTagCut() { return String(); } 211 String contextMenuItemTagCut() { return String(); }
167 String WebCore::contextMenuItemTagPaste() { return String(); } 212 String contextMenuItemTagPaste() { return String(); }
168 String WebCore::contextMenuItemTagNoGuessesFound() { return String(); } 213 String contextMenuItemTagNoGuessesFound() { return String(); }
169 String WebCore::contextMenuItemTagIgnoreSpelling() { return String(); } 214 String contextMenuItemTagIgnoreSpelling() { return String(); }
170 String WebCore::contextMenuItemTagLearnSpelling() { return String(); } 215 String contextMenuItemTagLearnSpelling() { return String(); }
171 String WebCore::contextMenuItemTagSearchWeb() { return String(); } 216 String contextMenuItemTagSearchWeb() { return String(); }
172 String WebCore::contextMenuItemTagLookUpInDictionary() { return String(); } 217 String contextMenuItemTagLookUpInDictionary() { return String(); }
173 String WebCore::contextMenuItemTagOpenLink() { return String(); } 218 String contextMenuItemTagOpenLink() { return String(); }
174 String WebCore::contextMenuItemTagIgnoreGrammar() { return String(); } 219 String contextMenuItemTagIgnoreGrammar() { return String(); }
175 String WebCore::contextMenuItemTagSpellingMenu() { return String(); } 220 String contextMenuItemTagSpellingMenu() { return String(); }
176 String WebCore::contextMenuItemTagCheckSpelling() { return String(); } 221 String contextMenuItemTagCheckSpelling() { return String(); }
177 String WebCore::contextMenuItemTagCheckSpellingWhileTyping() { return String(); } 222 String contextMenuItemTagCheckSpellingWhileTyping() { return String(); }
178 String WebCore::contextMenuItemTagCheckGrammarWithSpelling() { return String(); } 223 String contextMenuItemTagCheckGrammarWithSpelling() { return String(); }
179 String WebCore::contextMenuItemTagFontMenu() { return String(); } 224 String contextMenuItemTagFontMenu() { return String(); }
180 String WebCore::contextMenuItemTagBold() { return String(); } 225 String contextMenuItemTagBold() { return String(); }
181 String WebCore::contextMenuItemTagItalic() { return String(); } 226 String contextMenuItemTagItalic() { return String(); }
182 String WebCore::contextMenuItemTagUnderline() { return String(); } 227 String contextMenuItemTagUnderline() { return String(); }
183 String WebCore::contextMenuItemTagOutline() { return String(); } 228 String contextMenuItemTagOutline() { return String(); }
184 String WebCore::contextMenuItemTagWritingDirectionMenu() { return String(); } 229 String contextMenuItemTagWritingDirectionMenu() { return String(); }
185 String WebCore::contextMenuItemTagTextDirectionMenu() { return String(); } 230 String contextMenuItemTagTextDirectionMenu() { return String(); }
186 String WebCore::contextMenuItemTagDefaultDirection() { return String(); } 231 String contextMenuItemTagDefaultDirection() { return String(); }
187 String WebCore::contextMenuItemTagLeftToRight() { return String(); } 232 String contextMenuItemTagLeftToRight() { return String(); }
188 String WebCore::contextMenuItemTagRightToLeft() { return String(); } 233 String contextMenuItemTagRightToLeft() { return String(); }
189 String WebCore::contextMenuItemTagInspectElement() { return String(); } 234 String contextMenuItemTagInspectElement() { return String(); }
190 String WebCore::contextMenuItemTagShowSpellingPanel(bool show) { return String(); } 235 String contextMenuItemTagShowSpellingPanel(bool show) { return String(); }
191 // TODO(scherkus): These should return something. 236
192 String WebCore::mediaElementLiveBroadcastStateText() { return String(); } 237 // FIXME: These should return something.
193 String WebCore::mediaElementLoadingStateText() { return String(); } 238 String mediaElementLiveBroadcastStateText() { return String(); }
239 String mediaElementLoadingStateText() { return String(); }
240
241 } // namespace WebCore
OLDNEW
« no previous file with comments | « webkit/api/public/WebLocalizedString.h ('k') | webkit/glue/localized_strings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698