Skip to content

Commit 2a24ee0

Browse files
Merge pull request #359 from MihaiCristianCondrea/codex/check-app-strings-for-pluralization-issue
Handle cleanup string pluralization
2 parents c98e32c + 6a69125 commit 2a24ee0

File tree

31 files changed

+260
-69
lines changed

31 files changed

+260
-69
lines changed

app/src/main/kotlin/com/d4rk/cleaner/app/clean/analyze/ui/components/CleaningAnimationScreen.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import androidx.compose.runtime.getValue
1515
import androidx.compose.ui.Alignment
1616
import androidx.compose.ui.Modifier
1717
import androidx.compose.ui.layout.ContentScale
18-
import androidx.compose.ui.res.stringResource
18+
import androidx.compose.ui.res.pluralStringResource
1919
import com.airbnb.lottie.compose.LottieAnimation
2020
import com.airbnb.lottie.compose.LottieCompositionSpec
2121
import com.airbnb.lottie.compose.LottieConstants
@@ -62,7 +62,7 @@ fun CleaningAnimationScreen(
6262
LargeVerticalSpacer()
6363

6464
Text(
65-
text = stringResource(id = R.string.cleanup_progress, cleaned, total),
65+
text = pluralStringResource(R.plurals.cleanup_progress, total, cleaned, total),
6666
style = MaterialTheme.typography.bodyMedium
6767
)
6868
}

