Skip to content

Commit 8697522

Browse files
authored
Code Quality: Convert Multiple Localized Strings to ICU Message Format | Stage Three (#15514)
1 parent f9d0834 commit 8697522

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/Files.App/Strings/en-US/Resources.resw

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,10 @@
453453
<value>B</value>
454454
</data>
455455
<data name="PropertiesFilesAndFoldersCountString" xml:space="preserve">
456-
<value>{0:#,##0} files, {1:#,##0} folders</value>
456+
<value>{0, number} {0, plural, one {file} other {files}}, {1, number} {1, plural, one {folder} other {folders}}</value>
457457
</data>
458-
<data name="PropertiesFilesFoldersAndLocationsCountString" xml:space="preserve">
459-
<value>{0:#,##0} files, {1:#,##0} folders from {2:#,##0} locations</value>
458+
<data name="PropertiesLocationsCountString" xml:space="preserve">
459+
<value>from {0, number} {0, plural, one {location} other {locations}}</value>
460460
</data>
461461
<data name="BaseLayoutContextFlyoutRunAsAnotherUser.Text" xml:space="preserve">
462462
<value>Run as another user</value>
@@ -1589,8 +1589,8 @@
15891589
<data name="PreviewPaneLoadCloudItemButton.ToolTipService.ToolTip" xml:space="preserve">
15901590
<value>Downloads the item from the cloud and loads the preview</value>
15911591
</data>
1592-
<data name="DetailsArchiveItemCount" xml:space="preserve">
1593-
<value>{0} items ({1} files, {2} folders)</value>
1592+
<data name="DetailsArchiveItems" xml:space="preserve">
1593+
<value>{0, plural, one {# item} other {# items}} ({1, plural, one {# file} other {# files}}, {2, plural, one {# folder} other {# folders}})</value>
15941594
</data>
15951595
<data name="PropertyUncompressedSize" xml:space="preserve">
15961596
<value>Uncompressed size</value>

src/Files.App/ViewModels/Properties/Items/BaseProperties.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using Microsoft.UI.Dispatching;
55
using System.IO;
6+
using System.Text;
67
using Windows.Storage.FileProperties;
78
using static Files.App.Helpers.Win32Helper;
89
using FileAttributes = System.IO.FileAttributes;
@@ -121,14 +122,16 @@ await Dispatcher.EnqueueOrInvokeAsync(() =>
121122

122123
public void SetItemsCountString()
123124
{
125+
var resourceText = new StringBuilder();
126+
resourceText.Append("PropertiesFilesAndFoldersCountString".GetLocalizedFormatResource(ViewModel.FilesCount, ViewModel.FoldersCount));
127+
124128
if (ViewModel.LocationsCount > 0)
125129
{
126-
ViewModel.FilesAndFoldersCountString = string.Format("PropertiesFilesFoldersAndLocationsCountString".GetLocalizedResource(), ViewModel.FilesCount, ViewModel.FoldersCount, ViewModel.LocationsCount);
127-
}
128-
else
129-
{
130-
ViewModel.FilesAndFoldersCountString = string.Format("PropertiesFilesAndFoldersCountString".GetLocalizedResource(), ViewModel.FilesCount, ViewModel.FoldersCount);
130+
resourceText.Append(' ');
131+
resourceText.Append("PropertiesLocationsCountString".GetLocalizedFormatResource(ViewModel.LocationsCount));
131132
}
133+
134+
ViewModel.FilesAndFoldersCountString = resourceText.ToString();
132135
}
133136
}
134137
}

src/Files.App/ViewModels/UserControls/Previews/ArchivePreviewViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public override async Task<List<FileProperty>> LoadPreviewAndDetailsAsync()
5151

5252
folderCount = (int)zipFile.FilesCount - fileCount;
5353

54-
string propertyItemCount = string.Format("DetailsArchiveItemCount".GetLocalizedResource(), zipFile.FilesCount, fileCount, folderCount);
54+
string propertyItemCount = "DetailsArchiveItems".GetLocalizedFormatResource(zipFile.FilesCount, fileCount, folderCount);
5555
details.Add(GetFileProperty("PropertyItemCount", propertyItemCount));
5656
details.Add(GetFileProperty("PropertyUncompressedSize", totalSize.ToLongSizeString()));
5757

0 commit comments

Comments
 (0)