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