Skip to content

Commit

Permalink
AX: Loading progress percentage used for WebAre title is not localized.
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=270670
<rdar://problem/124238656>

Reviewed by Tyler Wilcock.

Added COCOA helper function localizedPercentage and modified AXProcessingPage to return the entire localized string including the percentage.

* Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp:
(WebCore::AXIsolatedTree::reportLoadingProgress):
* Source/WebCore/en.lproj/Localizable.strings:
* Source/WebCore/platform/LocalizedStrings.cpp:
(WebCore::AXProcessingPage): Deleted.
* Source/WebCore/platform/LocalizedStrings.h:
* Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm:
(WebCore::localizedPercentage):
(WebCore::AXProcessingPage):

Canonical link: https://commits.webkit.org/275834@main
  • Loading branch information
AndresGonzalezApple committed Mar 8, 2024
1 parent 0268a59 commit bd1508d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
3 changes: 1 addition & 2 deletions Source/WebCore/accessibility/isolatedtree/AXIsolatedTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ void AXIsolatedTree::reportLoadingProgress(double processingProgress)
}

m_processingProgress = processingProgress;
String percent = String::number(std::ceil(loadingProgress() * 100)) + "%"_s;
String title = AXProcessingPage() + " "_s + percent;
String title = AXProcessingPage(loadingProgress());
AXLOG(title);

WeakPtr cache = axObjectCache();
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@
"Previous Page" = "Previous Page";

/* Title for the webarea while the accessibility tree is being built. */
"Processing page" = "Processing page";
"Processing page %@" = "Processing page %@";

/* Codec Strings */
"Professional Profile (AV1 Codec Profile)" = "Professional Profile, ";
Expand Down
5 changes: 0 additions & 5 deletions Source/WebCore/platform/LocalizedStrings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,11 +990,6 @@ String autoFillStrongPasswordLabel()
return WEB_UI_STRING("Strong Password", "Label for strong password.");
}

String AXProcessingPage()
{
return WEB_UI_STRING("Processing page", "Title for the webarea while the accessibility tree is being built.");
}

String missingPluginText()
{
return WEB_UI_STRING("Missing Plug-in", "Label text to be used when a plugin is missing");
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/LocalizedStrings.h
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ namespace WebCore {
String AXAutoFillLoadingLabel();
String autoFillStrongPasswordLabel();

String AXProcessingPage();
String AXProcessingPage(double);

String missingPluginText();
String crashedPluginText();
Expand Down
15 changes: 15 additions & 0 deletions Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@

namespace WebCore {

static NSString *localizedPercentage(double percent)
{
RetainPtr numberFormatter = adoptNS([[NSNumberFormatter alloc] init]);
[numberFormatter setLocale:[NSLocale currentLocale]];
[numberFormatter setNumberStyle:NSNumberFormatterPercentStyle];
[numberFormatter setMinimumFractionDigits:0];
[numberFormatter setMaximumFractionDigits:0];
return [numberFormatter stringFromNumber:@(percent)];
}

String AXProcessingPage(double percent)
{
return WEB_UI_FORMAT_STRING("Processing page %@", "Title for the webarea while the accessibility tree is being built.", localizedPercentage(percent));
}

String copyImageUnknownFileLabel()
{
return WEB_UI_STRING("unknown", "Unknown filename");
Expand Down

0 comments on commit bd1508d

Please sign in to comment.