app/src/main/kotlin/com/d4rk/cleaner/app/clean/largefiles/ui/LargeFilesViewModel.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,13 @@ class LargeFilesViewModel(
195195
onEvent(LargeFilesEvent.LoadLargeFiles)
196196

197197
val message = if (failedCount > 0) {
198-
UiTextHelper.StringResource(
199-
R.string.cleanup_partial,
200-
listOf(successCount, failedCount)
198+
UiTextHelper.DynamicString(
199+
application.resources.getQuantityString(
200+
R.plurals.cleanup_partial,
201+
successCount,
202+
successCount,
203+
failedCount,
204+
)
201205
)
202206
} else {
203207
UiTextHelper.StringResource(R.string.all_clean)

app/src/main/kotlin/com/d4rk/cleaner/app/clean/scanner/ui/ScannerViewModel.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,13 @@ class ScannerViewModel(
612612
val successCount = selectedCount - failedCount
613613

614614
val message = if (failedCount > 0) {
615-
UiTextHelper.StringResource(
616-
R.string.cleanup_partial,
617-
listOf(successCount, failedCount)
615+
UiTextHelper.DynamicString(
616+
application.resources.getQuantityString(
617+
R.plurals.cleanup_partial,
618+
successCount,
619+
successCount,
620+
failedCount,
621+
)
618622
)
619623
} else {
620624
UiTextHelper.StringResource(R.string.all_clean)

app/src/main/kotlin/com/d4rk/cleaner/app/clean/scanner/work/FileCleanupWorker.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ class FileCleanupWorker(
104104
var processed = 0
105105
builder.setProgress(total, processed, false)
106106
.setContentText(
107-
applicationContext.getString(
108-
R.string.cleanup_progress,
107+
applicationContext.resources.getQuantityString(
108+
R.plurals.cleanup_progress,
109+
total,
109110
processed,
110111
total,
111112
),
@@ -163,8 +164,9 @@ class FileCleanupWorker(
163164
processed++
164165
builder.setProgress(total, processed, false)
165166
.setContentText(
166-
applicationContext.getString(
167-
R.string.cleanup_progress,
167+
applicationContext.resources.getQuantityString(
168+
R.plurals.cleanup_progress,
169+
total,
168170
processed,
169171
total,
170172
),
@@ -227,8 +229,9 @@ class FileCleanupWorker(
227229
if (hasPermission) {
228230
builder.setContentTitle(applicationContext.getString(R.string.cleanup_finished))
229231
.setContentText(
230-
applicationContext.getString(
231-
R.string.cleanup_partial,
232+
applicationContext.resources.getQuantityString(
233+
R.plurals.cleanup_partial,
234+
successCount,
232235
successCount,
233236
failedCount,
234237
),

app/src/main/kotlin/com/d4rk/cleaner/app/clean/trash/ui/TrashViewModel.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,13 @@ class TrashViewModel(
121121
}
122122

123123
val message = if (failedCount > 0) {
124-
UiTextHelper.StringResource(
125-
R.string.cleanup_partial,
126-
listOf(successCount, failedCount)
124+
UiTextHelper.DynamicString(
125+
application.resources.getQuantityString(
126+
R.plurals.cleanup_partial,
127+
successCount,
128+
successCount,
129+
failedCount,
130+
)
127131
)
128132
} else {
129133
UiTextHelper.StringResource(R.string.all_clean)

app/src/main/res/values-ar-rEG/strings.xml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,26 @@
434434
<string name="failed_to_update_trash_size">فشل في تحديث حجم القمامة: %1$s</string>
435435
<string name="no_cleaning_options_selected">يرجى اختيار تفضيلات التنظيف الخاصة بك في الإعدادات للمتابعة.</string>
436436
<string name="cleaning_in_progress">جاري التنظيف</string>
437-
<string name="cleanup_progress">تم تنظيف %1$d/%2$d ملف</string>
437+
<plurals name="cleanup_progress">
438+
<item quantity="zero">تم تنظيف %1$d/%2$d ملف</item>
439+
<item quantity="one">تم تنظيف %1$d/%2$d ملف</item>
440+
<item quantity="two">تم تنظيف %1$d/%2$d ملفين</item>
441+
<item quantity="few">تم تنظيف %1$d/%2$d ملفات</item>
442+
<item quantity="many">تم تنظيف %1$d/%2$d ملفًا</item>
443+
<item quantity="other">تم تنظيف %1$d/%2$d ملف</item>
444+
</plurals>
438445
<string name="cleanup_finished">اكتمل التنظيف</string>
439446
<string name="cleanup_failed">فشل التنظيف</string>
440447
<string name="cleanup_failed_details">تعذر حذف بعض الملفات</string>
441448
<string name="cleanup_cancelled">تم إلغاء التنظيف</string>
442-
<string name="cleanup_partial">تم حذف %1$d ملفًا، فشل حذف %2$d</string>
449+
<plurals name="cleanup_partial">
450+
<item quantity="zero">تم حذف %1$d ملف، فشل حذف %2$d</item>
451+
<item quantity="one">تم حذف %1$d ملف، فشل حذف %2$d</item>
452+
<item quantity="two">تم حذف %1$d ملفين، فشل حذف %2$d</item>
453+
<item quantity="few">تم حذف %1$d ملفات، فشل حذف %2$d</item>
454+
<item quantity="many">تم حذف %1$d ملفًا، فشل حذف %2$d</item>
455+
<item quantity="other">تم حذف %1$d ملف، فشل حذف %2$d</item>
456+
</plurals>
443457
<plurals name="current_streak_label">
444458
<item quantity="zero">السلسلة الحالية: %1$d يومًا على التوالي</item>
445459
<item quantity="one">السلسلة الحالية: %1$d يومًا على التوالي</item>

app/src/main/res/values-bg-rBG/strings.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,18 @@
401401
<string name="failed_to_update_trash_size">Неуспешно актуализиране на размера на боклука: %1$s</string>
402402
<string name="no_cleaning_options_selected">Моля, изберете вашите предпочитания за почистване в настройките, за да продължите.</string>
403403
<string name="cleaning_in_progress">Почистването е в ход</string>
404-
<string name="cleanup_progress">%1$d/%2$d файла почистени</string>
404+
<plurals name="cleanup_progress">
405+
<item quantity="one">%1$d/%2$d файл почистен</item>
406+
<item quantity="other">%1$d/%2$d файла почистени</item>
407+
</plurals>
405408
<string name="cleanup_finished">Почистването приключи</string>
406409
<string name="cleanup_failed">Почистването се провали</string>
407410
<string name="cleanup_failed_details">Някои файлове не можаха да бъдат изтрити</string>
408411
<string name="cleanup_cancelled">Почистването е отменено</string>
409-
<string name="cleanup_partial">%1$d файла изтрити, %2$d неуспешни</string>
412+
<plurals name="cleanup_partial">
413+
<item quantity="one">%1$d файл изтрит, %2$d неуспешни</item>
414+
<item quantity="other">%1$d файла изтрити, %2$d неуспешни</item>
415+
</plurals>
410416
<plurals name="current_streak_label">
411417
<item quantity="one">Текуща серия: %1$d ден подред</item>
412418
<item quantity="other">Текуща серия: %1$d дни подред</item>

app/src/main/res/values-bn-rBD/strings.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,18 @@
401401
<string name="failed_to_update_trash_size">আবর্জনার আকার আপডেট করতে ব্যর্থ: %1$s</string>
402402
<string name="no_cleaning_options_selected">এগিয়ে যেতে সেটিংসে আপনার পরিষ্কারের পছন্দগুলি চয়ন করুন।</string>
403403
<string name="cleaning_in_progress">পরিষ্কার চলছে</string>
404-
<string name="cleanup_progress">%1$d/%2$d টি ফাইল পরিষ্কার করা হয়েছে</string>
404+
<plurals name="cleanup_progress">
405+
<item quantity="one">%1$d/%2$d টি ফাইল পরিষ্কার করা হয়েছে</item>
406+
<item quantity="other">%1$d/%2$d টি ফাইল পরিষ্কার করা হয়েছে</item>
407+
</plurals>
405408
<string name="cleanup_finished">পরিষ্কার সম্পন্ন</string>
406409
<string name="cleanup_failed">পরিষ্কার ব্যর্থ হয়েছে</string>
407410
<string name="cleanup_failed_details">কিছু ফাইল মুছে ফেলা যায়নি</string>
408411
<string name="cleanup_cancelled">পরিষ্কার বাতিল করা হয়েছে</string>
409-
<string name="cleanup_partial">%1$d টি ফাইল মুছে ফেলা হয়েছে, %2$d টি ব্যর্থ হয়েছে</string>
412+
<plurals name="cleanup_partial">
413+
<item quantity="one">%1$d টি ফাইল মুছে ফেলা হয়েছে, %2$d টি ব্যর্থ হয়েছে</item>
414+
<item quantity="other">%1$d টি ফাইল মুছে ফেলা হয়েছে, %2$d টি ব্যর্থ হয়েছে</item>
415+
</plurals>
410416
<plurals name="current_streak_label">
411417
<item quantity="one">বর্তমান স্ট্রীক: পরপর %1$d দিন</item>
412418
<item quantity="other">বর্তমান স্ট্রীক: পরপর %1$d দিন</item>

app/src/main/res/values-de-rDE/strings.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,12 +402,18 @@
402402
<string name="failed_to_update_trash_size">Die Müllgröße nicht aktualisieren: %1$s</string>
403403
<string name="no_cleaning_options_selected">Bitte wählen Sie Ihre Reinigungseinstellungen in Einstellungen, um fortzufahren.</string>
404404
<string name="cleaning_in_progress">Reinigung läuft</string>
405-
<string name="cleanup_progress">%1$d/%2$d Dateien bereinigt</string>
405+
<plurals name="cleanup_progress">
406+
<item quantity="one">%1$d/%2$d Datei bereinigt</item>
407+
<item quantity="other">%1$d/%2$d Dateien bereinigt</item>
408+
</plurals>
406409
<string name="cleanup_finished">Bereinigung abgeschlossen</string>
407410
<string name="cleanup_failed">Bereinigung fehlgeschlagen</string>
408411
<string name="cleanup_failed_details">Einige Dateien konnten nicht gelöscht werden</string>
409412
<string name="cleanup_cancelled">Bereinigung abgebrochen</string>
410-
<string name="cleanup_partial">%1$d Dateien gelöscht, %2$d fehlgeschlagen</string>
413+
<plurals name="cleanup_partial">
414+
<item quantity="one">%1$d Datei gelöscht, %2$d fehlgeschlagen</item>
415+
<item quantity="other">%1$d Dateien gelöscht, %2$d fehlgeschlagen</item>
416+
</plurals>
411417
<plurals name="current_streak_label">
412418
<item quantity="one">Aktuelle Serie: %1$d Tag infolge</item>
413419
<item quantity="other">Aktuelle Serie: %1$d Tage infolge</item>

app/src/main/res/values-es-rGQ/strings.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,12 +410,18 @@
410410
<string name="failed_to_update_trash_size">No se pudo actualizar el tamaño de la basura: %1$s</string>
411411
<string name="no_cleaning_options_selected">Elija sus preferencias de limpieza en Configuración para continuar.</string>
412412
<string name="cleaning_in_progress">Limpieza en curso</string>
413-
<string name="cleanup_progress">%1$d/%2$d archivos limpiados</string>
413+
<plurals name="cleanup_progress">
414+
<item quantity="one">%1$d/%2$d archivo limpiado</item>
415+
<item quantity="other">%1$d/%2$d archivos limpiados</item>
416+
</plurals>
414417
<string name="cleanup_finished">Limpieza finalizada</string>
415418
<string name="cleanup_failed">Limpieza fallida</string>
416419
<string name="cleanup_failed_details">No se pudieron eliminar algunos archivos</string>
417420
<string name="cleanup_cancelled">Limpieza cancelada</string>
418-
<string name="cleanup_partial">%1$d archivos eliminados, %2$d fallidos</string>
421+
<plurals name="cleanup_partial">
422+
<item quantity="one">%1$d archivo eliminado, %2$d fallidos</item>
423+
<item quantity="other">%1$d archivos eliminados, %2$d fallidos</item>
424+
</plurals>
419425
<plurals name="current_streak_label">
420426
<item quantity="one">Racha actual: %1$d día seguido</item>
421427
<item quantity="many">Racha actual: %1$d días seguidos</item>

0 commit comments

Comments
 (0)