initial import
[vuplus_webkit] / Source / WebKit / chromium / src / LocalizedStrings.cpp
1 /*
2  * Copyright (C) 2009 Google Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *
8  *     * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above
11  * copyright notice, this list of conditions and the following disclaimer
12  * in the documentation and/or other materials provided with the
13  * distribution.
14  *     * Neither the name of Google Inc. nor the names of its
15  * contributors may be used to endorse or promote products derived from
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
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30
31 #include "config.h"
32 #include "LocalizedStrings.h"
33
34 #include "IntSize.h"
35 #include "NotImplemented.h"
36
37 #include "WebKit.h"
38 #include "WebKitPlatformSupport.h"
39 #include "WebLocalizedString.h"
40 #include "WebString.h"
41
42 #include <wtf/text/StringBuilder.h>
43 #include <wtf/text/WTFString.h>
44
45 using WebKit::WebLocalizedString;
46 using WebKit::WebString;
47
48 namespace WebCore {
49
50 static String query(WebLocalizedString::Name name)
51 {
52     return WebKit::webKitPlatformSupport()->queryLocalizedString(name);
53 }
54
55 static String query(WebLocalizedString::Name name, const WebString& parameter)
56 {
57     return WebKit::webKitPlatformSupport()->queryLocalizedString(name, parameter);
58 }
59
60 static String query(WebLocalizedString::Name name, const WebString& parameter1, const WebString& parameter2)
61 {
62     return WebKit::webKitPlatformSupport()->queryLocalizedString(name, parameter1, parameter2);
63 }
64
65 String searchableIndexIntroduction()
66 {
67     return query(WebLocalizedString::SearchableIndexIntroduction);
68 }
69
70 String submitButtonDefaultLabel()
71 {
72     return query(WebLocalizedString::SubmitButtonDefaultLabel);
73 }
74
75 String inputElementAltText()
76 {
77     return query(WebLocalizedString::InputElementAltText);
78 }
79
80 String resetButtonDefaultLabel()
81 {
82     return query(WebLocalizedString::ResetButtonDefaultLabel);
83 }
84
85 String fileButtonChooseFileLabel()
86 {
87     return query(WebLocalizedString::FileButtonChooseFileLabel);
88 }
89
90 String fileButtonChooseMultipleFilesLabel()
91 {
92     return query(WebLocalizedString::FileButtonChooseMultipleFilesLabel);
93 }
94
95 String defaultDetailsSummaryText()
96 {
97     return query(WebLocalizedString::DetailsLabel);
98 }
99
100 String fileButtonNoFileSelectedLabel()
101 {
102     return query(WebLocalizedString::FileButtonNoFileSelectedLabel);
103 }
104
105 String searchMenuNoRecentSearchesText()
106 {
107     return query(WebLocalizedString::SearchMenuNoRecentSearchesText);
108 }
109 String searchMenuRecentSearchesText()
110 {
111     return query(WebLocalizedString::SearchMenuRecentSearchesText);
112 }
113
114 String searchMenuClearRecentSearchesText()
115 {
116     return query(WebLocalizedString::SearchMenuClearRecentSearchesText);
117 }
118
119 String AXWebAreaText()
120 {
121     return query(WebLocalizedString::AXWebAreaText);
122 }
123
124 String AXLinkText()
125 {
126     return query(WebLocalizedString::AXLinkText);
127 }
128
129 String AXListMarkerText()
130 {
131     return query(WebLocalizedString::AXListMarkerText);
132 }
133
134 String AXImageMapText()
135 {
136     return query(WebLocalizedString::AXImageMapText);
137 }
138
139 String AXHeadingText()
140 {
141     return query(WebLocalizedString::AXHeadingText);
142 }
143
144 String AXDefinitionListTermText()
145 {
146     notImplemented();
147     return String("term");
148 }
149
150 String AXDefinitionListDefinitionText()
151 {
152     notImplemented();
153     return String("definition");
154 }
155
156 String AXButtonActionVerb()
157 {
158     return query(WebLocalizedString::AXButtonActionVerb);
159 }
160
161 String AXRadioButtonActionVerb()
162 {
163     return query(WebLocalizedString::AXRadioButtonActionVerb);
164 }
165
166 String AXTextFieldActionVerb()
167 {
168     return query(WebLocalizedString::AXTextFieldActionVerb);
169 }
170
171 String AXCheckedCheckBoxActionVerb()
172 {
173     return query(WebLocalizedString::AXCheckedCheckBoxActionVerb);
174 }
175
176 String AXUncheckedCheckBoxActionVerb()
177 {
178     return query(WebLocalizedString::AXUncheckedCheckBoxActionVerb);
179 }
180
181 String AXLinkActionVerb()
182 {
183     return query(WebLocalizedString::AXLinkActionVerb);
184 }
185
186 String AXMenuListPopupActionVerb()
187 {
188     return String();
189 }
190
191 String AXMenuListActionVerb()
192 {
193     return String();
194 }
195     
196 String missingPluginText()
197 {
198     notImplemented();
199     return String("Missing Plug-in");
200 }
201
202 String crashedPluginText()
203 {
204     notImplemented();
205     return String("Plug-in Failure");
206 }
207
208 String multipleFileUploadText(unsigned numberOfFiles)
209 {
210     return query(WebLocalizedString::MultipleFileUploadText, String::number(numberOfFiles));
211 }
212
213 // Used in FTPDirectoryDocument.cpp
214 String unknownFileSizeText()
215 {
216     return String();
217 }
218
219 // The following two functions are not declared in LocalizedStrings.h.
220 // They are used by the menu for the HTML keygen tag.
221 String keygenMenuHighGradeKeySize()
222 {
223     return query(WebLocalizedString::KeygenMenuHighGradeKeySize);
224 }
225
226 String keygenMenuMediumGradeKeySize()
227 {
228     return query(WebLocalizedString::KeygenMenuMediumGradeKeySize);
229 }
230
231 // Used in ImageDocument.cpp as the title for pages when that page is an image.
232 String imageTitle(const String& filename, const IntSize& size)
233 {
234     StringBuilder result;
235     result.append(filename);
236     result.append(" (");
237     result.append(String::number(size.width()));
238     result.append(static_cast<UChar>(0xD7));  // U+00D7 (multiplication sign)
239     result.append(String::number(size.height()));
240     result.append(')');
241     return result.toString();
242 }
243
244 // We don't use these strings, so they return an empty String. We can't just
245 // make them asserts because webcore still calls them.
246 String contextMenuItemTagOpenLinkInNewWindow() { return String(); }
247 String contextMenuItemTagDownloadLinkToDisk() { return String(); }
248 String contextMenuItemTagCopyLinkToClipboard() { return String(); }
249 String contextMenuItemTagOpenImageInNewWindow() { return String(); }
250 String contextMenuItemTagDownloadImageToDisk() { return String(); }
251 String contextMenuItemTagCopyImageToClipboard() { return String(); }
252 String contextMenuItemTagOpenFrameInNewWindow() { return String(); }
253 String contextMenuItemTagCopy() { return String(); }
254 String contextMenuItemTagGoBack() { return String(); }
255 String contextMenuItemTagGoForward() { return String(); }
256 String contextMenuItemTagStop() { return String(); }
257 String contextMenuItemTagReload() { return String(); }
258 String contextMenuItemTagCut() { return String(); }
259 String contextMenuItemTagPaste() { return String(); }
260 String contextMenuItemTagNoGuessesFound() { return String(); }
261 String contextMenuItemTagIgnoreSpelling() { return String(); }
262 String contextMenuItemTagLearnSpelling() { return String(); }
263 String contextMenuItemTagSearchWeb() { return String(); }
264 String contextMenuItemTagLookUpInDictionary(const String&) { return String(); }
265 String contextMenuItemTagOpenLink() { return String(); }
266 String contextMenuItemTagIgnoreGrammar() { return String(); }
267 String contextMenuItemTagSpellingMenu() { return String(); }
268 String contextMenuItemTagCheckSpelling() { return String(); }
269 String contextMenuItemTagCheckSpellingWhileTyping() { return String(); }
270 String contextMenuItemTagCheckGrammarWithSpelling() { return String(); }
271 String contextMenuItemTagFontMenu() { return String(); }
272 String contextMenuItemTagBold() { return String(); }
273 String contextMenuItemTagItalic() { return String(); }
274 String contextMenuItemTagUnderline() { return String(); }
275 String contextMenuItemTagOutline() { return String(); }
276 String contextMenuItemTagWritingDirectionMenu() { return String(); }
277 String contextMenuItemTagTextDirectionMenu() { return String(); }
278 String contextMenuItemTagDefaultDirection() { return String(); }
279 String contextMenuItemTagLeftToRight() { return String(); }
280 String contextMenuItemTagRightToLeft() { return String(); }
281 String contextMenuItemTagInspectElement() { return String(); }
282 String contextMenuItemTagShowSpellingPanel(bool show) { return String(); }
283 String mediaElementLiveBroadcastStateText() { return String(); }
284 String mediaElementLoadingStateText() { return String(); }
285 String contextMenuItemTagOpenVideoInNewWindow() { return String(); }
286 String contextMenuItemTagOpenAudioInNewWindow() { return String(); }
287 String contextMenuItemTagCopyVideoLinkToClipboard() { return String(); }
288 String contextMenuItemTagCopyAudioLinkToClipboard() { return String(); }
289 String contextMenuItemTagToggleMediaControls() { return String(); }
290 String contextMenuItemTagToggleMediaLoop() { return String(); }
291 String contextMenuItemTagEnterVideoFullscreen() { return String(); }
292 String contextMenuItemTagMediaPlay() { return String(); }
293 String contextMenuItemTagMediaPause() { return String(); }
294 String contextMenuItemTagMediaMute() { return String(); }
295
296 String localizedMediaControlElementString(const String& /*name*/)
297 {
298     // FIXME: to be fixed.
299     return String();
300 }
301
302 String localizedMediaControlElementHelpText(const String& /*name*/)
303 {
304     // FIXME: to be fixed.
305     return String();
306 }
307
308 String localizedMediaTimeDescription(float /*time*/)
309 {
310     // FIXME: to be fixed.
311     return String();
312 }
313
314 String validationMessageValueMissingText()
315 {
316     return query(WebLocalizedString::ValidationValueMissing);
317 }
318
319 String validationMessageValueMissingForCheckboxText()
320 {
321     return query(WebLocalizedString::ValidationValueMissingForCheckbox);
322 }
323
324 String validationMessageValueMissingForFileText()
325 {
326     return query(WebLocalizedString::ValidationValueMissingForFile);
327 }
328
329 String validationMessageValueMissingForMultipleFileText()
330 {
331     return query(WebLocalizedString::ValidationValueMissingForMultipleFile);
332 }
333
334 String validationMessageValueMissingForRadioText()
335 {
336     return query(WebLocalizedString::ValidationValueMissingForRadio);
337 }
338
339 String validationMessageValueMissingForSelectText()
340 {
341     return query(WebLocalizedString::ValidationValueMissingForSelect);
342 }
343
344 String validationMessageTypeMismatchText()
345 {
346     return query(WebLocalizedString::ValidationTypeMismatch);
347 }
348
349 String validationMessageTypeMismatchForEmailText()
350 {
351     return query(WebLocalizedString::ValidationTypeMismatchForEmail);
352 }
353
354 String validationMessageTypeMismatchForMultipleEmailText()
355 {
356     return query(WebLocalizedString::ValidationTypeMismatchForMultipleEmail);
357 }
358
359 String validationMessageTypeMismatchForURLText()
360 {
361     return query(WebLocalizedString::ValidationTypeMismatchForURL);
362 }
363
364 String validationMessagePatternMismatchText()
365 {
366     return query(WebLocalizedString::ValidationPatternMismatch);
367 }
368
369 String validationMessageTooLongText(int valueLength, int maxLength)
370 {
371     return query(WebLocalizedString::ValidationTooLong, String::number(valueLength), String::number(maxLength));
372 }
373
374 String validationMessageRangeUnderflowText(const String& minimum)
375 {
376     return query(WebLocalizedString::ValidationRangeUnderflow, minimum);
377 }
378
379 String validationMessageRangeOverflowText(const String& maximum)
380 {
381     return query(WebLocalizedString::ValidationRangeOverflow, maximum);
382 }
383
384 String validationMessageStepMismatchText(const String& base, const String& step)
385 {
386     return query(WebLocalizedString::ValidationStepMismatch, base, step);
387 }
388
389 } // namespace WebCore