• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #include "config.h"
27 #include "DefaultLocalizationStrategy.h"
28 
29 #if USE(PLATFORM_STRATEGIES)
30 
31 #include "IntSize.h"
32 #include "LocalizedStrings.h"
33 #include "NotImplemented.h"
34 #include <wtf/MathExtras.h>
35 #include <wtf/text/CString.h>
36 #include <wtf/UnusedParam.h>
37 
38 #if USE(CF)
39 #include <wtf/RetainPtr.h>
40 #endif
41 
42 namespace WebCore {
43 
44 // We can't use String::format for two reasons:
45 //  1) It doesn't handle non-ASCII characters in the format string.
46 //  2) It doesn't handle the %2$d syntax.
47 // Note that because |format| is used as the second parameter to va_start, it cannot be a reference
48 // type according to section 18.7/3 of the C++ N1905 standard.
formatLocalizedString(String format,...)49 static String formatLocalizedString(String format, ...)
50 {
51 #if USE(CF)
52     va_list arguments;
53     va_start(arguments, format);
54     RetainPtr<CFStringRef> formatCFString(AdoptCF, format.createCFString());
55     RetainPtr<CFStringRef> result(AdoptCF, CFStringCreateWithFormatAndArguments(0, 0, formatCFString.get(), arguments));
56     va_end(arguments);
57     return result.get();
58 #elif PLATFORM(QT)
59     va_list arguments;
60     va_start(arguments, format);
61     QString result;
62     result.vsprintf(format.latin1().data(), arguments);
63     va_end(arguments);
64     return result;
65 #else
66     notImplemented();
67     return format;
68 #endif
69 }
70 
DefaultLocalizationStrategy()71 DefaultLocalizationStrategy::DefaultLocalizationStrategy()
72 {
73 }
74 
inputElementAltText()75 String DefaultLocalizationStrategy::inputElementAltText()
76 {
77     return WEB_UI_STRING_KEY("Submit", "Submit (input element)", "alt text for <input> elements with no alt, title, or value");
78 }
79 
resetButtonDefaultLabel()80 String DefaultLocalizationStrategy::resetButtonDefaultLabel()
81 {
82     return WEB_UI_STRING("Reset", "default label for Reset buttons in forms on web pages");
83 }
84 
searchableIndexIntroduction()85 String DefaultLocalizationStrategy::searchableIndexIntroduction()
86 {
87     return WEB_UI_STRING("This is a searchable index. Enter search keywords: ",
88         "text that appears at the start of nearly-obsolete web pages in the form of a 'searchable index'");
89 }
90 
submitButtonDefaultLabel()91 String DefaultLocalizationStrategy::submitButtonDefaultLabel()
92 {
93     return WEB_UI_STRING("Submit", "default label for Submit buttons in forms on web pages");
94 }
95 
fileButtonChooseFileLabel()96 String DefaultLocalizationStrategy::fileButtonChooseFileLabel()
97 {
98     return WEB_UI_STRING("Choose File", "title for file button used in HTML forms");
99 }
100 
fileButtonNoFileSelectedLabel()101 String DefaultLocalizationStrategy::fileButtonNoFileSelectedLabel()
102 {
103     return WEB_UI_STRING("no file selected", "text to display in file button used in HTML forms when no file is selected");
104 }
105 
defaultDetailsSummaryText()106 String DefaultLocalizationStrategy::defaultDetailsSummaryText()
107 {
108     return WEB_UI_STRING("Details", "text to display in <details> tag when it has no <summary> child");
109 }
110 
111 #if PLATFORM(MAC)
copyImageUnknownFileLabel()112 String DefaultLocalizationStrategy::copyImageUnknownFileLabel()
113 {
114     return WEB_UI_STRING("unknown", "Unknown filename");
115 }
116 #endif
117 
118 #if ENABLE(CONTEXT_MENUS)
119 
contextMenuItemTagOpenLinkInNewWindow()120 String DefaultLocalizationStrategy::contextMenuItemTagOpenLinkInNewWindow()
121 {
122     return WEB_UI_STRING("Open Link in New Window", "Open in New Window context menu item");
123 }
124 
contextMenuItemTagDownloadLinkToDisk()125 String DefaultLocalizationStrategy::contextMenuItemTagDownloadLinkToDisk()
126 {
127     return WEB_UI_STRING("Download Linked File", "Download Linked File context menu item");
128 }
129 
contextMenuItemTagCopyLinkToClipboard()130 String DefaultLocalizationStrategy::contextMenuItemTagCopyLinkToClipboard()
131 {
132     return WEB_UI_STRING("Copy Link", "Copy Link context menu item");
133 }
134 
contextMenuItemTagOpenImageInNewWindow()135 String DefaultLocalizationStrategy::contextMenuItemTagOpenImageInNewWindow()
136 {
137     return WEB_UI_STRING("Open Image in New Window", "Open Image in New Window context menu item");
138 }
139 
contextMenuItemTagDownloadImageToDisk()140 String DefaultLocalizationStrategy::contextMenuItemTagDownloadImageToDisk()
141 {
142     return WEB_UI_STRING("Download Image", "Download Image context menu item");
143 }
144 
contextMenuItemTagCopyImageToClipboard()145 String DefaultLocalizationStrategy::contextMenuItemTagCopyImageToClipboard()
146 {
147     return WEB_UI_STRING("Copy Image", "Copy Image context menu item");
148 }
149 
150 #if PLATFORM(QT)
contextMenuItemTagCopyImageUrlToClipboard()151 String DefaultLocalizationStrategy::contextMenuItemTagCopyImageUrlToClipboard()
152 {
153     return WEB_UI_STRING("Copy Image Address", "Copy Image Address menu item");
154 }
155 #endif
156 
contextMenuItemTagOpenVideoInNewWindow()157 String DefaultLocalizationStrategy::contextMenuItemTagOpenVideoInNewWindow()
158 {
159     return WEB_UI_STRING("Open Video in New Window", "Open Video in New Window context menu item");
160 }
161 
contextMenuItemTagOpenAudioInNewWindow()162 String DefaultLocalizationStrategy::contextMenuItemTagOpenAudioInNewWindow()
163 {
164     return WEB_UI_STRING("Open Audio in New Window", "Open Audio in New Window context menu item");
165 }
166 
contextMenuItemTagCopyVideoLinkToClipboard()167 String DefaultLocalizationStrategy::contextMenuItemTagCopyVideoLinkToClipboard()
168 {
169     return WEB_UI_STRING("Copy Video Address", "Copy Video Address Location context menu item");
170 }
171 
contextMenuItemTagCopyAudioLinkToClipboard()172 String DefaultLocalizationStrategy::contextMenuItemTagCopyAudioLinkToClipboard()
173 {
174     return WEB_UI_STRING("Copy Audio Address", "Copy Audio Address Location context menu item");
175 }
176 
contextMenuItemTagToggleMediaControls()177 String DefaultLocalizationStrategy::contextMenuItemTagToggleMediaControls()
178 {
179     return WEB_UI_STRING("Controls", "Media Controls context menu item");
180 }
181 
contextMenuItemTagToggleMediaLoop()182 String DefaultLocalizationStrategy::contextMenuItemTagToggleMediaLoop()
183 {
184     return WEB_UI_STRING("Loop", "Media Loop context menu item");
185 }
186 
contextMenuItemTagEnterVideoFullscreen()187 String DefaultLocalizationStrategy::contextMenuItemTagEnterVideoFullscreen()
188 {
189     return WEB_UI_STRING("Enter Fullscreen", "Video Enter Fullscreen context menu item");
190 }
191 
contextMenuItemTagMediaPlay()192 String DefaultLocalizationStrategy::contextMenuItemTagMediaPlay()
193 {
194     return WEB_UI_STRING("Play", "Media Play context menu item");
195 }
196 
contextMenuItemTagMediaPause()197 String DefaultLocalizationStrategy::contextMenuItemTagMediaPause()
198 {
199     return WEB_UI_STRING("Pause", "Media Pause context menu item");
200 }
201 
contextMenuItemTagMediaMute()202 String DefaultLocalizationStrategy::contextMenuItemTagMediaMute()
203 {
204     return WEB_UI_STRING("Mute", "Media Mute context menu item");
205 }
206 
contextMenuItemTagOpenFrameInNewWindow()207 String DefaultLocalizationStrategy::contextMenuItemTagOpenFrameInNewWindow()
208 {
209     return WEB_UI_STRING("Open Frame in New Window", "Open Frame in New Window context menu item");
210 }
211 
contextMenuItemTagCopy()212 String DefaultLocalizationStrategy::contextMenuItemTagCopy()
213 {
214     return WEB_UI_STRING("Copy", "Copy context menu item");
215 }
216 
contextMenuItemTagGoBack()217 String DefaultLocalizationStrategy::contextMenuItemTagGoBack()
218 {
219     return WEB_UI_STRING("Back", "Back context menu item");
220 }
221 
contextMenuItemTagGoForward()222 String DefaultLocalizationStrategy::contextMenuItemTagGoForward()
223 {
224     return WEB_UI_STRING("Forward", "Forward context menu item");
225 }
226 
contextMenuItemTagStop()227 String DefaultLocalizationStrategy::contextMenuItemTagStop()
228 {
229     return WEB_UI_STRING("Stop", "Stop context menu item");
230 }
231 
contextMenuItemTagReload()232 String DefaultLocalizationStrategy::contextMenuItemTagReload()
233 {
234     return WEB_UI_STRING("Reload", "Reload context menu item");
235 }
236 
contextMenuItemTagCut()237 String DefaultLocalizationStrategy::contextMenuItemTagCut()
238 {
239     return WEB_UI_STRING("Cut", "Cut context menu item");
240 }
241 
contextMenuItemTagPaste()242 String DefaultLocalizationStrategy::contextMenuItemTagPaste()
243 {
244     return WEB_UI_STRING("Paste", "Paste context menu item");
245 }
246 
247 #if PLATFORM(GTK)
248 
contextMenuItemTagDelete()249 String DefaultLocalizationStrategy::contextMenuItemTagDelete()
250 {
251     notImplemented();
252     return "Delete";
253 }
254 
contextMenuItemTagInputMethods()255 String DefaultLocalizationStrategy::contextMenuItemTagInputMethods()
256 {
257     notImplemented();
258     return "Input Methods";
259 }
260 
contextMenuItemTagUnicode()261 String DefaultLocalizationStrategy::contextMenuItemTagUnicode()
262 {
263     notImplemented();
264     return "Unicode";
265 }
266 
267 #endif
268 
269 #if PLATFORM(GTK) || PLATFORM(QT)
270 
contextMenuItemTagSelectAll()271 String DefaultLocalizationStrategy::contextMenuItemTagSelectAll()
272 {
273     notImplemented();
274     return "Select All";
275 }
276 
277 #endif
278 
contextMenuItemTagNoGuessesFound()279 String DefaultLocalizationStrategy::contextMenuItemTagNoGuessesFound()
280 {
281     return WEB_UI_STRING("No Guesses Found", "No Guesses Found context menu item");
282 }
283 
contextMenuItemTagIgnoreSpelling()284 String DefaultLocalizationStrategy::contextMenuItemTagIgnoreSpelling()
285 {
286     return WEB_UI_STRING("Ignore Spelling", "Ignore Spelling context menu item");
287 }
288 
contextMenuItemTagLearnSpelling()289 String DefaultLocalizationStrategy::contextMenuItemTagLearnSpelling()
290 {
291     return WEB_UI_STRING("Learn Spelling", "Learn Spelling context menu item");
292 }
293 
contextMenuItemTagSearchWeb()294 String DefaultLocalizationStrategy::contextMenuItemTagSearchWeb()
295 {
296     return WEB_UI_STRING("Search in Google", "Search in Google context menu item");
297 }
298 
contextMenuItemTagLookUpInDictionary(const String & selectedString)299 String DefaultLocalizationStrategy::contextMenuItemTagLookUpInDictionary(const String& selectedString)
300 {
301 #if defined(BUILDING_ON_TIGER) || defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
302     UNUSED_PARAM(selectedString);
303     return WEB_UI_STRING("Look Up in Dictionary", "Look Up in Dictionary context menu item");
304 #else
305 #if USE(CF)
306     RetainPtr<CFStringRef> selectedCFString(AdoptCF, selectedString.createCFString());
307     return formatLocalizedString(WEB_UI_STRING("Look Up “%@”", "Look Up context menu item with selected word"), selectedCFString.get());
308 #else
309     return WEB_UI_STRING("Look Up “<selection>”", "Look Up context menu item with selected word").replace("<selection>", selectedString);
310 #endif
311 #endif
312 }
313 
contextMenuItemTagOpenLink()314 String DefaultLocalizationStrategy::contextMenuItemTagOpenLink()
315 {
316     return WEB_UI_STRING("Open Link", "Open Link context menu item");
317 }
318 
contextMenuItemTagIgnoreGrammar()319 String DefaultLocalizationStrategy::contextMenuItemTagIgnoreGrammar()
320 {
321     return WEB_UI_STRING("Ignore Grammar", "Ignore Grammar context menu item");
322 }
323 
contextMenuItemTagSpellingMenu()324 String DefaultLocalizationStrategy::contextMenuItemTagSpellingMenu()
325 {
326     return WEB_UI_STRING("Spelling and Grammar", "Spelling and Grammar context sub-menu item");
327 }
328 
contextMenuItemTagShowSpellingPanel(bool show)329 String DefaultLocalizationStrategy::contextMenuItemTagShowSpellingPanel(bool show)
330 {
331     if (show)
332         return WEB_UI_STRING("Show Spelling and Grammar", "menu item title");
333     return WEB_UI_STRING("Hide Spelling and Grammar", "menu item title");
334 }
335 
contextMenuItemTagCheckSpelling()336 String DefaultLocalizationStrategy::contextMenuItemTagCheckSpelling()
337 {
338     return WEB_UI_STRING("Check Document Now", "Check spelling context menu item");
339 }
340 
contextMenuItemTagCheckSpellingWhileTyping()341 String DefaultLocalizationStrategy::contextMenuItemTagCheckSpellingWhileTyping()
342 {
343     return WEB_UI_STRING("Check Spelling While Typing", "Check spelling while typing context menu item");
344 }
345 
contextMenuItemTagCheckGrammarWithSpelling()346 String DefaultLocalizationStrategy::contextMenuItemTagCheckGrammarWithSpelling()
347 {
348     return WEB_UI_STRING("Check Grammar With Spelling", "Check grammar with spelling context menu item");
349 }
350 
contextMenuItemTagFontMenu()351 String DefaultLocalizationStrategy::contextMenuItemTagFontMenu()
352 {
353     return WEB_UI_STRING("Font", "Font context sub-menu item");
354 }
355 
contextMenuItemTagBold()356 String DefaultLocalizationStrategy::contextMenuItemTagBold()
357 {
358     return WEB_UI_STRING("Bold", "Bold context menu item");
359 }
360 
contextMenuItemTagItalic()361 String DefaultLocalizationStrategy::contextMenuItemTagItalic()
362 {
363     return WEB_UI_STRING("Italic", "Italic context menu item");
364 }
365 
contextMenuItemTagUnderline()366 String DefaultLocalizationStrategy::contextMenuItemTagUnderline()
367 {
368     return WEB_UI_STRING("Underline", "Underline context menu item");
369 }
370 
contextMenuItemTagOutline()371 String DefaultLocalizationStrategy::contextMenuItemTagOutline()
372 {
373     return WEB_UI_STRING("Outline", "Outline context menu item");
374 }
375 
contextMenuItemTagWritingDirectionMenu()376 String DefaultLocalizationStrategy::contextMenuItemTagWritingDirectionMenu()
377 {
378     return WEB_UI_STRING("Paragraph Direction", "Paragraph direction context sub-menu item");
379 }
380 
contextMenuItemTagTextDirectionMenu()381 String DefaultLocalizationStrategy::contextMenuItemTagTextDirectionMenu()
382 {
383     return WEB_UI_STRING("Selection Direction", "Selection direction context sub-menu item");
384 }
385 
contextMenuItemTagDefaultDirection()386 String DefaultLocalizationStrategy::contextMenuItemTagDefaultDirection()
387 {
388     return WEB_UI_STRING("Default", "Default writing direction context menu item");
389 }
390 
contextMenuItemTagLeftToRight()391 String DefaultLocalizationStrategy::contextMenuItemTagLeftToRight()
392 {
393     return WEB_UI_STRING("Left to Right", "Left to Right context menu item");
394 }
395 
contextMenuItemTagRightToLeft()396 String DefaultLocalizationStrategy::contextMenuItemTagRightToLeft()
397 {
398     return WEB_UI_STRING("Right to Left", "Right to Left context menu item");
399 }
400 
401 #if PLATFORM(MAC)
402 
contextMenuItemTagSearchInSpotlight()403 String DefaultLocalizationStrategy::contextMenuItemTagSearchInSpotlight()
404 {
405     return WEB_UI_STRING("Search in Spotlight", "Search in Spotlight context menu item");
406 }
407 
contextMenuItemTagShowFonts()408 String DefaultLocalizationStrategy::contextMenuItemTagShowFonts()
409 {
410     return WEB_UI_STRING("Show Fonts", "Show fonts context menu item");
411 }
412 
contextMenuItemTagStyles()413 String DefaultLocalizationStrategy::contextMenuItemTagStyles()
414 {
415     return WEB_UI_STRING("Styles...", "Styles context menu item");
416 }
417 
contextMenuItemTagShowColors()418 String DefaultLocalizationStrategy::contextMenuItemTagShowColors()
419 {
420     return WEB_UI_STRING("Show Colors", "Show colors context menu item");
421 }
422 
contextMenuItemTagSpeechMenu()423 String DefaultLocalizationStrategy::contextMenuItemTagSpeechMenu()
424 {
425     return WEB_UI_STRING("Speech", "Speech context sub-menu item");
426 }
427 
contextMenuItemTagStartSpeaking()428 String DefaultLocalizationStrategy::contextMenuItemTagStartSpeaking()
429 {
430     return WEB_UI_STRING("Start Speaking", "Start speaking context menu item");
431 }
432 
contextMenuItemTagStopSpeaking()433 String DefaultLocalizationStrategy::contextMenuItemTagStopSpeaking()
434 {
435     return WEB_UI_STRING("Stop Speaking", "Stop speaking context menu item");
436 }
437 
contextMenuItemTagCorrectSpellingAutomatically()438 String DefaultLocalizationStrategy::contextMenuItemTagCorrectSpellingAutomatically()
439 {
440     return WEB_UI_STRING("Correct Spelling Automatically", "Correct Spelling Automatically context menu item");
441 }
442 
contextMenuItemTagSubstitutionsMenu()443 String DefaultLocalizationStrategy::contextMenuItemTagSubstitutionsMenu()
444 {
445     return WEB_UI_STRING("Substitutions", "Substitutions context sub-menu item");
446 }
447 
contextMenuItemTagShowSubstitutions(bool show)448 String DefaultLocalizationStrategy::contextMenuItemTagShowSubstitutions(bool show)
449 {
450     if (show)
451         return WEB_UI_STRING("Show Substitutions", "menu item title");
452     return WEB_UI_STRING("Hide Substitutions", "menu item title");
453 }
454 
contextMenuItemTagSmartCopyPaste()455 String DefaultLocalizationStrategy::contextMenuItemTagSmartCopyPaste()
456 {
457     return WEB_UI_STRING("Smart Copy/Paste", "Smart Copy/Paste context menu item");
458 }
459 
contextMenuItemTagSmartQuotes()460 String DefaultLocalizationStrategy::contextMenuItemTagSmartQuotes()
461 {
462     return WEB_UI_STRING("Smart Quotes", "Smart Quotes context menu item");
463 }
464 
contextMenuItemTagSmartDashes()465 String DefaultLocalizationStrategy::contextMenuItemTagSmartDashes()
466 {
467     return WEB_UI_STRING("Smart Dashes", "Smart Dashes context menu item");
468 }
469 
contextMenuItemTagSmartLinks()470 String DefaultLocalizationStrategy::contextMenuItemTagSmartLinks()
471 {
472     return WEB_UI_STRING("Smart Links", "Smart Links context menu item");
473 }
474 
contextMenuItemTagTextReplacement()475 String DefaultLocalizationStrategy::contextMenuItemTagTextReplacement()
476 {
477     return WEB_UI_STRING("Text Replacement", "Text Replacement context menu item");
478 }
479 
contextMenuItemTagTransformationsMenu()480 String DefaultLocalizationStrategy::contextMenuItemTagTransformationsMenu()
481 {
482     return WEB_UI_STRING("Transformations", "Transformations context sub-menu item");
483 }
484 
contextMenuItemTagMakeUpperCase()485 String DefaultLocalizationStrategy::contextMenuItemTagMakeUpperCase()
486 {
487     return WEB_UI_STRING("Make Upper Case", "Make Upper Case context menu item");
488 }
489 
contextMenuItemTagMakeLowerCase()490 String DefaultLocalizationStrategy::contextMenuItemTagMakeLowerCase()
491 {
492     return WEB_UI_STRING("Make Lower Case", "Make Lower Case context menu item");
493 }
494 
contextMenuItemTagCapitalize()495 String DefaultLocalizationStrategy::contextMenuItemTagCapitalize()
496 {
497     return WEB_UI_STRING("Capitalize", "Capitalize context menu item");
498 }
499 
contextMenuItemTagChangeBack(const String & replacedString)500 String DefaultLocalizationStrategy::contextMenuItemTagChangeBack(const String& replacedString)
501 {
502     notImplemented();
503     return replacedString;
504 }
505 
506 #endif
507 
contextMenuItemTagInspectElement()508 String DefaultLocalizationStrategy::contextMenuItemTagInspectElement()
509 {
510     return WEB_UI_STRING("Inspect Element", "Inspect Element context menu item");
511 }
512 
513 #endif // ENABLE(CONTEXT_MENUS)
514 
searchMenuNoRecentSearchesText()515 String DefaultLocalizationStrategy::searchMenuNoRecentSearchesText()
516 {
517     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");
518 }
519 
searchMenuRecentSearchesText()520 String DefaultLocalizationStrategy::searchMenuRecentSearchesText()
521 {
522     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");
523 }
524 
searchMenuClearRecentSearchesText()525 String DefaultLocalizationStrategy::searchMenuClearRecentSearchesText()
526 {
527     return WEB_UI_STRING("Clear Recent Searches", "menu item in Recent Searches menu that empties menu's contents");
528 }
529 
AXWebAreaText()530 String DefaultLocalizationStrategy::AXWebAreaText()
531 {
532     return WEB_UI_STRING("HTML content", "accessibility role description for web area");
533 }
534 
AXLinkText()535 String DefaultLocalizationStrategy::AXLinkText()
536 {
537     return WEB_UI_STRING("link", "accessibility role description for link");
538 }
539 
AXListMarkerText()540 String DefaultLocalizationStrategy::AXListMarkerText()
541 {
542     return WEB_UI_STRING("list marker", "accessibility role description for list marker");
543 }
544 
AXImageMapText()545 String DefaultLocalizationStrategy::AXImageMapText()
546 {
547     return WEB_UI_STRING("image map", "accessibility role description for image map");
548 }
549 
AXHeadingText()550 String DefaultLocalizationStrategy::AXHeadingText()
551 {
552     return WEB_UI_STRING("heading", "accessibility role description for headings");
553 }
554 
AXDefinitionListTermText()555 String DefaultLocalizationStrategy::AXDefinitionListTermText()
556 {
557     return WEB_UI_STRING("term", "term word of a definition");
558 }
559 
AXDefinitionListDefinitionText()560 String DefaultLocalizationStrategy::AXDefinitionListDefinitionText()
561 {
562     return WEB_UI_STRING("definition", "definition phrase");
563 }
564 
565 #if PLATFORM(MAC)
AXARIAContentGroupText(const String & ariaType)566 String DefaultLocalizationStrategy::AXARIAContentGroupText(const String& ariaType)
567 {
568     if (ariaType == "ARIAApplicationAlert")
569         return WEB_UI_STRING("alert", "An ARIA accessibility group that acts as an alert.");
570     if (ariaType == "ARIAApplicationAlertDialog")
571         return WEB_UI_STRING("alert dialog", "An ARIA accessibility group that acts as an alert dialog.");
572     if (ariaType == "ARIAApplicationDialog")
573         return WEB_UI_STRING("dialog", "An ARIA accessibility group that acts as an dialog.");
574     if (ariaType == "ARIAApplicationLog")
575         return WEB_UI_STRING("log", "An ARIA accessibility group that acts as a console log.");
576     if (ariaType == "ARIAApplicationMarquee")
577         return WEB_UI_STRING("marquee", "An ARIA accessibility group that acts as a marquee.");
578     if (ariaType == "ARIAApplicationStatus")
579         return WEB_UI_STRING("application status", "An ARIA accessibility group that acts as a status update.");
580     if (ariaType == "ARIAApplicationTimer")
581         return WEB_UI_STRING("timer", "An ARIA accessibility group that acts as an updating timer.");
582     if (ariaType == "ARIADocument")
583         return WEB_UI_STRING("document", "An ARIA accessibility group that acts as a document.");
584     if (ariaType == "ARIADocumentArticle")
585         return WEB_UI_STRING("article", "An ARIA accessibility group that acts as an article.");
586     if (ariaType == "ARIADocumentNote")
587         return WEB_UI_STRING("note", "An ARIA accessibility group that acts as a note in a document.");
588     if (ariaType == "ARIADocumentRegion")
589         return WEB_UI_STRING("region", "An ARIA accessibility group that acts as a distinct region in a document.");
590     if (ariaType == "ARIALandmarkApplication")
591         return WEB_UI_STRING("application", "An ARIA accessibility group that acts as an application.");
592     if (ariaType == "ARIALandmarkBanner")
593         return WEB_UI_STRING("banner", "An ARIA accessibility group that acts as a banner.");
594     if (ariaType == "ARIALandmarkComplementary")
595         return WEB_UI_STRING("complementary", "An ARIA accessibility group that acts as a region of complementary information.");
596     if (ariaType == "ARIALandmarkContentInfo")
597         return WEB_UI_STRING("content", "An ARIA accessibility group that contains content.");
598     if (ariaType == "ARIALandmarkMain")
599         return WEB_UI_STRING("main", "An ARIA accessibility group that is the main portion of the website.");
600     if (ariaType == "ARIALandmarkNavigation")
601         return WEB_UI_STRING("navigation", "An ARIA accessibility group that contains the main navigation elements of a website.");
602     if (ariaType == "ARIALandmarkSearch")
603         return WEB_UI_STRING("search", "An ARIA accessibility group that contains a search feature of a website.");
604     if (ariaType == "ARIAUserInterfaceTooltip")
605         return WEB_UI_STRING("tooltip", "An ARIA accessibility group that acts as a tooltip.");
606     if (ariaType == "ARIATabPanel")
607         return WEB_UI_STRING("tab panel", "An ARIA accessibility group that contains the content of a tab.");
608     if (ariaType == "ARIADocumentMath")
609         return WEB_UI_STRING("math", "An ARIA accessibility group that contains mathematical symbols.");
610     return String();
611 }
612 #endif
613 
AXButtonActionVerb()614 String DefaultLocalizationStrategy::AXButtonActionVerb()
615 {
616     return WEB_UI_STRING("press", "Verb stating the action that will occur when a button is pressed, as used by accessibility");
617 }
618 
AXRadioButtonActionVerb()619 String DefaultLocalizationStrategy::AXRadioButtonActionVerb()
620 {
621     return WEB_UI_STRING("select", "Verb stating the action that will occur when a radio button is clicked, as used by accessibility");
622 }
623 
AXTextFieldActionVerb()624 String DefaultLocalizationStrategy::AXTextFieldActionVerb()
625 {
626     return WEB_UI_STRING("activate", "Verb stating the action that will occur when a text field is selected, as used by accessibility");
627 }
628 
AXCheckedCheckBoxActionVerb()629 String DefaultLocalizationStrategy::AXCheckedCheckBoxActionVerb()
630 {
631     return WEB_UI_STRING("uncheck", "Verb stating the action that will occur when a checked checkbox is clicked, as used by accessibility");
632 }
633 
AXUncheckedCheckBoxActionVerb()634 String DefaultLocalizationStrategy::AXUncheckedCheckBoxActionVerb()
635 {
636     return WEB_UI_STRING("check", "Verb stating the action that will occur when an unchecked checkbox is clicked, as used by accessibility");
637 }
638 
AXMenuListActionVerb()639 String DefaultLocalizationStrategy::AXMenuListActionVerb()
640 {
641     notImplemented();
642     return "select";
643 }
644 
AXMenuListPopupActionVerb()645 String DefaultLocalizationStrategy::AXMenuListPopupActionVerb()
646 {
647     notImplemented();
648     return "select";
649 }
650 
AXLinkActionVerb()651 String DefaultLocalizationStrategy::AXLinkActionVerb()
652 {
653     return WEB_UI_STRING("jump", "Verb stating the action that will occur when a link is clicked, as used by accessibility");
654 }
655 
missingPluginText()656 String DefaultLocalizationStrategy::missingPluginText()
657 {
658     return WEB_UI_STRING("Missing Plug-in", "Label text to be used when a plugin is missing");
659 }
660 
crashedPluginText()661 String DefaultLocalizationStrategy::crashedPluginText()
662 {
663     return WEB_UI_STRING("Plug-in Failure", "Label text to be used if plugin host process has crashed");
664 }
665 
multipleFileUploadText(unsigned numberOfFiles)666 String DefaultLocalizationStrategy::multipleFileUploadText(unsigned numberOfFiles)
667 {
668     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);
669 }
670 
unknownFileSizeText()671 String DefaultLocalizationStrategy::unknownFileSizeText()
672 {
673     return WEB_UI_STRING("Unknown", "Unknown filesize FTP directory listing item");
674 }
675 
676 #if PLATFORM(WIN)
677 
uploadFileText()678 String DefaultLocalizationStrategy::uploadFileText()
679 {
680     notImplemented();
681     return "upload";
682 }
683 
allFilesText()684 String DefaultLocalizationStrategy::allFilesText()
685 {
686     notImplemented();
687     return "all files";
688 }
689 
690 #endif
691 
692 #if PLATFORM(MAC)
693 
keygenMenuItem512()694 String DefaultLocalizationStrategy::keygenMenuItem512()
695 {
696     return WEB_UI_STRING("512 (Low Grade)", "Menu item title for KEYGEN pop-up menu");
697 }
698 
keygenMenuItem1024()699 String DefaultLocalizationStrategy::keygenMenuItem1024()
700 {
701     return WEB_UI_STRING("1024 (Medium Grade)", "Menu item title for KEYGEN pop-up menu");
702 }
703 
keygenMenuItem2048()704 String DefaultLocalizationStrategy::keygenMenuItem2048()
705 {
706     return WEB_UI_STRING("2048 (High Grade)", "Menu item title for KEYGEN pop-up menu");
707 }
708 
keygenKeychainItemName(const String & host)709 String DefaultLocalizationStrategy::keygenKeychainItemName(const String& host)
710 {
711     RetainPtr<CFStringRef> hostCFString(AdoptCF, host.createCFString());
712     return formatLocalizedString(WEB_UI_STRING("Key from %@", "Name of keychain key generated by the KEYGEN tag"), hostCFString.get());
713 }
714 
715 #endif
716 
imageTitle(const String & filename,const IntSize & size)717 String DefaultLocalizationStrategy::imageTitle(const String& filename, const IntSize& size)
718 {
719 #if USE(CF)
720 #if !defined(BUILDING_ON_LEOPARD)
721     RetainPtr<CFStringRef> filenameCFString(AdoptCF, filename.createCFString());
722     RetainPtr<CFLocaleRef> locale(AdoptCF, CFLocaleCopyCurrent());
723     RetainPtr<CFNumberFormatterRef> formatter(AdoptCF, CFNumberFormatterCreate(0, locale.get(), kCFNumberFormatterDecimalStyle));
724 
725     int widthInt = size.width();
726     RetainPtr<CFNumberRef> width(AdoptCF, CFNumberCreate(0, kCFNumberIntType, &widthInt));
727     RetainPtr<CFStringRef> widthString(AdoptCF, CFNumberFormatterCreateStringWithNumber(0, formatter.get(), width.get()));
728 
729     int heightInt = size.height();
730     RetainPtr<CFNumberRef> height(AdoptCF, CFNumberCreate(0, kCFNumberIntType, &heightInt));
731     RetainPtr<CFStringRef> heightString(AdoptCF, CFNumberFormatterCreateStringWithNumber(0, formatter.get(), height.get()));
732 
733     return formatLocalizedString(WEB_UI_STRING("%@ %@×%@ pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filenameCFString.get(), widthString.get(), heightString.get());
734 #else
735     RetainPtr<CFStringRef> filenameCFString(AdoptCF, filename.createCFString());
736     return formatLocalizedString(WEB_UI_STRING("%@ %d×%d pixels", "window title for a standalone image (uses multiplication symbol, not x)"), filenameCFString.get(), size.width(), size.height());
737 #endif
738 #else
739     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);
740 #endif
741 }
742 
mediaElementLoadingStateText()743 String DefaultLocalizationStrategy::mediaElementLoadingStateText()
744 {
745     return WEB_UI_STRING("Loading...", "Media controller status message when the media is loading");
746 }
747 
mediaElementLiveBroadcastStateText()748 String DefaultLocalizationStrategy::mediaElementLiveBroadcastStateText()
749 {
750     return WEB_UI_STRING("Live Broadcast", "Media controller status message when watching a live broadcast");
751 }
752 
localizedMediaControlElementString(const String & name)753 String DefaultLocalizationStrategy::localizedMediaControlElementString(const String& name)
754 {
755     if (name == "AudioElement")
756         return WEB_UI_STRING("audio element controller", "accessibility role description for audio element controller");
757     if (name == "VideoElement")
758         return WEB_UI_STRING("video element controller", "accessibility role description for video element controller");
759     if (name == "MuteButton")
760         return WEB_UI_STRING("mute", "accessibility role description for mute button");
761     if (name == "UnMuteButton")
762         return WEB_UI_STRING("unmute", "accessibility role description for turn mute off button");
763     if (name == "PlayButton")
764         return WEB_UI_STRING("play", "accessibility role description for play button");
765     if (name == "PauseButton")
766         return WEB_UI_STRING("pause", "accessibility role description for pause button");
767     if (name == "Slider")
768         return WEB_UI_STRING("movie time", "accessibility role description for timeline slider");
769     if (name == "SliderThumb")
770         return WEB_UI_STRING("timeline slider thumb", "accessibility role description for timeline thumb");
771     if (name == "RewindButton")
772         return WEB_UI_STRING("back 30 seconds", "accessibility role description for seek back 30 seconds button");
773     if (name == "ReturnToRealtimeButton")
774         return WEB_UI_STRING("return to realtime", "accessibility role description for return to real time button");
775     if (name == "CurrentTimeDisplay")
776         return WEB_UI_STRING("elapsed time", "accessibility role description for elapsed time display");
777     if (name == "TimeRemainingDisplay")
778         return WEB_UI_STRING("remaining time", "accessibility role description for time remaining display");
779     if (name == "StatusDisplay")
780         return WEB_UI_STRING("status", "accessibility role description for movie status");
781     if (name == "FullscreenButton")
782         return WEB_UI_STRING("fullscreen", "accessibility role description for enter fullscreen button");
783     if (name == "SeekForwardButton")
784         return WEB_UI_STRING("fast forward", "accessibility role description for fast forward button");
785     if (name == "SeekBackButton")
786         return WEB_UI_STRING("fast reverse", "accessibility role description for fast reverse button");
787     if (name == "ShowClosedCaptionsButton")
788         return WEB_UI_STRING("show closed captions", "accessibility role description for show closed captions button");
789     if (name == "HideClosedCaptionsButton")
790         return WEB_UI_STRING("hide closed captions", "accessibility role description for hide closed captions button");
791 
792     // FIXME: the ControlsPanel container should never be visible in the accessibility hierarchy.
793     if (name == "ControlsPanel")
794         return String();
795 
796     ASSERT_NOT_REACHED();
797     return String();
798 }
799 
localizedMediaControlElementHelpText(const String & name)800 String DefaultLocalizationStrategy::localizedMediaControlElementHelpText(const String& name)
801 {
802     if (name == "AudioElement")
803         return WEB_UI_STRING("audio element playback controls and status display", "accessibility role description for audio element controller");
804     if (name == "VideoElement")
805         return WEB_UI_STRING("video element playback controls and status display", "accessibility role description for video element controller");
806     if (name == "MuteButton")
807         return WEB_UI_STRING("mute audio tracks", "accessibility help text for mute button");
808     if (name == "UnMuteButton")
809         return WEB_UI_STRING("unmute audio tracks", "accessibility help text for un mute button");
810     if (name == "PlayButton")
811         return WEB_UI_STRING("begin playback", "accessibility help text for play button");
812     if (name == "PauseButton")
813         return WEB_UI_STRING("pause playback", "accessibility help text for pause button");
814     if (name == "Slider")
815         return WEB_UI_STRING("movie time scrubber", "accessibility help text for timeline slider");
816     if (name == "SliderThumb")
817         return WEB_UI_STRING("movie time scrubber thumb", "accessibility help text for timeline slider thumb");
818     if (name == "RewindButton")
819         return WEB_UI_STRING("seek movie back 30 seconds", "accessibility help text for jump back 30 seconds button");
820     if (name == "ReturnToRealtimeButton")
821         return WEB_UI_STRING("return streaming movie to real time", "accessibility help text for return streaming movie to real time button");
822     if (name == "CurrentTimeDisplay")
823         return WEB_UI_STRING("current movie time in seconds", "accessibility help text for elapsed time display");
824     if (name == "TimeRemainingDisplay")
825         return WEB_UI_STRING("number of seconds of movie remaining", "accessibility help text for remaining time display");
826     if (name == "StatusDisplay")
827         return WEB_UI_STRING("current movie status", "accessibility help text for movie status display");
828     if (name == "SeekBackButton")
829         return WEB_UI_STRING("seek quickly back", "accessibility help text for fast rewind button");
830     if (name == "SeekForwardButton")
831         return WEB_UI_STRING("seek quickly forward", "accessibility help text for fast forward button");
832     if (name == "FullscreenButton")
833         return WEB_UI_STRING("Play movie in fullscreen mode", "accessibility help text for enter fullscreen button");
834     if (name == "ShowClosedCaptionsButton")
835         return WEB_UI_STRING("start displaying closed captions", "accessibility help text for show closed captions button");
836     if (name == "HideClosedCaptionsButton")
837         return WEB_UI_STRING("stop displaying closed captions", "accessibility help text for hide closed captions button");
838 
839     ASSERT_NOT_REACHED();
840     return String();
841 }
842 
localizedMediaTimeDescription(float time)843 String DefaultLocalizationStrategy::localizedMediaTimeDescription(float time)
844 {
845     if (!isfinite(time))
846         return WEB_UI_STRING("indefinite time", "accessibility help text for an indefinite media controller time value");
847 
848     int seconds = static_cast<int>(fabsf(time));
849     int days = seconds / (60 * 60 * 24);
850     int hours = seconds / (60 * 60);
851     int minutes = (seconds / 60) % 60;
852     seconds %= 60;
853 
854     if (days)
855         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);
856     if (hours)
857         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);
858     if (minutes)
859         return formatLocalizedString(WEB_UI_STRING("%1$d minutes %2$d seconds", "accessibility help text for media controller time value >= 60 seconds"), minutes, seconds);
860     return formatLocalizedString(WEB_UI_STRING("%1$d seconds", "accessibility help text for media controller time value < 60 seconds"), seconds);
861 }
862 
validationMessageValueMissingText()863 String DefaultLocalizationStrategy::validationMessageValueMissingText()
864 {
865     return WEB_UI_STRING("value missing", "Validation message for required form control elements that have no value");
866 }
867 
validationMessageTypeMismatchText()868 String DefaultLocalizationStrategy::validationMessageTypeMismatchText()
869 {
870     return WEB_UI_STRING("type mismatch", "Validation message for input form controls with a value not matching type");
871 }
872 
validationMessagePatternMismatchText()873 String DefaultLocalizationStrategy::validationMessagePatternMismatchText()
874 {
875     return WEB_UI_STRING("pattern mismatch", "Validation message for input form controls requiring a constrained value according to pattern");
876 }
877 
validationMessageTooLongText()878 String DefaultLocalizationStrategy::validationMessageTooLongText()
879 {
880     return WEB_UI_STRING("too long", "Validation message for form control elements with a value longer than maximum allowed length");
881 }
882 
validationMessageRangeUnderflowText()883 String DefaultLocalizationStrategy::validationMessageRangeUnderflowText()
884 {
885     return WEB_UI_STRING("range underflow", "Validation message for input form controls with value lower than allowed minimum");
886 }
887 
validationMessageRangeOverflowText()888 String DefaultLocalizationStrategy::validationMessageRangeOverflowText()
889 {
890     return WEB_UI_STRING("range overflow", "Validation message for input form controls with value higher than allowed maximum");
891 }
892 
validationMessageStepMismatchText()893 String DefaultLocalizationStrategy::validationMessageStepMismatchText()
894 {
895     return WEB_UI_STRING("step mismatch", "Validation message for input form controls with value not respecting the step attribute");
896 }
897 
898 } // namespace WebCore
899 
900 #endif // USE(PLATFORM_STRATEGIES)
901