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 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 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#include "LocalizedStrings.h"
33
34#include "IntSize.h"
35#include "NotImplemented.h"
36#include <glib/gi18n-lib.h>
37#include <gtk/gtk.h>
38#include <wtf/MathExtras.h>
39#include <wtf/gobject/GUniquePtr.h>
40#include <wtf/text/CString.h>
41#include <wtf/text/WTFString.h>
42
43namespace WebCore {
44
45static 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
53String submitButtonDefaultLabel()
54{
55    return String::fromUTF8(_("Submit"));
56}
57
58String inputElementAltText()
59{
60    return String::fromUTF8(_("Submit"));
61}
62
63String resetButtonDefaultLabel()
64{
65    return String::fromUTF8(_("Reset"));
66}
67
68String defaultDetailsSummaryText()
69{
70    return String::fromUTF8(_("Details"));
71}
72
73String searchableIndexIntroduction()
74{
75    return String::fromUTF8(_("This is a searchable index. Enter search keywords: "));
76}
77
78String fileButtonChooseFileLabel()
79{
80    return String::fromUTF8(_("Choose File"));
81}
82
83String fileButtonChooseMultipleFilesLabel()
84{
85    return String::fromUTF8(_("Choose Files"));
86}
87
88String fileButtonNoFileSelectedLabel()
89{
90    return String::fromUTF8(_("(None)"));
91}
92
93String fileButtonNoFilesSelectedLabel()
94{
95    return String::fromUTF8(_("(None)"));
96}
97
98String contextMenuItemTagOpenLinkInNewWindow()
99{
100    return String::fromUTF8(_("Open Link in New _Window"));
101}
102
103String contextMenuItemTagDownloadLinkToDisk()
104{
105    return String::fromUTF8(_("_Download Linked File"));
106}
107
108String contextMenuItemTagCopyLinkToClipboard()
109{
110    return String::fromUTF8(_("Copy Link Loc_ation"));
111}
112
113String contextMenuItemTagOpenImageInNewWindow()
114{
115    return String::fromUTF8(_("Open _Image in New Window"));
116}
117
118String contextMenuItemTagDownloadImageToDisk()
119{
120    return String::fromUTF8(_("Sa_ve Image As"));
121}
122
123String contextMenuItemTagCopyImageToClipboard()
124{
125    return String::fromUTF8(_("Cop_y Image"));
126}
127
128String contextMenuItemTagCopyImageUrlToClipboard()
129{
130    return String::fromUTF8(_("Copy Image _Address"));
131}
132
133String contextMenuItemTagOpenVideoInNewWindow()
134{
135    return String::fromUTF8(_("Open _Video in New Window"));
136}
137
138String contextMenuItemTagOpenAudioInNewWindow()
139{
140    return String::fromUTF8(_("Open _Audio in New Window"));
141}
142
143String contextMenuItemTagDownloadVideoToDisk()
144{
145    return String::fromUTF8(_("Download _Video"));
146}
147
148String contextMenuItemTagDownloadAudioToDisk()
149{
150    return String::fromUTF8(_("Download _Audio"));
151}
152
153String contextMenuItemTagCopyVideoLinkToClipboard()
154{
155    return String::fromUTF8(_("Cop_y Video Link Location"));
156}
157
158String contextMenuItemTagCopyAudioLinkToClipboard()
159{
160    return String::fromUTF8(_("Cop_y Audio Link Location"));
161}
162
163String contextMenuItemTagToggleMediaControls()
164{
165    return String::fromUTF8(_("_Toggle Media Controls"));
166}
167
168String contextMenuItemTagShowMediaControls()
169{
170    return String::fromUTF8(_("_Show Media Controls"));
171}
172
173String contextMenuItemTagHideMediaControls()
174{
175    return String::fromUTF8(_("_Hide Media Controls"));
176}
177
178String contextMenuItemTagToggleMediaLoop()
179{
180    return String::fromUTF8(_("Toggle Media _Loop Playback"));
181}
182
183String contextMenuItemTagEnterVideoFullscreen()
184{
185    return String::fromUTF8(_("Switch Video to _Fullscreen"));
186}
187
188String contextMenuItemTagMediaPlay()
189{
190    return String::fromUTF8(_("_Play"));
191}
192
193String contextMenuItemTagMediaPause()
194{
195    return String::fromUTF8(_("_Pause"));
196}
197
198String contextMenuItemTagMediaMute()
199{
200    return String::fromUTF8(_("_Mute"));
201}
202
203String contextMenuItemTagOpenFrameInNewWindow()
204{
205    return String::fromUTF8(_("Open _Frame in New Window"));
206}
207
208String contextMenuItemTagCopy()
209{
210    static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_COPY));
211    return stockLabel;
212}
213
214String contextMenuItemTagDelete()
215{
216    static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_DELETE));
217    return stockLabel;
218}
219
220String contextMenuItemTagSelectAll()
221{
222    static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_SELECT_ALL));
223    return stockLabel;
224}
225
226String contextMenuItemTagUnicode()
227{
228    return String::fromUTF8(_("_Insert Unicode Control Character"));
229}
230
231String contextMenuItemTagInputMethods()
232{
233    return String::fromUTF8(_("Input _Methods"));
234}
235
236String contextMenuItemTagGoBack()
237{
238    static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_GO_BACK));
239    return stockLabel;
240}
241
242String contextMenuItemTagGoForward()
243{
244    static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_GO_FORWARD));
245    return stockLabel;
246}
247
248String contextMenuItemTagStop()
249{
250    static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_STOP));
251    return stockLabel;
252}
253
254String contextMenuItemTagReload()
255{
256    return String::fromUTF8(_("_Reload"));
257}
258
259String contextMenuItemTagCut()
260{
261    static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_CUT));
262    return stockLabel;
263}
264
265String contextMenuItemTagPaste()
266{
267    static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_PASTE));
268    return stockLabel;
269}
270
271String contextMenuItemTagNoGuessesFound()
272{
273    return String::fromUTF8(_("No Guesses Found"));
274}
275
276String contextMenuItemTagIgnoreSpelling()
277{
278    return String::fromUTF8(_("_Ignore Spelling"));
279}
280
281String contextMenuItemTagLearnSpelling()
282{
283    return String::fromUTF8(_("_Learn Spelling"));
284}
285
286String contextMenuItemTagSearchWeb()
287{
288    return String::fromUTF8(_("_Search the Web"));
289}
290
291String contextMenuItemTagLookUpInDictionary(const String&)
292{
293    return String::fromUTF8(_("_Look Up in Dictionary"));
294}
295
296String contextMenuItemTagOpenLink()
297{
298    return String::fromUTF8(_("_Open Link"));
299}
300
301String contextMenuItemTagIgnoreGrammar()
302{
303    return String::fromUTF8(_("Ignore _Grammar"));
304}
305
306String contextMenuItemTagSpellingMenu()
307{
308    return String::fromUTF8(_("Spelling and _Grammar"));
309}
310
311String contextMenuItemTagShowSpellingPanel(bool show)
312{
313    return String::fromUTF8(show ? _("_Show Spelling and Grammar") : _("_Hide Spelling and Grammar"));
314}
315
316String contextMenuItemTagCheckSpelling()
317{
318    return String::fromUTF8(_("_Check Document Now"));
319}
320
321String contextMenuItemTagCheckSpellingWhileTyping()
322{
323    return String::fromUTF8(_("Check Spelling While _Typing"));
324}
325
326String contextMenuItemTagCheckGrammarWithSpelling()
327{
328    return String::fromUTF8(_("Check _Grammar With Spelling"));
329}
330
331String contextMenuItemTagFontMenu()
332{
333    return String::fromUTF8(_("_Font"));
334}
335
336String contextMenuItemTagBold()
337{
338    static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_BOLD));
339    return stockLabel;
340}
341
342String contextMenuItemTagItalic()
343{
344    static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_ITALIC));
345    return stockLabel;
346}
347
348String contextMenuItemTagUnderline()
349{
350    static String stockLabel = String::fromUTF8(gtkStockLabel(GTK_STOCK_UNDERLINE));
351    return stockLabel;
352}
353
354String contextMenuItemTagOutline()
355{
356    return String::fromUTF8(_("_Outline"));
357}
358
359String contextMenuItemTagInspectElement()
360{
361    return String::fromUTF8(_("Inspect _Element"));
362}
363
364String contextMenuItemTagUnicodeInsertLRMMark()
365{
366    return String::fromUTF8(_("LRM _Left-to-right mark"));
367}
368
369String contextMenuItemTagUnicodeInsertRLMMark()
370{
371    return String::fromUTF8(_("RLM _Right-to-left mark"));
372}
373
374String contextMenuItemTagUnicodeInsertLREMark()
375{
376    return String::fromUTF8(_("LRE Left-to-right _embedding"));
377}
378
379String contextMenuItemTagUnicodeInsertRLEMark()
380{
381    return String::fromUTF8(_("RLE Right-to-left e_mbedding"));
382}
383
384String contextMenuItemTagUnicodeInsertLROMark()
385{
386    return String::fromUTF8(_("LRO Left-to-right _override"));
387}
388
389String contextMenuItemTagUnicodeInsertRLOMark()
390{
391    return String::fromUTF8(_("RLO Right-to-left o_verride"));
392}
393
394String contextMenuItemTagUnicodeInsertPDFMark()
395{
396    return String::fromUTF8(_("PDF _Pop directional formatting"));
397}
398
399String contextMenuItemTagUnicodeInsertZWSMark()
400{
401    return String::fromUTF8(_("ZWS _Zero width space"));
402}
403
404String contextMenuItemTagUnicodeInsertZWJMark()
405{
406    return String::fromUTF8(_("ZWJ Zero width _joiner"));
407}
408
409String contextMenuItemTagUnicodeInsertZWNJMark()
410{
411    return String::fromUTF8(_("ZWNJ Zero width _non-joiner"));
412}
413
414String searchMenuNoRecentSearchesText()
415{
416    return String::fromUTF8(_("No recent searches"));
417}
418
419String searchMenuRecentSearchesText()
420{
421    return String::fromUTF8(_("Recent searches"));
422}
423
424String searchMenuClearRecentSearchesText()
425{
426    return String::fromUTF8(_("_Clear recent searches"));
427}
428
429String AXDefinitionText()
430{
431    return String::fromUTF8(_("definition"));
432}
433
434String AXDescriptionListText()
435{
436    return String::fromUTF8(_("description list"));
437}
438
439String AXDescriptionListTermText()
440{
441    return String::fromUTF8(_("term"));
442}
443
444String AXDescriptionListDetailText()
445{
446    return String::fromUTF8(_("description"));
447}
448
449String AXFooterRoleDescriptionText()
450{
451    return String::fromUTF8(_("footer"));
452}
453
454String AXSearchFieldCancelButtonText()
455{
456    return String::fromUTF8(_("cancel"));
457}
458
459String AXButtonActionVerb()
460{
461    return String::fromUTF8(_("press"));
462}
463
464String AXRadioButtonActionVerb()
465{
466    return String::fromUTF8(_("select"));
467}
468
469String AXTextFieldActionVerb()
470{
471    return String::fromUTF8(_("activate"));
472}
473
474String AXCheckedCheckBoxActionVerb()
475{
476    return String::fromUTF8(_("uncheck"));
477}
478
479String AXUncheckedCheckBoxActionVerb()
480{
481    return String::fromUTF8(_("check"));
482}
483
484String AXLinkActionVerb()
485{
486    return String::fromUTF8(_("jump"));
487}
488
489String AXMenuListPopupActionVerb()
490{
491    return String();
492}
493
494String AXMenuListActionVerb()
495{
496    return String();
497}
498
499String AXListItemActionVerb()
500{
501    return String();
502}
503
504String missingPluginText()
505{
506    return String::fromUTF8(_("Missing Plug-in"));
507}
508
509String crashedPluginText()
510{
511    notImplemented();
512    return String::fromUTF8(_("Plug-in Failure"));
513}
514
515String blockedPluginByContentSecurityPolicyText()
516{
517    notImplemented();
518    return String();
519}
520
521String insecurePluginVersionText()
522{
523    notImplemented();
524    return String();
525}
526
527String inactivePluginText()
528{
529    notImplemented();
530    return String();
531}
532
533String multipleFileUploadText(unsigned numberOfFiles)
534{
535    // FIXME: If this file gets localized, this should really be localized as one string with a wildcard for the number.
536    return String::number(numberOfFiles) + String::fromUTF8(_(" files"));
537}
538
539String unknownFileSizeText()
540{
541    return String::fromUTF8(_("Unknown"));
542}
543
544String imageTitle(const String& filename, const IntSize& size)
545{
546    GUniquePtr<gchar> string(g_strdup_printf(C_("Title string for images", "%s  (%dx%d pixels)"),
547        filename.utf8().data(), size.width(), size.height()));
548
549    return String::fromUTF8(string.get());
550}
551
552
553#if ENABLE(VIDEO)
554
555String mediaElementLoadingStateText()
556{
557    return String::fromUTF8(_("Loading..."));
558}
559
560String mediaElementLiveBroadcastStateText()
561{
562    return String::fromUTF8(_("Live Broadcast"));
563}
564
565String localizedMediaControlElementString(const String& name)
566{
567    if (name == "AudioElement")
568        return String::fromUTF8(_("audio playback"));
569    if (name == "VideoElement")
570        return String::fromUTF8(_("video playback"));
571    if (name == "MuteButton")
572        return String::fromUTF8(_("mute"));
573    if (name == "UnMuteButton")
574        return String::fromUTF8(_("unmute"));
575    if (name == "PlayButton")
576        return String::fromUTF8(_("play"));
577    if (name == "PauseButton")
578        return String::fromUTF8(_("pause"));
579    if (name == "Slider")
580        return String::fromUTF8(_("movie time"));
581    if (name == "SliderThumb")
582        return String::fromUTF8(_("timeline slider thumb"));
583    if (name == "RewindButton")
584        return String::fromUTF8(_("back 30 seconds"));
585    if (name == "ReturnToRealtimeButton")
586        return String::fromUTF8(_("return to realtime"));
587    if (name == "CurrentTimeDisplay")
588        return String::fromUTF8(_("elapsed time"));
589    if (name == "TimeRemainingDisplay")
590        return String::fromUTF8(_("remaining time"));
591    if (name == "StatusDisplay")
592        return String::fromUTF8(_("status"));
593    if (name == "EnterFullscreenButton")
594        return String::fromUTF8(_("enter fullscreen"));
595    if (name == "ExitFullscreenButton")
596        return String::fromUTF8(_("exit fullscreen"));
597    if (name == "SeekForwardButton")
598        return String::fromUTF8(_("fast forward"));
599    if (name == "SeekBackButton")
600        return String::fromUTF8(_("fast reverse"));
601    if (name == "ShowClosedCaptionsButton")
602        return String::fromUTF8(_("show closed captions"));
603    if (name == "HideClosedCaptionsButton")
604        return String::fromUTF8(_("hide closed captions"));
605    if (name == "ControlsPanel")
606        return String::fromUTF8(_("media controls"));
607
608    ASSERT_NOT_REACHED();
609    return String();
610}
611
612String localizedMediaControlElementHelpText(const String& name)
613{
614    if (name == "AudioElement")
615        return String::fromUTF8(_("audio element playback controls and status display"));
616    if (name == "VideoElement")
617        return String::fromUTF8(_("video element playback controls and status display"));
618    if (name == "MuteButton")
619        return String::fromUTF8(_("mute audio tracks"));
620    if (name == "UnMuteButton")
621        return String::fromUTF8(_("unmute audio tracks"));
622    if (name == "PlayButton")
623        return String::fromUTF8(_("begin playback"));
624    if (name == "PauseButton")
625        return String::fromUTF8(_("pause playback"));
626    if (name == "Slider")
627        return String::fromUTF8(_("movie time scrubber"));
628    if (name == "SliderThumb")
629        return String::fromUTF8(_("movie time scrubber thumb"));
630    if (name == "RewindButton")
631        return String::fromUTF8(_("seek movie back 30 seconds"));
632    if (name == "ReturnToRealtimeButton")
633        return String::fromUTF8(_("return streaming movie to real time"));
634    if (name == "CurrentTimeDisplay")
635        return String::fromUTF8(_("current movie time in seconds"));
636    if (name == "TimeRemainingDisplay")
637        return String::fromUTF8(_("number of seconds of movie remaining"));
638    if (name == "StatusDisplay")
639        return String::fromUTF8(_("current movie status"));
640    if (name == "SeekBackButton")
641        return String::fromUTF8(_("seek quickly back"));
642    if (name == "SeekForwardButton")
643        return String::fromUTF8(_("seek quickly forward"));
644    if (name == "EnterFullscreenButton")
645        return String::fromUTF8(_("Play movie in fullscreen mode"));
646    if (name == "EnterFullscreenButton")
647        return String::fromUTF8(_("Exit fullscreen mode"));
648    if (name == "ShowClosedCaptionsButton")
649        return String::fromUTF8(_("start displaying closed captions"));
650    if (name == "HideClosedCaptionsButton")
651        return String::fromUTF8(_("stop displaying closed captions"));
652
653    ASSERT_NOT_REACHED();
654    return String();
655}
656
657String localizedMediaTimeDescription(float time)
658{
659    if (!std::isfinite(time))
660        return String::fromUTF8(_("indefinite time"));
661
662    int seconds = static_cast<int>(abs(time));
663    int days = seconds / (60 * 60 * 24);
664    int hours = seconds / (60 * 60);
665    int minutes = (seconds / 60) % 60;
666    seconds %= 60;
667
668    if (days) {
669        GUniquePtr<gchar> string(g_strdup_printf("%d days %d hours %d minutes %d seconds", days, hours, minutes, seconds));
670        return String::fromUTF8(string.get());
671    }
672
673    if (hours) {
674        GUniquePtr<gchar> string(g_strdup_printf("%d hours %d minutes %d seconds", hours, minutes, seconds));
675        return String::fromUTF8(string.get());
676    }
677
678    if (minutes) {
679        GUniquePtr<gchar> string(g_strdup_printf("%d minutes %d seconds", minutes, seconds));
680        return String::fromUTF8(string.get());
681    }
682
683    GUniquePtr<gchar> string(g_strdup_printf("%d seconds", seconds));
684    return String::fromUTF8(string.get());
685}
686#endif  // ENABLE(VIDEO)
687
688String validationMessageValueMissingText()
689{
690    return String::fromUTF8(_("value missing"));
691}
692
693String validationMessageValueMissingForCheckboxText()
694{
695    notImplemented();
696    return validationMessageValueMissingText();
697}
698
699String validationMessageValueMissingForFileText()
700{
701    notImplemented();
702    return validationMessageValueMissingText();
703}
704
705String validationMessageValueMissingForMultipleFileText()
706{
707    notImplemented();
708    return validationMessageValueMissingText();
709}
710
711String validationMessageValueMissingForRadioText()
712{
713    notImplemented();
714    return validationMessageValueMissingText();
715}
716
717String validationMessageValueMissingForSelectText()
718{
719    notImplemented();
720    return validationMessageValueMissingText();
721}
722
723String validationMessageTypeMismatchText()
724{
725    notImplemented();
726    return String::fromUTF8(_("type mismatch"));
727}
728
729String validationMessageTypeMismatchForEmailText()
730{
731    notImplemented();
732    return validationMessageTypeMismatchText();
733}
734
735String validationMessageTypeMismatchForMultipleEmailText()
736{
737    notImplemented();
738    return validationMessageTypeMismatchText();
739}
740
741String validationMessageTypeMismatchForURLText()
742{
743    notImplemented();
744    return validationMessageTypeMismatchText();
745}
746
747String validationMessagePatternMismatchText()
748{
749    return String::fromUTF8(_("pattern mismatch"));
750}
751
752String validationMessageTooLongText(int, int)
753{
754    return String::fromUTF8(_("too long"));
755}
756
757String validationMessageRangeUnderflowText(const String&)
758{
759    return String::fromUTF8(_("range underflow"));
760}
761
762String validationMessageRangeOverflowText(const String&)
763{
764    return String::fromUTF8(_("range overflow"));
765}
766
767String validationMessageStepMismatchText(const String&, const String&)
768{
769    return String::fromUTF8(_("step mismatch"));
770}
771
772String unacceptableTLSCertificate()
773{
774    return String::fromUTF8(_("Unacceptable TLS certificate"));
775}
776
777String localizedString(const char* key)
778{
779    return String::fromUTF8(key, strlen(key));
780}
781
782String validationMessageBadInputForNumberText()
783{
784    notImplemented();
785    return validationMessageTypeMismatchText();
786}
787
788#if ENABLE(VIDEO_TRACK)
789String textTrackClosedCaptionsText()
790{
791    return String::fromUTF8(C_("Closed Captions", "Menu section heading for closed captions"));
792}
793
794String textTrackSubtitlesText()
795{
796    return String::fromUTF8(C_("Menu section heading for subtitles", "Subtitles"));
797}
798
799String textTrackOffMenuItemText()
800{
801    return String::fromUTF8(C_("Menu item label for the track that represents disabling closed captions", "Off"));
802}
803
804String textTrackAutomaticMenuItemText()
805{
806    return String::fromUTF8(C_("Menu item label for the automatically choosen track", "Auto"));
807}
808
809String textTrackNoLabelText()
810{
811    return String::fromUTF8(C_("Menu item label for a closed captions track that has no other name", "No label"));
812}
813#endif
814
815String snapshottedPlugInLabelTitle()
816{
817    return String::fromUTF8(C_("Snapshotted Plug-In", "Title of the label to show on a snapshotted plug-in"));
818}
819
820String snapshottedPlugInLabelSubtitle()
821{
822    return String::fromUTF8(C_("Click to restart", "Subtitle of the label to show on a snapshotted plug-in"));
823}
824
825}
826