1/*
2 * Copyright (C) 2003, 2006, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Igalia S.L
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#include "config.h"
28#include "LocalizedStrings.h"
29
30#include "IntSize.h"
31#include "NotImplemented.h"
32#include <wtf/MathExtras.h>
33#include <wtf/text/TextBreakIterator.h>
34#include <wtf/unicode/CharacterNames.h>
35
36#if USE(CF)
37#include <wtf/RetainPtr.h>
38#endif
39
40#if USE(GLIB)
41#include <wtf/glib/GUniquePtr.h>
42#endif
43
44namespace WebCore {
45
46// Because |format| is used as the second parameter to va_start, it cannot be a reference
47// type according to section 18.7/3 of the C++ N1905 standard.
48String formatLocalizedString(String format, ...)
49{
50#if USE(CF)
51 va_list arguments;
52 va_start(arguments, format);
53
54 ALLOW_NONLITERAL_FORMAT_BEGIN
55 auto result = adoptCF(CFStringCreateWithFormatAndArguments(0, 0, format.createCFString().get(), arguments));
56 ALLOW_NONLITERAL_FORMAT_END
57
58 va_end(arguments);
59 return result.get();
60#elif USE(GLIB)
61 va_list arguments;
62 va_start(arguments, format);
63 GUniquePtr<gchar> result(g_strdup_vprintf(format.utf8().data(), arguments));
64 va_end(arguments);
65 return String::fromUTF8(result.get());
66#else
67 notImplemented();
68 return format;
69#endif
70}
71
72#if !USE(CF)
73
74String localizedString(const char* key)
75{
76 return String::fromUTF8(key, strlen(key));
77}
78
79#endif
80
81#if ENABLE(CONTEXT_MENUS)
82
83static String truncatedStringForLookupMenuItem(const String& original)
84{
85 // Truncate the string if it's too long. This number is roughly the same as the one used by AppKit.
86 unsigned maxNumberOfGraphemeClustersInLookupMenuItem = 24;
87
88 String trimmed = original.stripWhiteSpace();
89 unsigned numberOfCharacters = numCodeUnitsInGraphemeClusters(trimmed, maxNumberOfGraphemeClustersInLookupMenuItem);
90 return numberOfCharacters == trimmed.length() ? trimmed : makeString(trimmed.left(numberOfCharacters), horizontalEllipsis);
91}
92
93#endif
94
95String inputElementAltText()
96{
97 return WEB_UI_STRING_KEY("Submit", "Submit (input element)", "alt text for <input> elements with no alt, title, or value");
98}
99
100String resetButtonDefaultLabel()
101{
102 return WEB_UI_STRING("Reset", "default label for Reset buttons in forms on web pages");
103}
104
105String searchableIndexIntroduction()
106{
107 return WEB_UI_STRING("This is a searchable index. Enter search keywords: ",
108 "text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index'");
109}
110
111String submitButtonDefaultLabel()
112{
113 return WEB_UI_STRING("Submit", "default label for Submit buttons in forms on web pages");
114}
115
116String fileButtonChooseFileLabel()
117{
118 return WEB_UI_STRING("Choose File", "title for a single file chooser button used in HTML forms");
119}
120
121String fileButtonChooseMultipleFilesLabel()
122{
123 return WEB_UI_STRING("Choose Files", "title for a multiple file chooser button used in HTML forms. This title should be as short as possible.");
124}
125
126String fileButtonNoFileSelectedLabel()
127{
128 return WEB_UI_STRING("no file selected", "text to display in file button used in HTML forms when no file is selected");
129}
130
131String fileButtonNoFilesSelectedLabel()
132{
133 return WEB_UI_STRING("no files selected", "text to display in file button used in HTML forms when no files are selected and the button allows multiple files to be selected");
134}
135
136String defaultDetailsSummaryText()
137{
138 return WEB_UI_STRING("Details", "text to display in <details> tag when it has no <summary> child");
139}
140
141#if ENABLE(CONTEXT_MENUS)
142
143String contextMenuItemTagOpenLinkInNewWindow()
144{
145 return WEB_UI_STRING_WITH_MNEMONIC("Open Link in New Window", "Open Link in New _Window", "Open in New Window context menu item");
146}
147
148String contextMenuItemTagDownloadLinkToDisk()
149{
150 return WEB_UI_STRING_WITH_MNEMONIC("Download Linked File", "_Download Linked File", "Download Linked File context menu item");
151}
152
153#if !PLATFORM(GTK)
154String contextMenuItemTagCopyLinkToClipboard()
155{
156 return WEB_UI_STRING("Copy Link", "Copy Link context menu item");
157}
158#endif
159
160String contextMenuItemTagOpenImageInNewWindow()
161{
162 return WEB_UI_STRING_WITH_MNEMONIC("Open Image in New Window", "Open _Image in New Window", "Open Image in New Window context menu item");
163}
164
165#if !PLATFORM(GTK)
166String contextMenuItemTagDownloadImageToDisk()
167{
168 return WEB_UI_STRING("Download Image", "Download Image context menu item");
169}
170#endif
171
172String contextMenuItemTagCopyImageToClipboard()
173{
174 return WEB_UI_STRING_WITH_MNEMONIC("Copy Image", "Cop_y Image", "Copy Image context menu item");
175}
176
177String contextMenuItemTagOpenFrameInNewWindow()
178{
179 return WEB_UI_STRING_WITH_MNEMONIC("Open Frame in New Window", "Open _Frame in New Window", "Open Frame in New Window context menu item");
180}
181
182String contextMenuItemTagCopy()
183{
184 return WEB_UI_STRING_WITH_MNEMONIC("Copy", "_Copy", "Copy context menu item");
185}
186
187String contextMenuItemTagGoBack()
188{
189 return WEB_UI_STRING_WITH_MNEMONIC("Back", "_Back", "Back context menu item");
190}
191
192String contextMenuItemTagGoForward()
193{
194 return WEB_UI_STRING_WITH_MNEMONIC("Forward", "_Forward", "Forward context menu item");
195}
196
197String contextMenuItemTagStop()
198{
199 return WEB_UI_STRING_WITH_MNEMONIC("Stop", "_Stop", "Stop context menu item");
200}
201
202String contextMenuItemTagReload()
203{
204 return WEB_UI_STRING_WITH_MNEMONIC("Reload", "_Reload", "Reload context menu item");
205}
206
207String contextMenuItemTagCut()
208{
209 return WEB_UI_STRING_WITH_MNEMONIC("Cut", "Cu_t", "Cut context menu item");
210}
211
212String contextMenuItemTagPaste()
213{
214 return WEB_UI_STRING_WITH_MNEMONIC("Paste", "_Paste", "Paste context menu item");
215}
216
217String contextMenuItemTagNoGuessesFound()
218{
219 return WEB_UI_STRING("No Guesses Found", "No Guesses Found context menu item");
220}
221
222String contextMenuItemTagIgnoreSpelling()
223{
224 return WEB_UI_STRING_WITH_MNEMONIC("Ignore Spelling", "_Ignore Spelling", "Ignore Spelling context menu item");
225}
226
227String contextMenuItemTagLearnSpelling()
228{
229 return WEB_UI_STRING_WITH_MNEMONIC("Learn Spelling", "_Learn Spelling", "Learn Spelling context menu item");
230}
231
232String contextMenuItemTagLookUpInDictionary(const String& selectedString)
233{
234#if USE(CF)
235 auto selectedCFString = truncatedStringForLookupMenuItem(selectedString).createCFString();
236 return formatLocalizedString(WEB_UI_CFSTRING("Look Up “%@”", "Look Up context menu item with selected word"), selectedCFString.get());
237#elif USE(GLIB)
238 return formatLocalizedString(WEB_UI_STRING("Look Up “%s”", "Look Up context menu item with selected word"), truncatedStringForLookupMenuItem(selectedString).utf8().data());
239#else
240 return WEB_UI_STRING("Look Up “<selection>”", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForLookupMenuItem(selectedString));
241#endif
242}
243
244String contextMenuItemTagOpenLink()
245{
246 return WEB_UI_STRING_WITH_MNEMONIC("Open Link", "_Open Link", "Open Link context menu item");
247}
248
249String contextMenuItemTagIgnoreGrammar()
250{
251 return WEB_UI_STRING_WITH_MNEMONIC("Ignore Grammar", "Ignore _Grammar", "Ignore Grammar context menu item");
252}
253
254String contextMenuItemTagSpellingMenu()
255{
256 return WEB_UI_STRING_WITH_MNEMONIC("Spelling and Grammar", "Spelling and _Grammar", "Spelling and Grammar context sub-menu item");
257}
258
259String contextMenuItemTagShowSpellingPanel(bool show)
260{
261 if (show)
262 return WEB_UI_STRING_WITH_MNEMONIC("Show Spelling and Grammar", "_Show Spelling and Grammar", "menu item title");
263 return WEB_UI_STRING_WITH_MNEMONIC("Hide Spelling and Grammar", "_Hide Spelling and Grammar", "menu item title");
264}
265
266String contextMenuItemTagCheckSpelling()
267{
268 return WEB_UI_STRING_WITH_MNEMONIC("Check Document Now", "_Check Document Now", "Check spelling context menu item");
269}
270
271String contextMenuItemTagCheckSpellingWhileTyping()
272{
273 return WEB_UI_STRING_WITH_MNEMONIC("Check Spelling While Typing", "Check Spelling While _Typing", "Check spelling while typing context menu item");
274}
275
276String contextMenuItemTagCheckGrammarWithSpelling()
277{
278 return WEB_UI_STRING_WITH_MNEMONIC("Check Grammar With Spelling", "Check _Grammar With Spelling", "Check grammar with spelling context menu item");
279}
280
281String contextMenuItemTagFontMenu()
282{
283 return WEB_UI_STRING_WITH_MNEMONIC("Font", "_Font", "Font context sub-menu item");
284}
285
286String contextMenuItemTagBold()
287{
288 return WEB_UI_STRING_WITH_MNEMONIC("Bold", "_Bold", "Bold context menu item");
289}
290
291String contextMenuItemTagItalic()
292{
293 return WEB_UI_STRING_WITH_MNEMONIC("Italic", "_Italic", "Italic context menu item");
294}
295
296String contextMenuItemTagUnderline()
297{
298 return WEB_UI_STRING_WITH_MNEMONIC("Underline", "_Underline", "Underline context menu item");
299}
300
301String contextMenuItemTagOutline()
302{
303 return WEB_UI_STRING_WITH_MNEMONIC("Outline", "_Outline", "Outline context menu item");
304}
305
306#if !PLATFORM(GTK)
307String contextMenuItemTagWritingDirectionMenu()
308{
309 return WEB_UI_STRING("Paragraph Direction", "Paragraph direction context sub-menu item");
310}
311
312String contextMenuItemTagTextDirectionMenu()
313{
314 return WEB_UI_STRING("Selection Direction", "Selection direction context sub-menu item");
315}
316
317String contextMenuItemTagDefaultDirection()
318{
319 return WEB_UI_STRING("Default", "Default writing direction context menu item");
320}
321
322String contextMenuItemTagLeftToRight()
323{
324 return WEB_UI_STRING("Left to Right", "Left to Right context menu item");
325}
326
327String contextMenuItemTagRightToLeft()
328{
329 return WEB_UI_STRING("Right to Left", "Right to Left context menu item");
330}
331#endif
332
333String contextMenuItemTagOpenVideoInNewWindow()
334{
335 return WEB_UI_STRING_WITH_MNEMONIC("Open Video in New Window", "Open _Video in New Window", "Open Video in New Window context menu item");
336}
337
338String contextMenuItemTagOpenAudioInNewWindow()
339{
340 return WEB_UI_STRING_WITH_MNEMONIC("Open Audio in New Window", "Open _Audio in New Window", "Open Audio in New Window context menu item");
341}
342
343String contextMenuItemTagDownloadVideoToDisk()
344{
345 return WEB_UI_STRING_WITH_MNEMONIC("Download Video", "Download _Video", "Download Video To Disk context menu item");
346}
347
348String contextMenuItemTagDownloadAudioToDisk()
349{
350 return WEB_UI_STRING_WITH_MNEMONIC("Download Audio", "Download _Audio", "Download Audio To Disk context menu item");
351}
352
353#if !PLATFORM(GTK)
354String contextMenuItemTagCopyVideoLinkToClipboard()
355{
356 return WEB_UI_STRING("Copy Video Address", "Copy Video Address Location context menu item");
357}
358
359String contextMenuItemTagCopyAudioLinkToClipboard()
360{
361 return WEB_UI_STRING("Copy Audio Address", "Copy Audio Address Location context menu item");
362}
363
364String contextMenuItemTagToggleMediaControls()
365{
366 return WEB_UI_STRING("Controls", "Media Controls context menu item");
367}
368
369String contextMenuItemTagShowMediaControls()
370{
371 return WEB_UI_STRING("Show Controls", "Show Media Controls context menu item");
372}
373
374String contextMenuItemTagHideMediaControls()
375{
376 return WEB_UI_STRING("Hide Controls", "Hide Media Controls context menu item");
377}
378
379String contextMenuItemTagToggleMediaLoop()
380{
381 return WEB_UI_STRING("Loop", "Media Loop context menu item");
382}
383
384String contextMenuItemTagEnterVideoFullscreen()
385{
386 return WEB_UI_STRING("Enter Full Screen", "Video Enter Full Screen context menu item");
387}
388
389String contextMenuItemTagExitVideoFullscreen()
390{
391 return WEB_UI_STRING_KEY("Exit Full Screen", "Exit Full Screen (context menu)", "Video Exit Full Screen context menu item");
392}
393#endif
394
395String contextMenuItemTagMediaPlay()
396{
397 return WEB_UI_STRING_WITH_MNEMONIC("Play", "_Play", "Media Play context menu item");
398}
399
400String contextMenuItemTagMediaPause()
401{
402 return WEB_UI_STRING_WITH_MNEMONIC("Pause", "_Pause", "Media Pause context menu item");
403}
404
405String contextMenuItemTagMediaMute()
406{
407 return WEB_UI_STRING_WITH_MNEMONIC("Mute", "_Mute", "Media Mute context menu item");
408}
409
410String contextMenuItemTagInspectElement()
411{
412 return WEB_UI_STRING_WITH_MNEMONIC("Inspect Element", "Inspect _Element", "Inspect Element context menu item");
413}
414
415#if !PLATFORM(COCOA)
416String contextMenuItemTagSearchWeb()
417{
418 return WEB_UI_STRING_WITH_MNEMONIC("Search the Web", "_Search the Web", "Search the Web context menu item");
419}
420#endif
421
422#endif // ENABLE(CONTEXT_MENUS)
423
424#if !PLATFORM(IOS_FAMILY)
425
426String searchMenuNoRecentSearchesText()
427{
428 return WEB_UI_STRING("No recent searches", "Label for only item in menu that appears when clicking on the search field image, when no searches have been performed");
429}
430
431String searchMenuRecentSearchesText()
432{
433 return WEB_UI_STRING("Recent Searches", "label for first item in the menu that appears when clicking on the search field image, used as embedded menu title");
434}
435
436String searchMenuClearRecentSearchesText()
437{
438 return WEB_UI_STRING("Clear Recent Searches", "menu item in Recent Searches menu that empties menu's contents");
439}
440
441#endif // !PLATFORM(IOS_FAMILY)
442
443String AXWebAreaText()
444{
445 return WEB_UI_STRING("HTML content", "accessibility role description for web area");
446}
447
448String AXLinkText()
449{
450 return WEB_UI_STRING("link", "accessibility role description for link");
451}
452
453String AXListMarkerText()
454{
455 return WEB_UI_STRING("list marker", "accessibility role description for list marker");
456}
457
458String AXImageMapText()
459{
460 return WEB_UI_STRING("image map", "accessibility role description for image map");
461}
462
463String AXHeadingText()
464{
465 return WEB_UI_STRING("heading", "accessibility role description for headings");
466}
467
468String AXColorWellText()
469{
470 return WEB_UI_STRING("color well", "accessibility role description for a color well");
471}
472
473String AXDefinitionText()
474{
475 return WEB_UI_STRING("definition", "role description of ARIA definition role");
476}
477
478String AXDescriptionListText()
479{
480 return WEB_UI_STRING("description list", "accessibility role description of a description list");
481}
482
483String AXDescriptionListTermText()
484{
485 return WEB_UI_STRING("term", "term word of a description list");
486}
487
488String AXDescriptionListDetailText()
489{
490 return WEB_UI_STRING("description", "description detail");
491}
492
493String AXDetailsText()
494{
495 return WEB_UI_STRING("details", "accessibility role description for a details element");
496}
497
498String AXSummaryText()
499{
500 return WEB_UI_STRING("summary", "accessibility role description for a summary element");
501}
502
503String AXFooterRoleDescriptionText()
504{
505 return WEB_UI_STRING("footer", "accessibility role description for a footer");
506}
507
508String AXFileUploadButtonText()
509{
510 return WEB_UI_STRING("file upload button", "accessibility role description for a file upload button");
511}
512
513String AXOutputText()
514{
515 return WEB_UI_STRING("output", "accessibility role description for an output element");
516}
517
518String AXAttachmentRoleText()
519{
520 return WEB_UI_STRING("attachment", "accessibility role description for an attachment element");
521}
522
523String AXSearchFieldCancelButtonText()
524{
525 return WEB_UI_STRING("cancel", "accessibility description for a search field cancel button");
526}
527
528String AXFeedText()
529{
530 return WEB_UI_STRING("feed", "accessibility role description for a group containing a scrollable list of articles.");
531}
532
533String AXFigureText()
534{
535 return WEB_UI_STRING("figure", "accessibility role description for a figure element.");
536}
537
538String AXEmailFieldText()
539{
540 return WEB_UI_STRING("email field", "accessibility role description for an email field.");
541}
542
543String AXTelephoneFieldText()
544{
545 return WEB_UI_STRING("telephone number field", "accessibility role description for a telephone number field.");
546}
547
548String AXURLFieldText()
549{
550 return WEB_UI_STRING("URL field", "accessibility role description for a URL field.");
551}
552
553String AXDateFieldText()
554{
555 return WEB_UI_STRING("date field", "accessibility role description for a date field.");
556}
557
558String AXTimeFieldText()
559{
560 return WEB_UI_STRING("time field", "accessibility role description for a time field.");
561}
562
563String AXDateTimeFieldText()
564{
565 return WEB_UI_STRING("date and time field", "accessibility role description for a date and time field.");
566}
567
568String AXMonthFieldText()
569{
570 return WEB_UI_STRING("month and year field", "accessibility role description for a month field.");
571}
572
573String AXNumberFieldText()
574{
575 return WEB_UI_STRING("number field", "accessibility role description for a number field.");
576}
577
578String AXWeekFieldText()
579{
580 return WEB_UI_STRING("week and year field", "accessibility role description for a time field.");
581}
582
583String AXButtonActionVerb()
584{
585 return WEB_UI_STRING("press", "Verb stating the action that will occur when a button is pressed, as used by accessibility");
586}
587
588String AXRadioButtonActionVerb()
589{
590 return WEB_UI_STRING("select", "Verb stating the action that will occur when a radio button is clicked, as used by accessibility");
591}
592
593String AXTextFieldActionVerb()
594{
595 return WEB_UI_STRING("activate", "Verb stating the action that will occur when a text field is selected, as used by accessibility");
596}
597
598String AXCheckedCheckBoxActionVerb()
599{
600 return WEB_UI_STRING("uncheck", "Verb stating the action that will occur when a checked checkbox is clicked, as used by accessibility");
601}
602
603String AXUncheckedCheckBoxActionVerb()
604{
605 return WEB_UI_STRING("check", "Verb stating the action that will occur when an unchecked checkbox is clicked, as used by accessibility");
606}
607
608String AXLinkActionVerb()
609{
610 return WEB_UI_STRING("jump", "Verb stating the action that will occur when a link is clicked, as used by accessibility");
611}
612
613String AXMenuListPopupActionVerb()
614{
615 notImplemented();
616 return "select";
617}
618
619String AXMenuListActionVerb()
620{
621 notImplemented();
622 return "select";
623}
624
625String AXListItemActionVerb()
626{
627 notImplemented();
628 return "select";
629}
630
631#if ENABLE(APPLE_PAY)
632String AXApplePayPlainLabel()
633{
634 return WEB_UI_STRING("Apple Pay", "Label for the plain Apple Pay button.");
635}
636
637String AXApplePayBuyLabel()
638{
639 return WEB_UI_STRING("Buy with Apple Pay", "Label for the buy with Apple Pay button.");
640}
641
642String AXApplePaySetupLabel()
643{
644 return WEB_UI_STRING("Set up with Apple Pay", "Label for the set up with Apple Pay button.");
645}
646
647String AXApplePayDonateLabel()
648{
649 return WEB_UI_STRING("Donate with Apple Pay", "Label for the donate with Apple Pay button.");
650}
651
652String AXApplePayCheckOutLabel()
653{
654 return WEB_UI_STRING("Check out with Apple Pay", "Label for the check out with Apple Pay button.");
655}
656
657String AXApplePayBookLabel()
658{
659 return WEB_UI_STRING("Book with Apple Pay", "Label for the book with Apple Pay button.");
660}
661
662String AXApplePaySubscribeLabel()
663{
664 return WEB_UI_STRING("Subscribe with Apple Pay", "Label for the subcribe with Apple Pay button.");
665}
666#endif
667
668String AXAutoFillCredentialsLabel()
669{
670 return WEB_UI_STRING("password AutoFill", "Label for the AutoFill credentials button inside a text field.");
671}
672
673String AXAutoFillContactsLabel()
674{
675 return WEB_UI_STRING("contact info AutoFill", "Label for the AutoFill contacts button inside a text field.");
676}
677
678String AXAutoFillStrongPasswordLabel()
679{
680 return WEB_UI_STRING("strong password AutoFill", "Label for the strong password AutoFill button inside a text field.");
681}
682
683String AXAutoFillCreditCardLabel()
684{
685 return WEB_UI_STRING("credit card AutoFill", "Label for the credit card AutoFill button inside a text field.");
686}
687
688String autoFillStrongPasswordLabel()
689{
690 return WEB_UI_STRING("Strong Password", "Label for strong password.");
691}
692
693String missingPluginText()
694{
695 return WEB_UI_STRING("Missing Plug-in", "Label text to be used when a plugin is missing");
696}
697
698String crashedPluginText()
699{
700 return WEB_UI_STRING("Plug-in Failure", "Label text to be used if plugin host process has crashed");
701}
702
703String blockedPluginByContentSecurityPolicyText()
704{
705 return WEB_UI_STRING_KEY("Blocked Plug-in", "Blocked Plug-In (Blocked by page's Content Security Policy)", "Label text to be used if plugin is blocked by a page's Content Security Policy");
706}
707
708String insecurePluginVersionText()
709{
710 return WEB_UI_STRING_KEY("Blocked Plug-in", "Blocked Plug-In (Insecure plug-in)", "Label text to be used when an insecure plug-in version was blocked from loading");
711}
712
713String unsupportedPluginText()
714{
715 return WEB_UI_STRING_KEY("Unsupported Plug-in", "Unsupported Plug-In", "Label text to be used when an unsupported plug-in was blocked from loading");
716}
717
718String pluginTooSmallText()
719{
720 return WEB_UI_STRING_KEY("Plug-In too small", "Plug-In too small", "Label text to be used when a plug-in was blocked from loading because it was too small");
721}
722
723String multipleFileUploadText(unsigned numberOfFiles)
724{
725 return formatLocalizedString(WEB_UI_STRING("%d files", "Label to describe the number of files selected in a file upload control that allows multiple files"), numberOfFiles);
726}
727
728String unknownFileSizeText()
729{
730 return WEB_UI_STRING_KEY("Unknown", "Unknown (filesize)", "Unknown filesize FTP directory listing item");
731}
732
733String imageTitle(const String& filename, const IntSize& size)
734{
735#if USE(CF)
736 auto locale = adoptCF(CFLocaleCopyCurrent());
737 auto formatter = adoptCF(CFNumberFormatterCreate(0, locale.get(), kCFNumberFormatterDecimalStyle));
738
739 int widthInt = size.width();
740 auto width = adoptCF(CFNumberCreate(0, kCFNumberIntType, &widthInt));
741 auto widthString = adoptCF(CFNumberFormatterCreateStringWithNumber(0, formatter.get(), width.get()));
742
743 int heightInt = size.height();
744 auto height = adoptCF(CFNumberCreate(0, kCFNumberIntType, &heightInt));
745 auto heightString = adoptCF(CFNumberFormatterCreateStringWithNumber(0, formatter.get(), height.get()));
746
747 return formatLocalizedString(WEB_UI_CFSTRING("%@ %@×%@ pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filename.createCFString().get(), widthString.get(), heightString.get());
748#elif USE(GLIB)
749 return formatLocalizedString(WEB_UI_STRING("%s %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filename.utf8().data(), size.width(), size.height());
750#else
751 return formatLocalizedString(WEB_UI_STRING("<filename> %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)"), size.width(), size.height()).replace("<filename>", filename);
752#endif
753}
754
755String mediaElementLoadingStateText()
756{
757 return WEB_UI_STRING("Loading…", "Media controller status message when the media is loading");
758}
759
760String mediaElementLiveBroadcastStateText()
761{
762 return WEB_UI_STRING("Live Broadcast", "Media controller status message when watching a live broadcast");
763}
764
765String localizedMediaControlElementString(const String& name)
766{
767 if (name == "AudioElement")
768 return WEB_UI_STRING("audio playback", "accessibility label for audio element controller");
769 if (name == "VideoElement")
770 return WEB_UI_STRING("video playback", "accessibility label for video element controller");
771 if (name == "MuteButton")
772 return WEB_UI_STRING("mute", "accessibility label for mute button");
773 if (name == "UnMuteButton")
774 return WEB_UI_STRING("unmute", "accessibility label for turn mute off button");
775 if (name == "PlayButton")
776 return WEB_UI_STRING("play", "accessibility label for play button");
777 if (name == "PauseButton")
778 return WEB_UI_STRING("pause", "accessibility label for pause button");
779 if (name == "Slider")
780 return WEB_UI_STRING("movie time", "accessibility label for timeline slider");
781 if (name == "SliderThumb")
782 return WEB_UI_STRING("timeline slider thumb", "accessibility label for timeline thumb");
783 if (name == "RewindButton")
784 return WEB_UI_STRING("back 30 seconds", "accessibility label for seek back 30 seconds button");
785 if (name == "ReturnToRealtimeButton")
786 return WEB_UI_STRING("return to realtime", "accessibility label for return to real time button");
787 if (name == "CurrentTimeDisplay")
788 return WEB_UI_STRING("elapsed time", "accessibility label for elapsed time display");
789 if (name == "TimeRemainingDisplay")
790 return WEB_UI_STRING("remaining time", "accessibility label for time remaining display");
791 if (name == "StatusDisplay")
792 return WEB_UI_STRING("status", "accessibility label for movie status");
793 if (name == "EnterFullscreenButton")
794 return WEB_UI_STRING("enter full screen", "accessibility label for enter full screen button");
795 if (name == "ExitFullscreenButton")
796 return WEB_UI_STRING("exit full screen", "accessibility label for exit full screen button");
797 if (name == "SeekForwardButton")
798 return WEB_UI_STRING("fast forward", "accessibility label for fast forward button");
799 if (name == "SeekBackButton")
800 return WEB_UI_STRING("fast reverse", "accessibility label for fast reverse button");
801 if (name == "ShowClosedCaptionsButton")
802 return WEB_UI_STRING("show closed captions", "accessibility label for show closed captions button");
803 if (name == "HideClosedCaptionsButton")
804 return WEB_UI_STRING("hide closed captions", "accessibility label for hide closed captions button");
805
806 // FIXME: the ControlsPanel container should never be visible in the accessibility hierarchy.
807 if (name == "ControlsPanel")
808 return String();
809
810 ASSERT_NOT_REACHED();
811 return String();
812}
813
814String localizedMediaControlElementHelpText(const String& name)
815{
816 if (name == "AudioElement")
817 return WEB_UI_STRING("audio element playback controls and status display", "accessibility help text for audio element controller");
818 if (name == "VideoElement")
819 return WEB_UI_STRING("video element playback controls and status display", "accessibility help text for video element controller");
820 if (name == "MuteButton")
821 return WEB_UI_STRING("mute audio tracks", "accessibility help text for mute button");
822 if (name == "UnMuteButton")
823 return WEB_UI_STRING("unmute audio tracks", "accessibility help text for un mute button");
824 if (name == "PlayButton")
825 return WEB_UI_STRING("begin playback", "accessibility help text for play button");
826 if (name == "PauseButton")
827 return WEB_UI_STRING("pause playback", "accessibility help text for pause button");
828 if (name == "Slider")
829 return WEB_UI_STRING("movie time scrubber", "accessibility help text for timeline slider");
830 if (name == "SliderThumb")
831 return WEB_UI_STRING("movie time scrubber thumb", "accessibility help text for timeline slider thumb");
832 if (name == "RewindButton")
833 return WEB_UI_STRING("seek movie back 30 seconds", "accessibility help text for jump back 30 seconds button");
834 if (name == "ReturnToRealtimeButton")
835 return WEB_UI_STRING("return streaming movie to real time", "accessibility help text for return streaming movie to real time button");
836 if (name == "CurrentTimeDisplay")
837 return WEB_UI_STRING("current movie time in seconds", "accessibility help text for elapsed time display");
838 if (name == "TimeRemainingDisplay")
839 return WEB_UI_STRING("number of seconds of movie remaining", "accessibility help text for remaining time display");
840 if (name == "StatusDisplay")
841 return WEB_UI_STRING("current movie status", "accessibility help text for movie status display");
842 if (name == "SeekBackButton")
843 return WEB_UI_STRING("seek quickly back", "accessibility help text for fast rewind button");
844 if (name == "SeekForwardButton")
845 return WEB_UI_STRING("seek quickly forward", "accessibility help text for fast forward button");
846 if (name == "FullscreenButton")
847 return WEB_UI_STRING("Play movie in full screen mode", "accessibility help text for enter full screen button");
848 if (name == "ShowClosedCaptionsButton")
849 return WEB_UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button");
850 if (name == "HideClosedCaptionsButton")
851 return WEB_UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button");
852
853 // The description of this button is descriptive enough that it doesn't require help text.
854 if (name == "EnterFullscreenButton")
855 return String();
856
857 ASSERT_NOT_REACHED();
858 return String();
859}
860
861String localizedMediaTimeDescription(float time)
862{
863 if (!std::isfinite(time))
864 return WEB_UI_STRING("indefinite time", "accessibility help text for an indefinite media controller time value");
865
866 int seconds = static_cast<int>(fabsf(time));
867 int days = seconds / (60 * 60 * 24);
868 int hours = seconds / (60 * 60);
869 int minutes = (seconds / 60) % 60;
870 seconds %= 60;
871
872 if (days)
873 return formatLocalizedString(WEB_UI_STRING("%1$d days %2$d hours %3$d minutes %4$d seconds", "accessibility help text for media controller time value >= 1 day"), days, hours, minutes, seconds);
874 if (hours)
875 return formatLocalizedString(WEB_UI_STRING("%1$d hours %2$d minutes %3$d seconds", "accessibility help text for media controller time value >= 60 minutes"), hours, minutes, seconds);
876 if (minutes)
877 return formatLocalizedString(WEB_UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds);
878 return formatLocalizedString(WEB_UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"), seconds);
879}
880
881String validationMessageValueMissingText()
882{
883 return WEB_UI_STRING("Fill out this field", "Validation message for required form control elements that have no value");
884}
885
886String validationMessageValueMissingForCheckboxText()
887{
888 return WEB_UI_STRING("Select this checkbox", "Validation message for required checkboxes that have not be selected");
889}
890
891String validationMessageValueMissingForFileText()
892{
893 return WEB_UI_STRING("Select a file", "Validation message for required file inputs that have no value");
894}
895
896String validationMessageValueMissingForMultipleFileText()
897{
898 return validationMessageValueMissingForFileText();
899}
900
901String validationMessageValueMissingForRadioText()
902{
903 return WEB_UI_STRING("Select one of these options", "Validation message for required radio boxes that have no selection");
904}
905
906String validationMessageValueMissingForSelectText()
907{
908 return WEB_UI_STRING("Select an item in the list", "Validation message for required menu list controls that have no selection");
909}
910
911String validationMessageTypeMismatchText()
912{
913 return WEB_UI_STRING("Invalid value", "Validation message for input form controls with a value not matching type");
914}
915
916String validationMessageTypeMismatchForEmailText()
917{
918 return WEB_UI_STRING("Enter an email address", "Validation message for input form controls of type 'email' that have an invalid value");
919}
920
921String validationMessageTypeMismatchForMultipleEmailText()
922{
923 return validationMessageTypeMismatchForEmailText();
924}
925
926String validationMessageTypeMismatchForURLText()
927{
928 return WEB_UI_STRING("Enter a URL", "Validation message for input form controls of type 'url' that have an invalid value");
929}
930
931String validationMessagePatternMismatchText()
932{
933 return WEB_UI_STRING("Match the requested format", "Validation message for input form controls requiring a constrained value according to pattern");
934}
935
936#if !PLATFORM(GTK)
937String validationMessageTooShortText(int, int minLength)
938{
939 return formatLocalizedString(WEB_UI_STRING("Use at least %d characters", "Validation message for form control elements with a value shorter than minimum allowed length"), minLength);
940}
941
942#if !PLATFORM(COCOA)
943String validationMessageTooLongText(int, int maxLength)
944{
945 return formatLocalizedString(WEB_UI_STRING("Use no more than %d characters", "Validation message for form control elements with a value shorter than maximum allowed length"), maxLength);
946}
947#endif
948#endif
949
950String validationMessageRangeUnderflowText(const String& minimum)
951{
952#if USE(CF)
953 return formatLocalizedString(WEB_UI_CFSTRING("Value must be greater than or equal to %@", "Validation message for input form controls with value lower than allowed minimum"), minimum.createCFString().get());
954#elif USE(GLIB)
955 return formatLocalizedString(WEB_UI_STRING("Value must be greater than or equal to %s", "Validation message for input form controls with value lower than allowed minimum"), minimum.utf8().data());
956#else
957 UNUSED_PARAM(minimum);
958 return WEB_UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum");
959#endif
960}
961
962String validationMessageRangeOverflowText(const String& maximum)
963{
964#if USE(CF)
965 return formatLocalizedString(WEB_UI_CFSTRING("Value must be less than or equal to %@", "Validation message for input form controls with value higher than allowed maximum"), maximum.createCFString().get());
966#elif USE(GLIB)
967 return formatLocalizedString(WEB_UI_STRING("Value must be less than or equal to %s", "Validation message for input form controls with value higher than allowed maximum"), maximum.utf8().data());
968#else
969 UNUSED_PARAM(maximum);
970 return WEB_UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum");
971#endif
972}
973
974String validationMessageStepMismatchText(const String&, const String&)
975{
976 return WEB_UI_STRING("Enter a valid value", "Validation message for input form controls with value not respecting the step attribute");
977}
978
979String validationMessageBadInputForNumberText()
980{
981 return WEB_UI_STRING("Enter a number", "Validation message for number fields where the user entered a non-number string");
982}
983
984String clickToExitFullScreenText()
985{
986 return WEB_UI_STRING("Click to Exit Full Screen", "Message to display in browser window when in webkit full screen mode.");
987}
988
989#if ENABLE(VIDEO_TRACK)
990
991String textTrackSubtitlesText()
992{
993 return WEB_UI_STRING("Subtitles", "Menu section heading for subtitles");
994}
995
996String textTrackOffMenuItemText()
997{
998 return WEB_UI_STRING("Off", "Menu item label for the track that represents disabling closed captions");
999}
1000
1001String textTrackAutomaticMenuItemText()
1002{
1003 return formatLocalizedString(WEB_UI_STRING("Auto (Recommended)", "Menu item label for automatic track selection behavior"));
1004}
1005
1006String textTrackNoLabelText()
1007{
1008 return WEB_UI_STRING_KEY("Unknown", "Unknown (text track)", "Menu item label for a text track that has no other name");
1009}
1010
1011String audioTrackNoLabelText()
1012{
1013 return WEB_UI_STRING_KEY("Unknown", "Unknown (audio track)", "Menu item label for an audio track that has no other name");
1014}
1015
1016#endif
1017
1018#if ENABLE(VIDEO_TRACK) && USE(CF)
1019
1020String textTrackCountryAndLanguageMenuItemText(const String& title, const String& country, const String& language)
1021{
1022 return formatLocalizedString(WEB_UI_CFSTRING("%@ (%@-%@)", "Text track display name format that includes the country and language of the subtitle, in the form of 'Title (Language-Country)'"), title.createCFString().get(), language.createCFString().get(), country.createCFString().get());
1023}
1024
1025String textTrackLanguageMenuItemText(const String& title, const String& language)
1026{
1027 return formatLocalizedString(WEB_UI_CFSTRING("%@ (%@)", "Text track display name format that includes the language of the subtitle, in the form of 'Title (Language)'"), title.createCFString().get(), language.createCFString().get());
1028}
1029
1030String closedCaptionTrackMenuItemText(const String& title)
1031{
1032 return formatLocalizedString(WEB_UI_CFSTRING("%@ CC", "Text track contains closed captions"), title.createCFString().get());
1033}
1034
1035String sdhTrackMenuItemText(const String& title)
1036{
1037 return formatLocalizedString(WEB_UI_CFSTRING("%@ SDH", "Text track contains subtitles for the deaf and hard of hearing"), title.createCFString().get());
1038}
1039
1040String easyReaderTrackMenuItemText(const String& title)
1041{
1042 return formatLocalizedString(WEB_UI_CFSTRING("%@ Easy Reader", "Text track contains simplified (3rd grade level) subtitles"), title.createCFString().get());
1043}
1044
1045String forcedTrackMenuItemText(const String& title)
1046{
1047 return formatLocalizedString(WEB_UI_CFSTRING("%@ Forced", "Text track contains forced subtitles"), title.createCFString().get());
1048}
1049
1050String audioDescriptionTrackSuffixText(const String& title)
1051{
1052 return formatLocalizedString(WEB_UI_CFSTRING("%@ AD", "Text track contains Audio Descriptions"), title.createCFString().get());
1053}
1054
1055#endif
1056
1057String snapshottedPlugInLabelTitle()
1058{
1059 return WEB_UI_STRING("Snapshotted Plug-In", "Title of the label to show on a snapshotted plug-in");
1060}
1061
1062String snapshottedPlugInLabelSubtitle()
1063{
1064 return WEB_UI_STRING("Click to restart", "Subtitle of the label to show on a snapshotted plug-in");
1065}
1066
1067String useBlockedPlugInContextMenuTitle()
1068{
1069 return formatLocalizedString(WEB_UI_STRING("Show in blocked plug-in", "Title of the context menu item to show when PDFPlugin was used instead of a blocked plugin"));
1070}
1071
1072#if ENABLE(WEB_CRYPTO)
1073
1074String webCryptoMasterKeyKeychainLabel(const String& localizedApplicationName)
1075{
1076#if USE(CF)
1077 return formatLocalizedString(WEB_UI_CFSTRING("%@ WebCrypto Master Key", "Name of application's single WebCrypto master key in Keychain"), localizedApplicationName.createCFString().get());
1078#elif USE(GLIB)
1079 return formatLocalizedString(WEB_UI_STRING("%s WebCrypto Master Key", "Name of application's single WebCrypto master key in Keychain"), localizedApplicationName.utf8().data());
1080#else
1081 return String::fromUTF8("<application> WebCrypto Master Key", "Name of application's single WebCrypto master key in Keychain").replace("<application>", localizedApplicationName);
1082#endif
1083}
1084
1085String webCryptoMasterKeyKeychainComment()
1086{
1087 return WEB_UI_STRING("Used to encrypt WebCrypto keys in persistent storage, such as IndexedDB", "Description of WebCrypto master keys in Keychain");
1088}
1089
1090#endif
1091
1092#if PLATFORM(WATCHOS)
1093
1094String numberPadOKButtonTitle()
1095{
1096 return WEB_UI_STRING_KEY("OK", "OK (OK button title in extra zoomed number pad)", "Title of the OK button for the number pad in zoomed form controls.");
1097}
1098
1099String formControlDoneButtonTitle()
1100{
1101 return WEB_UI_STRING("Done", "Title of the Done button for zoomed form controls.");
1102}
1103
1104String formControlCancelButtonTitle()
1105{
1106 return WEB_UI_STRING("Cancel", "Cancel");
1107}
1108
1109String formControlHideButtonTitle()
1110{
1111 return WEB_UI_STRING("Hide", "Title of the Hide button for zoomed form controls.");
1112}
1113
1114String formControlGoButtonTitle()
1115{
1116 return WEB_UI_STRING("Go", "Title of the Go button for zoomed form controls.");
1117}
1118
1119String formControlSearchButtonTitle()
1120{
1121 return WEB_UI_STRING("Search", "Title of the Search button for zoomed form controls.");
1122}
1123
1124String datePickerSetButtonTitle()
1125{
1126 return WEB_UI_STRING_KEY("Set", "Set (Button below date picker for extra zoom mode)", "Set button below date picker");
1127}
1128
1129String datePickerDayLabelTitle()
1130{
1131 return WEB_UI_STRING_KEY("DAY", "DAY (Date picker for extra zoom mode)", "Day label in date picker");
1132}
1133
1134String datePickerMonthLabelTitle()
1135{
1136 return WEB_UI_STRING_KEY("MONTH", "MONTH (Date picker for extra zoom mode)", "Month label in date picker");
1137}
1138
1139String datePickerYearLabelTitle()
1140{
1141 return WEB_UI_STRING_KEY("YEAR", "YEAR (Date picker for extra zoom mode)", "Year label in date picker");
1142}
1143
1144#endif
1145
1146#if USE(SOUP)
1147String unacceptableTLSCertificate()
1148{
1149 return WEB_UI_STRING("Unacceptable TLS certificate", "Unacceptable TLS certificate error");
1150}
1151#endif
1152
1153} // namespace WebCore
1154