• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
44 namespace WebCore {
45 
gtkStockLabel(const char * stockID)46 static 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 
submitButtonDefaultLabel()54 String submitButtonDefaultLabel()
55 {
56     return String::fromUTF8(_("Submit"));
57 }
58 
inputElementAltText()59 String inputElementAltText()
60 {
61     return String::fromUTF8(_("Submit"));
62 }
63 
resetButtonDefaultLabel()64 String resetButtonDefaultLabel()
65 {
66     return String::fromUTF8(_("Reset"));
67 }
68 
defaultDetailsSummaryText()69 String defaultDetailsSummaryText()
70 {
71     return String::fromUTF8(_("Details"));
72 }
73 
searchableIndexIntroduction()74 String searchableIndexIntroduction()
75 {
76     return String::fromUTF8(_("This is a searchable index. Enter search keywords: "));
77 }
78 
fileButtonChooseFileLabel()79 String fileButtonChooseFileLabel()
80 {
81     return String::fromUTF8(_("Choose File"));
82 }
83 
fileButtonNoFileSelectedLabel()84 String fileButtonNoFileSelectedLabel()
85 {
86     return String::fromUTF8(_("(None)"));
87 }
88 
contextMenuItemTagOpenLinkInNewWindow()89 String contextMenuItemTagOpenLinkInNewWindow()
90 {
91     return String::fromUTF8(_("Open Link in New _Window"));
92 }
93 
contextMenuItemTagDownloadLinkToDisk()94 String contextMenuItemTagDownloadLinkToDisk()
95 {
96     return String::fromUTF8(_("_Download Linked File"));
97 }
98 
contextMenuItemTagCopyLinkToClipboard()99 String contextMenuItemTagCopyLinkToClipboard()
100 {
101     return String::fromUTF8(_("Copy Link Loc_ation"));
102 }
103 
contextMenuItemTagOpenImageInNewWindow()104 String contextMenuItemTagOpenImageInNewWindow()
105 {
106     return String::fromUTF8(_("Open _Image in New Window"));
107 }
108 
contextMenuItemTagDownloadImageToDisk()109 String contextMenuItemTagDownloadImageToDisk()
110 {
111     return String::fromUTF8(_("Sa_ve Image As"));
112 }
113 
contextMenuItemTagCopyImageToClipboard()114 String contextMenuItemTagCopyImageToClipboard()
115 {
116     return String::fromUTF8(_("Cop_y Image"));
117 }
118 
contextMenuItemTagCopyImageUrlToClipboard()119 String contextMenuItemTagCopyImageUrlToClipboard()
120 {
121     return String::fromUTF8(_("Copy Image _Address"));
122 }
123 
contextMenuItemTagOpenVideoInNewWindow()124 String contextMenuItemTagOpenVideoInNewWindow()
125 {
126     return String::fromUTF8(_("Open _Video in New Window"));
127 }
128 
contextMenuItemTagOpenAudioInNewWindow()129 String contextMenuItemTagOpenAudioInNewWindow()
130 {
131     return String::fromUTF8(_("Open _Audio in New Window"));
132 }
133 
contextMenuItemTagCopyVideoLinkToClipboard()134 String contextMenuItemTagCopyVideoLinkToClipboard()
135 {
136     return String::fromUTF8(_("Cop_y Video Link Location"));
137 }
138 
contextMenuItemTagCopyAudioLinkToClipboard()139 String contextMenuItemTagCopyAudioLinkToClipboard()
140 {
141     return String::fromUTF8(_("Cop_y Audio Link Location"));
142 }
143 
contextMenuItemTagToggleMediaControls()144 String contextMenuItemTagToggleMediaControls()
145 {
146     return String::fromUTF8(_("_Toggle Media Controls"));
147 }
148 
contextMenuItemTagToggleMediaLoop()149 String contextMenuItemTagToggleMediaLoop()
150 {
151     return String::fromUTF8(_("Toggle Media _Loop Playback"));
152 }
153 
contextMenuItemTagEnterVideoFullscreen()154 String contextMenuItemTagEnterVideoFullscreen()
155 {
156     return String::fromUTF8(_("Switch Video to _Fullscreen"));
157 }
158 
contextMenuItemTagMediaPlay()159 String contextMenuItemTagMediaPlay()
160 {
161     return String::fromUTF8(_("_Play"));
162 }
163 
contextMenuItemTagMediaPause()164 String contextMenuItemTagMediaPause()
165 {
166     return String::fromUTF8(_("_Pause"));
167 }
168 
contextMenuItemTagMediaMute()169 String contextMenuItemTagMediaMute()
170 {
171     return String::fromUTF8(_("_Mute"));
172 }
173 
contextMenuItemTagOpenFrameInNewWindow()174 String contextMenuItemTagOpenFrameInNewWindow()
175 {
176     return String::fromUTF8(_("Open _Frame in New Window"));
177 }
178 
contextMenuItemTagCopy()179 String contextMenuItemTagCopy()
180 {
181     static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_COPY));
182     return stockLabel;
183 }
184 
contextMenuItemTagDelete()185 String contextMenuItemTagDelete()
186 {
187     static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_DELETE));
188     return stockLabel;
189 }
190 
contextMenuItemTagSelectAll()191 String contextMenuItemTagSelectAll()
192 {
193     static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_SELECT_ALL));
194     return stockLabel;
195 }
196 
contextMenuItemTagUnicode()197 String contextMenuItemTagUnicode()
198 {
199     return String::fromUTF8(_("_Insert Unicode Control Character"));
200 }
201 
contextMenuItemTagInputMethods()202 String contextMenuItemTagInputMethods()
203 {
204     return String::fromUTF8(_("Input _Methods"));
205 }
206 
contextMenuItemTagGoBack()207 String contextMenuItemTagGoBack()
208 {
209     static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_GO_BACK));
210     return stockLabel;
211 }
212 
contextMenuItemTagGoForward()213 String contextMenuItemTagGoForward()
214 {
215     static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_GO_FORWARD));
216     return stockLabel;
217 }
218 
contextMenuItemTagStop()219 String contextMenuItemTagStop()
220 {
221     static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_STOP));
222     return stockLabel;
223 }
224 
contextMenuItemTagReload()225 String contextMenuItemTagReload()
226 {
227     return String::fromUTF8(_("_Reload"));
228 }
229 
contextMenuItemTagCut()230 String contextMenuItemTagCut()
231 {
232     static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_CUT));
233     return stockLabel;
234 }
235 
contextMenuItemTagPaste()236 String contextMenuItemTagPaste()
237 {
238     static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_PASTE));
239     return stockLabel;
240 }
241 
contextMenuItemTagNoGuessesFound()242 String contextMenuItemTagNoGuessesFound()
243 {
244     return String::fromUTF8(_("No Guesses Found"));
245 }
246 
contextMenuItemTagIgnoreSpelling()247 String contextMenuItemTagIgnoreSpelling()
248 {
249     return String::fromUTF8(_("_Ignore Spelling"));
250 }
251 
contextMenuItemTagLearnSpelling()252 String contextMenuItemTagLearnSpelling()
253 {
254     return String::fromUTF8(_("_Learn Spelling"));
255 }
256 
contextMenuItemTagSearchWeb()257 String contextMenuItemTagSearchWeb()
258 {
259     return String::fromUTF8(_("_Search the Web"));
260 }
261 
contextMenuItemTagLookUpInDictionary(const String &)262 String contextMenuItemTagLookUpInDictionary(const String&)
263 {
264     return String::fromUTF8(_("_Look Up in Dictionary"));
265 }
266 
contextMenuItemTagOpenLink()267 String contextMenuItemTagOpenLink()
268 {
269     return String::fromUTF8(_("_Open Link"));
270 }
271 
contextMenuItemTagIgnoreGrammar()272 String contextMenuItemTagIgnoreGrammar()
273 {
274     return String::fromUTF8(_("Ignore _Grammar"));
275 }
276 
contextMenuItemTagSpellingMenu()277 String contextMenuItemTagSpellingMenu()
278 {
279     return String::fromUTF8(_("Spelling and _Grammar"));
280 }
281 
contextMenuItemTagShowSpellingPanel(bool show)282 String contextMenuItemTagShowSpellingPanel(bool show)
283 {
284     return String::fromUTF8(show ? _("_Show Spelling and Grammar") : _("_Hide Spelling and Grammar"));
285 }
286 
contextMenuItemTagCheckSpelling()287 String contextMenuItemTagCheckSpelling()
288 {
289     return String::fromUTF8(_("_Check Document Now"));
290 }
291 
contextMenuItemTagCheckSpellingWhileTyping()292 String contextMenuItemTagCheckSpellingWhileTyping()
293 {
294     return String::fromUTF8(_("Check Spelling While _Typing"));
295 }
296 
contextMenuItemTagCheckGrammarWithSpelling()297 String contextMenuItemTagCheckGrammarWithSpelling()
298 {
299     return String::fromUTF8(_("Check _Grammar With Spelling"));
300 }
301 
contextMenuItemTagFontMenu()302 String contextMenuItemTagFontMenu()
303 {
304     return String::fromUTF8(_("_Font"));
305 }
306 
contextMenuItemTagBold()307 String contextMenuItemTagBold()
308 {
309     static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_BOLD));
310     return stockLabel;
311 }
312 
contextMenuItemTagItalic()313 String contextMenuItemTagItalic()
314 {
315     static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_ITALIC));
316     return stockLabel;
317 }
318 
contextMenuItemTagUnderline()319 String contextMenuItemTagUnderline()
320 {
321     static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_UNDERLINE));
322     return stockLabel;
323 }
324 
contextMenuItemTagOutline()325 String contextMenuItemTagOutline()
326 {
327     return String::fromUTF8(_("_Outline"));
328 }
329 
contextMenuItemTagInspectElement()330 String contextMenuItemTagInspectElement()
331 {
332     return String::fromUTF8(_("Inspect _Element"));
333 }
334 
searchMenuNoRecentSearchesText()335 String searchMenuNoRecentSearchesText()
336 {
337     return String::fromUTF8(_("No recent searches"));
338 }
339 
searchMenuRecentSearchesText()340 String searchMenuRecentSearchesText()
341 {
342     return String::fromUTF8(_("Recent searches"));
343 }
344 
searchMenuClearRecentSearchesText()345 String searchMenuClearRecentSearchesText()
346 {
347     return String::fromUTF8(_("_Clear recent searches"));
348 }
349 
AXDefinitionListTermText()350 String AXDefinitionListTermText()
351 {
352     return String::fromUTF8(_("term"));
353 }
354 
AXDefinitionListDefinitionText()355 String AXDefinitionListDefinitionText()
356 {
357     return String::fromUTF8(_("definition"));
358 }
359 
AXButtonActionVerb()360 String AXButtonActionVerb()
361 {
362     return String::fromUTF8(_("press"));
363 }
364 
AXRadioButtonActionVerb()365 String AXRadioButtonActionVerb()
366 {
367     return String::fromUTF8(_("select"));
368 }
369 
AXTextFieldActionVerb()370 String AXTextFieldActionVerb()
371 {
372     return String::fromUTF8(_("activate"));
373 }
374 
AXCheckedCheckBoxActionVerb()375 String AXCheckedCheckBoxActionVerb()
376 {
377     return String::fromUTF8(_("uncheck"));
378 }
379 
AXUncheckedCheckBoxActionVerb()380 String AXUncheckedCheckBoxActionVerb()
381 {
382     return String::fromUTF8(_("check"));
383 }
384 
AXLinkActionVerb()385 String AXLinkActionVerb()
386 {
387     return String::fromUTF8(_("jump"));
388 }
389 
AXMenuListPopupActionVerb()390 String AXMenuListPopupActionVerb()
391 {
392     return String();
393 }
394 
AXMenuListActionVerb()395 String AXMenuListActionVerb()
396 {
397     return String();
398 }
399 
missingPluginText()400 String missingPluginText()
401 {
402     return String::fromUTF8(_("Missing Plug-in"));
403 }
404 
crashedPluginText()405 String crashedPluginText()
406 {
407     notImplemented();
408     return String::fromUTF8(_("Plug-in Failure"));
409 }
410 
multipleFileUploadText(unsigned numberOfFiles)411 String 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 
unknownFileSizeText()417 String unknownFileSizeText()
418 {
419     return String::fromUTF8(_("Unknown"));
420 }
421 
imageTitle(const String & filename,const IntSize & size)422 String 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 
mediaElementLoadingStateText()434 String mediaElementLoadingStateText()
435 {
436     return String::fromUTF8(_("Loading..."));
437 }
438 
mediaElementLiveBroadcastStateText()439 String mediaElementLiveBroadcastStateText()
440 {
441     return String::fromUTF8(_("Live Broadcast"));
442 }
443 
localizedMediaControlElementString(const String & name)444 String 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 
localizedMediaControlElementHelpText(const String & name)487 String 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 
localizedMediaTimeDescription(float time)530 String 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 
validationMessageValueMissingText()561 String validationMessageValueMissingText()
562 {
563     return String::fromUTF8(_("value missing"));
564 }
565 
validationMessageValueMissingForCheckboxText()566 String validationMessageValueMissingForCheckboxText()
567 {
568     notImplemented();
569     return validationMessageValueMissingText();
570 }
571 
validationMessageValueMissingForFileText()572 String validationMessageValueMissingForFileText()
573 {
574     notImplemented();
575     return validationMessageValueMissingText();
576 }
577 
validationMessageValueMissingForMultipleFileText()578 String validationMessageValueMissingForMultipleFileText()
579 {
580     notImplemented();
581     return validationMessageValueMissingText();
582 }
583 
validationMessageValueMissingForRadioText()584 String validationMessageValueMissingForRadioText()
585 {
586     notImplemented();
587     return validationMessageValueMissingText();
588 }
589 
validationMessageValueMissingForSelectText()590 String validationMessageValueMissingForSelectText()
591 {
592     notImplemented();
593     return validationMessageValueMissingText();
594 }
595 
validationMessageTypeMismatchText()596 String validationMessageTypeMismatchText()
597 {
598     notImplemented();
599     return String::fromUTF8(_("type mismatch"));
600 }
601 
validationMessageTypeMismatchForEmailText()602 String validationMessageTypeMismatchForEmailText()
603 {
604     notImplemented();
605     return validationMessageTypeMismatchText();
606 }
607 
validationMessageTypeMismatchForMultipleEmailText()608 String validationMessageTypeMismatchForMultipleEmailText()
609 {
610     notImplemented();
611     return validationMessageTypeMismatchText();
612 }
613 
validationMessageTypeMismatchForURLText()614 String validationMessageTypeMismatchForURLText()
615 {
616     notImplemented();
617     return validationMessageTypeMismatchText();
618 }
619 
validationMessagePatternMismatchText()620 String validationMessagePatternMismatchText()
621 {
622     return String::fromUTF8(_("pattern mismatch"));
623 }
624 
validationMessageTooLongText(int,int)625 String validationMessageTooLongText(int, int)
626 {
627     return String::fromUTF8(_("too long"));
628 }
629 
validationMessageRangeUnderflowText(const String &)630 String validationMessageRangeUnderflowText(const String&)
631 {
632     return String::fromUTF8(_("range underflow"));
633 }
634 
validationMessageRangeOverflowText(const String &)635 String validationMessageRangeOverflowText(const String&)
636 {
637     return String::fromUTF8(_("range overflow"));
638 }
639 
validationMessageStepMismatchText(const String &,const String &)640 String validationMessageStepMismatchText(const String&, const String&)
641 {
642     return String::fromUTF8(_("step mismatch"));
643 }
644 
localizedString(const char * key)645 String localizedString(const char* key)
646 {
647     return String::fromUTF8(key, strlen(key));
648 }
649 
650 }
651