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