1/* 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com 4 * Copyright (C) 2007 Holger Hans Peter Freyther 5 * Copyright (C) 2008 Christian Dywan <christian@imendio.com> 6 * Copyright (C) 2008 Nuanti Ltd. 7 * Copyright (C) 2010 Igalia S.L 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 1. Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 2. Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 26 * 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 33#include "LocalizedStrings.h" 34#include "GOwnPtr.h" 35#include "IntSize.h" 36#include "NotImplemented.h" 37#include "PlatformString.h" 38#include <wtf/text/CString.h> 39 40#include <glib/gi18n-lib.h> 41#include <gtk/gtk.h> 42#include <math.h> 43 44namespace WebCore { 45 46static const char* gtkStockLabel(const char* stockID) 47{ 48 GtkStockItem item; 49 if (!gtk_stock_lookup(stockID, &item)) 50 return stockID; 51 return item.label; 52} 53 54String submitButtonDefaultLabel() 55{ 56 return String::fromUTF8(_("Submit")); 57} 58 59String inputElementAltText() 60{ 61 return String::fromUTF8(_("Submit")); 62} 63 64String resetButtonDefaultLabel() 65{ 66 return String::fromUTF8(_("Reset")); 67} 68 69String defaultDetailsSummaryText() 70{ 71 return String::fromUTF8(_("Details")); 72} 73 74String searchableIndexIntroduction() 75{ 76 return String::fromUTF8(_("This is a searchable index. Enter search keywords: ")); 77} 78 79String fileButtonChooseFileLabel() 80{ 81 return String::fromUTF8(_("Choose File")); 82} 83 84String fileButtonNoFileSelectedLabel() 85{ 86 return String::fromUTF8(_("(None)")); 87} 88 89String contextMenuItemTagOpenLinkInNewWindow() 90{ 91 return String::fromUTF8(_("Open Link in New _Window")); 92} 93 94String contextMenuItemTagDownloadLinkToDisk() 95{ 96 return String::fromUTF8(_("_Download Linked File")); 97} 98 99String contextMenuItemTagCopyLinkToClipboard() 100{ 101 return String::fromUTF8(_("Copy Link Loc_ation")); 102} 103 104String contextMenuItemTagOpenImageInNewWindow() 105{ 106 return String::fromUTF8(_("Open _Image in New Window")); 107} 108 109String contextMenuItemTagDownloadImageToDisk() 110{ 111 return String::fromUTF8(_("Sa_ve Image As")); 112} 113 114String contextMenuItemTagCopyImageToClipboard() 115{ 116 return String::fromUTF8(_("Cop_y Image")); 117} 118 119String contextMenuItemTagCopyImageUrlToClipboard() 120{ 121 return String::fromUTF8(_("Copy Image _Address")); 122} 123 124String contextMenuItemTagOpenVideoInNewWindow() 125{ 126 return String::fromUTF8(_("Open _Video in New Window")); 127} 128 129String contextMenuItemTagOpenAudioInNewWindow() 130{ 131 return String::fromUTF8(_("Open _Audio in New Window")); 132} 133 134String contextMenuItemTagCopyVideoLinkToClipboard() 135{ 136 return String::fromUTF8(_("Cop_y Video Link Location")); 137} 138 139String contextMenuItemTagCopyAudioLinkToClipboard() 140{ 141 return String::fromUTF8(_("Cop_y Audio Link Location")); 142} 143 144String contextMenuItemTagToggleMediaControls() 145{ 146 return String::fromUTF8(_("_Toggle Media Controls")); 147} 148 149String contextMenuItemTagToggleMediaLoop() 150{ 151 return String::fromUTF8(_("Toggle Media _Loop Playback")); 152} 153 154String contextMenuItemTagEnterVideoFullscreen() 155{ 156 return String::fromUTF8(_("Switch Video to _Fullscreen")); 157} 158 159String contextMenuItemTagMediaPlay() 160{ 161 return String::fromUTF8(_("_Play")); 162} 163 164String contextMenuItemTagMediaPause() 165{ 166 return String::fromUTF8(_("_Pause")); 167} 168 169String contextMenuItemTagMediaMute() 170{ 171 return String::fromUTF8(_("_Mute")); 172} 173 174String contextMenuItemTagOpenFrameInNewWindow() 175{ 176 return String::fromUTF8(_("Open _Frame in New Window")); 177} 178 179String contextMenuItemTagCopy() 180{ 181 static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_COPY)); 182 return stockLabel; 183} 184 185String contextMenuItemTagDelete() 186{ 187 static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_DELETE)); 188 return stockLabel; 189} 190 191String contextMenuItemTagSelectAll() 192{ 193 static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_SELECT_ALL)); 194 return stockLabel; 195} 196 197String contextMenuItemTagUnicode() 198{ 199 return String::fromUTF8(_("_Insert Unicode Control Character")); 200} 201 202String contextMenuItemTagInputMethods() 203{ 204 return String::fromUTF8(_("Input _Methods")); 205} 206 207String contextMenuItemTagGoBack() 208{ 209 static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_GO_BACK)); 210 return stockLabel; 211} 212 213String contextMenuItemTagGoForward() 214{ 215 static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_GO_FORWARD)); 216 return stockLabel; 217} 218 219String contextMenuItemTagStop() 220{ 221 static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_STOP)); 222 return stockLabel; 223} 224 225String contextMenuItemTagReload() 226{ 227 return String::fromUTF8(_("_Reload")); 228} 229 230String contextMenuItemTagCut() 231{ 232 static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_CUT)); 233 return stockLabel; 234} 235 236String contextMenuItemTagPaste() 237{ 238 static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_PASTE)); 239 return stockLabel; 240} 241 242String contextMenuItemTagNoGuessesFound() 243{ 244 return String::fromUTF8(_("No Guesses Found")); 245} 246 247String contextMenuItemTagIgnoreSpelling() 248{ 249 return String::fromUTF8(_("_Ignore Spelling")); 250} 251 252String contextMenuItemTagLearnSpelling() 253{ 254 return String::fromUTF8(_("_Learn Spelling")); 255} 256 257String contextMenuItemTagSearchWeb() 258{ 259 return String::fromUTF8(_("_Search the Web")); 260} 261 262String contextMenuItemTagLookUpInDictionary(const String&) 263{ 264 return String::fromUTF8(_("_Look Up in Dictionary")); 265} 266 267String contextMenuItemTagOpenLink() 268{ 269 return String::fromUTF8(_("_Open Link")); 270} 271 272String contextMenuItemTagIgnoreGrammar() 273{ 274 return String::fromUTF8(_("Ignore _Grammar")); 275} 276 277String contextMenuItemTagSpellingMenu() 278{ 279 return String::fromUTF8(_("Spelling and _Grammar")); 280} 281 282String contextMenuItemTagShowSpellingPanel(bool show) 283{ 284 return String::fromUTF8(show ? _("_Show Spelling and Grammar") : _("_Hide Spelling and Grammar")); 285} 286 287String contextMenuItemTagCheckSpelling() 288{ 289 return String::fromUTF8(_("_Check Document Now")); 290} 291 292String contextMenuItemTagCheckSpellingWhileTyping() 293{ 294 return String::fromUTF8(_("Check Spelling While _Typing")); 295} 296 297String contextMenuItemTagCheckGrammarWithSpelling() 298{ 299 return String::fromUTF8(_("Check _Grammar With Spelling")); 300} 301 302String contextMenuItemTagFontMenu() 303{ 304 return String::fromUTF8(_("_Font")); 305} 306 307String contextMenuItemTagBold() 308{ 309 static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_BOLD)); 310 return stockLabel; 311} 312 313String contextMenuItemTagItalic() 314{ 315 static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_ITALIC)); 316 return stockLabel; 317} 318 319String contextMenuItemTagUnderline() 320{ 321 static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_UNDERLINE)); 322 return stockLabel; 323} 324 325String contextMenuItemTagOutline() 326{ 327 return String::fromUTF8(_("_Outline")); 328} 329 330String contextMenuItemTagInspectElement() 331{ 332 return String::fromUTF8(_("Inspect _Element")); 333} 334 335String searchMenuNoRecentSearchesText() 336{ 337 return String::fromUTF8(_("No recent searches")); 338} 339 340String searchMenuRecentSearchesText() 341{ 342 return String::fromUTF8(_("Recent searches")); 343} 344 345String searchMenuClearRecentSearchesText() 346{ 347 return String::fromUTF8(_("_Clear recent searches")); 348} 349 350String AXDefinitionListTermText() 351{ 352 return String::fromUTF8(_("term")); 353} 354 355String AXDefinitionListDefinitionText() 356{ 357 return String::fromUTF8(_("definition")); 358} 359 360String AXButtonActionVerb() 361{ 362 return String::fromUTF8(_("press")); 363} 364 365String AXRadioButtonActionVerb() 366{ 367 return String::fromUTF8(_("select")); 368} 369 370String AXTextFieldActionVerb() 371{ 372 return String::fromUTF8(_("activate")); 373} 374 375String AXCheckedCheckBoxActionVerb() 376{ 377 return String::fromUTF8(_("uncheck")); 378} 379 380String AXUncheckedCheckBoxActionVerb() 381{ 382 return String::fromUTF8(_("check")); 383} 384 385String AXLinkActionVerb() 386{ 387 return String::fromUTF8(_("jump")); 388} 389 390String AXMenuListPopupActionVerb() 391{ 392 return String(); 393} 394 395String AXMenuListActionVerb() 396{ 397 return String(); 398} 399 400String missingPluginText() 401{ 402 return String::fromUTF8(_("Missing Plug-in")); 403} 404 405String crashedPluginText() 406{ 407 notImplemented(); 408 return String::fromUTF8(_("Plug-in Failure")); 409} 410 411String multipleFileUploadText(unsigned numberOfFiles) 412{ 413 // FIXME: If this file gets localized, this should really be localized as one string with a wildcard for the number. 414 return String::number(numberOfFiles) + String::fromUTF8(_(" files")); 415} 416 417String unknownFileSizeText() 418{ 419 return String::fromUTF8(_("Unknown")); 420} 421 422String imageTitle(const String& filename, const IntSize& size) 423{ 424 GOwnPtr<gchar> string(g_strdup_printf(C_("Title string for images", "%s (%dx%d pixels)"), 425 filename.utf8().data(), 426 size.width(), size.height())); 427 428 return String::fromUTF8(string.get()); 429} 430 431 432#if ENABLE(VIDEO) 433 434String mediaElementLoadingStateText() 435{ 436 return String::fromUTF8(_("Loading...")); 437} 438 439String mediaElementLiveBroadcastStateText() 440{ 441 return String::fromUTF8(_("Live Broadcast")); 442} 443 444String localizedMediaControlElementString(const String& name) 445{ 446 if (name == "AudioElement") 447 return String::fromUTF8(_("audio element controller")); 448 if (name == "VideoElement") 449 return String::fromUTF8(_("video element controller")); 450 if (name == "MuteButton") 451 return String::fromUTF8(_("mute")); 452 if (name == "UnMuteButton") 453 return String::fromUTF8(_("unmute")); 454 if (name == "PlayButton") 455 return String::fromUTF8(_("play")); 456 if (name == "PauseButton") 457 return String::fromUTF8(_("pause")); 458 if (name == "Slider") 459 return String::fromUTF8(_("movie time")); 460 if (name == "SliderThumb") 461 return String::fromUTF8(_("timeline slider thumb")); 462 if (name == "RewindButton") 463 return String::fromUTF8(_("back 30 seconds")); 464 if (name == "ReturnToRealtimeButton") 465 return String::fromUTF8(_("return to realtime")); 466 if (name == "CurrentTimeDisplay") 467 return String::fromUTF8(_("elapsed time")); 468 if (name == "TimeRemainingDisplay") 469 return String::fromUTF8(_("remaining time")); 470 if (name == "StatusDisplay") 471 return String::fromUTF8(_("status")); 472 if (name == "FullscreenButton") 473 return String::fromUTF8(_("fullscreen")); 474 if (name == "SeekForwardButton") 475 return String::fromUTF8(_("fast forward")); 476 if (name == "SeekBackButton") 477 return String::fromUTF8(_("fast reverse")); 478 if (name == "ShowClosedCaptionsButton") 479 return String::fromUTF8(_("show closed captions")); 480 if (name == "HideClosedCaptionsButton") 481 return String::fromUTF8(_("hide closed captions")); 482 483 ASSERT_NOT_REACHED(); 484 return String(); 485} 486 487String localizedMediaControlElementHelpText(const String& name) 488{ 489 if (name == "AudioElement") 490 return String::fromUTF8(_("audio element playback controls and status display")); 491 if (name == "VideoElement") 492 return String::fromUTF8(_("video element playback controls and status display")); 493 if (name == "MuteButton") 494 return String::fromUTF8(_("mute audio tracks")); 495 if (name == "UnMuteButton") 496 return String::fromUTF8(_("unmute audio tracks")); 497 if (name == "PlayButton") 498 return String::fromUTF8(_("begin playback")); 499 if (name == "PauseButton") 500 return String::fromUTF8(_("pause playback")); 501 if (name == "Slider") 502 return String::fromUTF8(_("movie time scrubber")); 503 if (name == "SliderThumb") 504 return String::fromUTF8(_("movie time scrubber thumb")); 505 if (name == "RewindButton") 506 return String::fromUTF8(_("seek movie back 30 seconds")); 507 if (name == "ReturnToRealtimeButton") 508 return String::fromUTF8(_("return streaming movie to real time")); 509 if (name == "CurrentTimeDisplay") 510 return String::fromUTF8(_("current movie time in seconds")); 511 if (name == "TimeRemainingDisplay") 512 return String::fromUTF8(_("number of seconds of movie remaining")); 513 if (name == "StatusDisplay") 514 return String::fromUTF8(_("current movie status")); 515 if (name == "SeekBackButton") 516 return String::fromUTF8(_("seek quickly back")); 517 if (name == "SeekForwardButton") 518 return String::fromUTF8(_("seek quickly forward")); 519 if (name == "FullscreenButton") 520 return String::fromUTF8(_("Play movie in fullscreen mode")); 521 if (name == "ShowClosedCaptionsButton") 522 return String::fromUTF8(_("start displaying closed captions")); 523 if (name == "HideClosedCaptionsButton") 524 return String::fromUTF8(_("stop displaying closed captions")); 525 526 ASSERT_NOT_REACHED(); 527 return String(); 528} 529 530String localizedMediaTimeDescription(float time) 531{ 532 if (!isfinite(time)) 533 return String::fromUTF8(_("indefinite time")); 534 535 int seconds = (int)fabsf(time); 536 int days = seconds / (60 * 60 * 24); 537 int hours = seconds / (60 * 60); 538 int minutes = (seconds / 60) % 60; 539 seconds %= 60; 540 541 if (days) { 542 GOwnPtr<gchar> string(g_strdup_printf("%d days %d hours %d minutes %d seconds", days, hours, minutes, seconds)); 543 return String::fromUTF8(string.get()); 544 } 545 546 if (hours) { 547 GOwnPtr<gchar> string(g_strdup_printf("%d hours %d minutes %d seconds", hours, minutes, seconds)); 548 return String::fromUTF8(string.get()); 549 } 550 551 if (minutes) { 552 GOwnPtr<gchar> string(g_strdup_printf("%d minutes %d seconds", minutes, seconds)); 553 return String::fromUTF8(string.get()); 554 } 555 556 GOwnPtr<gchar> string(g_strdup_printf("%d seconds", seconds)); 557 return String::fromUTF8(string.get()); 558} 559#endif // ENABLE(VIDEO) 560 561String validationMessageValueMissingText() 562{ 563 return String::fromUTF8(_("value missing")); 564} 565 566String validationMessageValueMissingForCheckboxText() 567{ 568 notImplemented(); 569 return validationMessageValueMissingText(); 570} 571 572String validationMessageValueMissingForFileText() 573{ 574 notImplemented(); 575 return validationMessageValueMissingText(); 576} 577 578String validationMessageValueMissingForMultipleFileText() 579{ 580 notImplemented(); 581 return validationMessageValueMissingText(); 582} 583 584String validationMessageValueMissingForRadioText() 585{ 586 notImplemented(); 587 return validationMessageValueMissingText(); 588} 589 590String validationMessageValueMissingForSelectText() 591{ 592 notImplemented(); 593 return validationMessageValueMissingText(); 594} 595 596String validationMessageTypeMismatchText() 597{ 598 notImplemented(); 599 return String::fromUTF8(_("type mismatch")); 600} 601 602String validationMessageTypeMismatchForEmailText() 603{ 604 notImplemented(); 605 return validationMessageTypeMismatchText(); 606} 607 608String validationMessageTypeMismatchForMultipleEmailText() 609{ 610 notImplemented(); 611 return validationMessageTypeMismatchText(); 612} 613 614String validationMessageTypeMismatchForURLText() 615{ 616 notImplemented(); 617 return validationMessageTypeMismatchText(); 618} 619 620String validationMessagePatternMismatchText() 621{ 622 return String::fromUTF8(_("pattern mismatch")); 623} 624 625String validationMessageTooLongText(int, int) 626{ 627 return String::fromUTF8(_("too long")); 628} 629 630String validationMessageRangeUnderflowText(const String&) 631{ 632 return String::fromUTF8(_("range underflow")); 633} 634 635String validationMessageRangeOverflowText(const String&) 636{ 637 return String::fromUTF8(_("range overflow")); 638} 639 640String validationMessageStepMismatchText(const String&, const String&) 641{ 642 return String::fromUTF8(_("step mismatch")); 643} 644 645String localizedString(const char* key) 646{ 647 return String::fromUTF8(key, strlen(key)); 648} 649 650} 651