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 45 using WebKit::WebLocalizedString; 46 using WebKit::WebString; 47 48 namespace WebCore { 49 50 static String query(WebLocalizedString::Name name) 51 { 52 return WebKit::webKitClient()->queryLocalizedString(name); 53 } 54 55 static String query(WebLocalizedString::Name name, const WebString& parameter) 56 { 57 return WebKit::webKitClient()->queryLocalizedString(name, parameter); 58 } 59 60 static String query(WebLocalizedString::Name name, const WebString& parameter1, const WebString& parameter2) 61 { 62 return WebKit::webKitClient()->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 defaultDetailsSummaryText() 91 { 92 notImplemented(); 93 return String("Details"); 94 } 95 96 String fileButtonNoFileSelectedLabel() 97 { 98 return query(WebLocalizedString::FileButtonNoFileSelectedLabel); 99 } 100 101 String searchMenuNoRecentSearchesText() 102 { 103 return query(WebLocalizedString::SearchMenuNoRecentSearchesText); 104 } 105 String searchMenuRecentSearchesText() 106 { 107 return query(WebLocalizedString::SearchMenuRecentSearchesText); 108 } 109 110 String searchMenuClearRecentSearchesText() 111 { 112 return query(WebLocalizedString::SearchMenuClearRecentSearchesText); 113 } 114 115 String AXWebAreaText() 116 { 117 return query(WebLocalizedString::AXWebAreaText); 118 } 119 120 String AXLinkText() 121 { 122 return query(WebLocalizedString::AXLinkText); 123 } 124 125 String AXListMarkerText() 126 { 127 return query(WebLocalizedString::AXListMarkerText); 128 } 129 130 String AXImageMapText() 131 { 132 return query(WebLocalizedString::AXImageMapText); 133 } 134 135 String AXHeadingText() 136 { 137 return query(WebLocalizedString::AXHeadingText); 138 } 139 140 String AXDefinitionListTermText() 141 { 142 notImplemented(); 143 return String("term"); 144 } 145 146 String AXDefinitionListDefinitionText() 147 { 148 notImplemented(); 149 return String("definition"); 150 } 151 152 String AXButtonActionVerb() 153 { 154 return query(WebLocalizedString::AXButtonActionVerb); 155 } 156 157 String AXRadioButtonActionVerb() 158 { 159 return query(WebLocalizedString::AXRadioButtonActionVerb); 160 } 161 162 String AXTextFieldActionVerb() 163 { 164 return query(WebLocalizedString::AXTextFieldActionVerb); 165 } 166 167 String AXCheckedCheckBoxActionVerb() 168 { 169 return query(WebLocalizedString::AXCheckedCheckBoxActionVerb); 170 } 171 172 String AXUncheckedCheckBoxActionVerb() 173 { 174 return query(WebLocalizedString::AXUncheckedCheckBoxActionVerb); 175 } 176 177 String AXLinkActionVerb() 178 { 179 return query(WebLocalizedString::AXLinkActionVerb); 180 } 181 182 String AXMenuListPopupActionVerb() 183 { 184 return String(); 185 } 186 187 String AXMenuListActionVerb() 188 { 189 return String(); 190 } 191 192 String missingPluginText() 193 { 194 notImplemented(); 195 return String("Missing Plug-in"); 196 } 197 198 String crashedPluginText() 199 { 200 notImplemented(); 201 return String("Plug-in Failure"); 202 } 203 204 String multipleFileUploadText(unsigned numberOfFiles) 205 { 206 return query(WebLocalizedString::MultipleFileUploadText, String::number(numberOfFiles)); 207 } 208 209 // Used in FTPDirectoryDocument.cpp 210 String 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. 217 String keygenMenuHighGradeKeySize() 218 { 219 return query(WebLocalizedString::KeygenMenuHighGradeKeySize); 220 } 221 222 String 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. 228 String 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. 242 String contextMenuItemTagOpenLinkInNewWindow() { return String(); } 243 String contextMenuItemTagDownloadLinkToDisk() { return String(); } 244 String contextMenuItemTagCopyLinkToClipboard() { return String(); } 245 String contextMenuItemTagOpenImageInNewWindow() { return String(); } 246 String contextMenuItemTagDownloadImageToDisk() { return String(); } 247 String contextMenuItemTagCopyImageToClipboard() { return String(); } 248 String contextMenuItemTagOpenFrameInNewWindow() { return String(); } 249 String contextMenuItemTagCopy() { return String(); } 250 String contextMenuItemTagGoBack() { return String(); } 251 String contextMenuItemTagGoForward() { return String(); } 252 String contextMenuItemTagStop() { return String(); } 253 String contextMenuItemTagReload() { return String(); } 254 String contextMenuItemTagCut() { return String(); } 255 String contextMenuItemTagPaste() { return String(); } 256 String contextMenuItemTagNoGuessesFound() { return String(); } 257 String contextMenuItemTagIgnoreSpelling() { return String(); } 258 String contextMenuItemTagLearnSpelling() { return String(); } 259 String contextMenuItemTagSearchWeb() { return String(); } 260 String contextMenuItemTagLookUpInDictionary(const String&) { return String(); } 261 String contextMenuItemTagOpenLink() { return String(); } 262 String contextMenuItemTagIgnoreGrammar() { return String(); } 263 String contextMenuItemTagSpellingMenu() { return String(); } 264 String contextMenuItemTagCheckSpelling() { return String(); } 265 String contextMenuItemTagCheckSpellingWhileTyping() { return String(); } 266 String contextMenuItemTagCheckGrammarWithSpelling() { return String(); } 267 String contextMenuItemTagFontMenu() { return String(); } 268 String contextMenuItemTagBold() { return String(); } 269 String contextMenuItemTagItalic() { return String(); } 270 String contextMenuItemTagUnderline() { return String(); } 271 String contextMenuItemTagOutline() { return String(); } 272 String contextMenuItemTagWritingDirectionMenu() { return String(); } 273 String contextMenuItemTagTextDirectionMenu() { return String(); } 274 String contextMenuItemTagDefaultDirection() { return String(); } 275 String contextMenuItemTagLeftToRight() { return String(); } 276 String contextMenuItemTagRightToLeft() { return String(); } 277 String contextMenuItemTagInspectElement() { return String(); } 278 String contextMenuItemTagShowSpellingPanel(bool show) { return String(); } 279 String mediaElementLiveBroadcastStateText() { return String(); } 280 String mediaElementLoadingStateText() { return String(); } 281 String contextMenuItemTagOpenVideoInNewWindow() { return String(); } 282 String contextMenuItemTagOpenAudioInNewWindow() { return String(); } 283 String contextMenuItemTagCopyVideoLinkToClipboard() { return String(); } 284 String contextMenuItemTagCopyAudioLinkToClipboard() { return String(); } 285 String contextMenuItemTagToggleMediaControls() { return String(); } 286 String contextMenuItemTagToggleMediaLoop() { return String(); } 287 String contextMenuItemTagEnterVideoFullscreen() { return String(); } 288 String contextMenuItemTagMediaPlay() { return String(); } 289 String contextMenuItemTagMediaPause() { return String(); } 290 String contextMenuItemTagMediaMute() { return String(); } 291 292 String localizedMediaControlElementString(const String& /*name*/) 293 { 294 // FIXME: to be fixed. 295 return String(); 296 } 297 298 String localizedMediaControlElementHelpText(const String& /*name*/) 299 { 300 // FIXME: to be fixed. 301 return String(); 302 } 303 304 String localizedMediaTimeDescription(float /*time*/) 305 { 306 // FIXME: to be fixed. 307 return String(); 308 } 309 310 String validationMessageValueMissingText() 311 { 312 return query(WebLocalizedString::ValidationValueMissing); 313 } 314 315 String validationMessageValueMissingForCheckboxText() 316 { 317 return query(WebLocalizedString::ValidationValueMissingForCheckbox); 318 } 319 320 String validationMessageValueMissingForFileText() 321 { 322 return query(WebLocalizedString::ValidationValueMissingForFile); 323 } 324 325 String validationMessageValueMissingForMultipleFileText() 326 { 327 return query(WebLocalizedString::ValidationValueMissingForMultipleFile); 328 } 329 330 String validationMessageValueMissingForRadioText() 331 { 332 return query(WebLocalizedString::ValidationValueMissingForRadio); 333 } 334 335 String validationMessageValueMissingForSelectText() 336 { 337 return query(WebLocalizedString::ValidationValueMissingForSelect); 338 } 339 340 String validationMessageTypeMismatchText() 341 { 342 return query(WebLocalizedString::ValidationTypeMismatch); 343 } 344 345 String validationMessageTypeMismatchForEmailText() 346 { 347 return query(WebLocalizedString::ValidationTypeMismatchForEmail); 348 } 349 350 String validationMessageTypeMismatchForMultipleEmailText() 351 { 352 return query(WebLocalizedString::ValidationTypeMismatchForMultipleEmail); 353 } 354 355 String validationMessageTypeMismatchForURLText() 356 { 357 return query(WebLocalizedString::ValidationTypeMismatchForURL); 358 } 359 360 String validationMessagePatternMismatchText() 361 { 362 return query(WebLocalizedString::ValidationPatternMismatch); 363 } 364 365 String validationMessageTooLongText(int valueLength, int maxLength) 366 { 367 return query(WebLocalizedString::ValidationTooLong, String::number(valueLength), String::number(maxLength)); 368 } 369 370 String validationMessageRangeUnderflowText(const String& minimum) 371 { 372 return query(WebLocalizedString::ValidationRangeUnderflow, minimum); 373 } 374 375 String validationMessageRangeOverflowText(const String& maximum) 376 { 377 return query(WebLocalizedString::ValidationRangeOverflow, maximum); 378 } 379 380 String validationMessageStepMismatchText(const String& base, const String& step) 381 { 382 return query(WebLocalizedString::ValidationStepMismatch, base, step); 383 } 384 385 } // namespace WebCore 386