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