Skip to content

Commit 03ca804

Browse files
authored
Code Quality: Convert Multiple Localized Strings to ICU Message Format | Fix word order problem (#15520)
1 parent 32acb63 commit 03ca804

File tree

3 files changed

+9
-21
lines changed

3 files changed

+9
-21
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,8 @@
455455
<data name="PropertiesFilesAndFoldersCountString" xml:space="preserve">
456456
<value>{0, number} {0, plural, one {file} other {files}}, {1, number} {1, plural, one {folder} other {folders}}</value>
457457
</data>
458-
<data name="PropertiesLocationsCountString" xml:space="preserve">
459-
<value>from {0, number} {0, plural, one {location} other {locations}}</value>
458+
<data name="PropertiesFilesAndFoldersAndLocationsCount" xml:space="preserve">
459+
<value>{0, number} {0, plural, one {file} other {files}}, {1, number} {1, plural, one {folder} other {folders}} from {2, number} {2, plural, one {location} other {locations}}</value>
460460
</data>
461461
<data name="BaseLayoutContextFlyoutRunAsAnotherUser.Text" xml:space="preserve">
462462
<value>Run as another user</value>
@@ -1239,7 +1239,7 @@
12391239
<value>{0, plural, one {There is one conflicting file name} other {There are # conflicting file names}}</value>
12401240
</data>
12411241
<data name="ConflictingItemsDialogSubtitleConflictsNonConflicts" xml:space="preserve">
1242-
<value>{0, plural, one {, and one outgoing item} other {, and # outgoing items}}</value>
1242+
<value>{0, plural, one {There is one conflicting file name} other {There are # conflicting file names}}, and {1, plural, one {one outgoing item} other {# outgoing items}}</value>
12431243
</data>
12441244
<data name="ConflictingItemsDialogTitle" xml:space="preserve">
12451245
<value>Conflicting {0, plural, one {file name} other {file names}}</value>

src/Files.App/ViewModels/Dialogs/FileSystemDialog/FileSystemDialogViewModel.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,10 @@ public static FileSystemDialogViewModel GetDialogViewModel(FileSystemDialogMode
151151
{
152152
titleText = "ConflictingItemsDialogTitle".GetLocalizedFormatResource(totalCount);
153153

154-
var descriptionLocalized = new StringBuilder();
155-
descriptionLocalized.Append("ConflictingItemsDialogSubtitleConflicts".GetLocalizedFormatResource(conflictingItems.Count));
154+
descriptionText = nonConflictingItems.Count > 0
155+
? "ConflictingItemsDialogSubtitleConflictsNonConflicts".GetLocalizedFormatResource(conflictingItems.Count, nonConflictingItems.Count)
156+
: "ConflictingItemsDialogSubtitleConflicts".GetLocalizedFormatResource(conflictingItems.Count);
156157

157-
if (nonConflictingItems.Count > 0)
158-
descriptionLocalized.Append("ConflictingItemsDialogSubtitleConflictsNonConflicts".GetLocalizedFormatResource(nonConflictingItems.Count));
159-
160-
descriptionLocalized.Append('.');
161-
descriptionText = descriptionLocalized.ToString();
162158
primaryButtonText = "ConflictingItemsDialogPrimaryButtonText".ToLocalized();
163159
secondaryButtonText = "Cancel".ToLocalized();
164160
}

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

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

44
using Microsoft.UI.Dispatching;
55
using System.IO;
6-
using System.Text;
76
using Windows.Storage.FileProperties;
87
using static Files.App.Helpers.Win32Helper;
98
using FileAttributes = System.IO.FileAttributes;
@@ -122,16 +121,9 @@ await Dispatcher.EnqueueOrInvokeAsync(() =>
122121

123122
public void SetItemsCountString()
124123
{
125-
var resourceText = new StringBuilder();
126-
resourceText.Append("PropertiesFilesAndFoldersCountString".GetLocalizedFormatResource(ViewModel.FilesCount, ViewModel.FoldersCount));
127-
128-
if (ViewModel.LocationsCount > 0)
129-
{
130-
resourceText.Append(' ');
131-
resourceText.Append("PropertiesLocationsCountString".GetLocalizedFormatResource(ViewModel.LocationsCount));
132-
}
133-
134-
ViewModel.FilesAndFoldersCountString = resourceText.ToString();
124+
ViewModel.FilesAndFoldersCountString = ViewModel.LocationsCount > 0
125+
? "PropertiesFilesAndFoldersAndLocationsCount".GetLocalizedFormatResource(ViewModel.FilesCount, ViewModel.FoldersCount, ViewModel.LocationsCount)
126+
: "PropertiesFilesAndFoldersCountString".GetLocalizedFormatResource(ViewModel.FilesCount, ViewModel.FoldersCount);
135127
}
136128
}
137129
}

0 commit comments

Comments
 (0)