diff --git a/lib/generated/intl/messages_en.dart b/lib/generated/intl/messages_en.dart index ed7b8c3de..31e051123 100644 --- a/lib/generated/intl/messages_en.dart +++ b/lib/generated/intl/messages_en.dart @@ -180,6 +180,9 @@ class MessageLookup extends MessageLookupByLibrary { static String m37(email) => "This is ${email}\'s Verification ID"; + static String m62(count) => + "${Intl.plural(count, zero: '', one: '1 day', other: '${count} days')}"; + static String m38(email) => "Verify ${email}"; static String m39(email) => "We have sent a mail to ${email}"; @@ -1151,6 +1154,7 @@ class MessageLookup extends MessageLookupByLibrary { "total": MessageLookupByLibrary.simpleMessage("total"), "totalSize": MessageLookupByLibrary.simpleMessage("Total size"), "trash": MessageLookupByLibrary.simpleMessage("Trash"), + "trashDaysLeft": m62, "tryAgain": MessageLookupByLibrary.simpleMessage("Try again"), "turnOnBackupForAutoUpload": MessageLookupByLibrary.simpleMessage( "Turn on backup to automatically upload files added to this device folder to ente."), diff --git a/lib/generated/l10n.dart b/lib/generated/l10n.dart index 13d1c3467..6e22e786f 100644 --- a/lib/generated/l10n.dart +++ b/lib/generated/l10n.dart @@ -5199,6 +5199,20 @@ class S { ); } + /// `{count, plural, =0 {} =1 {1 day} other {{count} days}}` + String trashDaysLeft(int count) { + return Intl.plural( + count, + zero: '', + one: '1 day', + other: '$count days', + name: 'trashDaysLeft', + desc: + 'Text to indicate number of days remaining before permanent deletion', + args: [count], + ); + } + /// `Delete All` String get deleteAll { return Intl.message( diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 7ddca5cfb..06660d33f 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -736,6 +736,16 @@ "referFriendsAnd2xYourPlan": "Refer friends and 2x your plan", "shareAlbumHint": "Open an album and tap the share button on the top right to share.", "itemsShowTheNumberOfDaysRemainingBeforePermanentDeletion": "Items show the number of days remaining before permanent deletion", + "trashDaysLeft": "{count, plural, =0 {} =1 {1 day} other {{count} days}}", + "@trashDaysLeft": { + "description": "Text to indicate number of days remaining before permanent deletion", + "placeholders": { + "count": { + "example": "1|2|3", + "type": "int" + } + } + }, "deleteAll": "Delete All", "renameAlbum": "Rename album", "rename": "Rename", diff --git a/lib/ui/viewer/file/file_icons_widget.dart b/lib/ui/viewer/file/file_icons_widget.dart index 11ec540c5..efdfb0a84 100644 --- a/lib/ui/viewer/file/file_icons_widget.dart +++ b/lib/ui/viewer/file/file_icons_widget.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:photos/ente_theme_data.dart'; +import "package:photos/generated/l10n.dart"; import 'package:photos/models/collection.dart'; import 'package:photos/models/trash_file.dart'; import 'package:photos/theme/colors.dart'; import 'package:photos/ui/sharing/user_avator_widget.dart'; -import 'package:photos/utils/date_time_util.dart'; class ThumbnailPlaceHolder extends StatelessWidget { const ThumbnailPlaceHolder({Key? key}) : super(key: key); @@ -135,6 +135,10 @@ class TrashedFileOverlayText extends StatelessWidget { @override Widget build(BuildContext context) { + final int daysLeft = + ((file.deleteBy - DateTime.now().microsecondsSinceEpoch) / + Duration.microsecondsPerDay) + .ceil(); return Container( decoration: BoxDecoration( gradient: LinearGradient( @@ -146,7 +150,7 @@ class TrashedFileOverlayText extends StatelessWidget { alignment: Alignment.bottomCenter, padding: const EdgeInsets.only(bottom: 5), child: Text( - daysLeft(file.deleteBy), + S.of(context).trashDaysLeft(daysLeft), style: Theme.of(context) .textTheme .subtitle2! diff --git a/lib/utils/date_time_util.dart b/lib/utils/date_time_util.dart index 2e26207a4..ce510398b 100644 --- a/lib/utils/date_time_util.dart +++ b/lib/utils/date_time_util.dart @@ -71,13 +71,6 @@ String getFormattedTime(BuildContext context, DateTime dateTime) { ); } -String daysLeft(int futureTime) { - final int daysLeft = ((futureTime - DateTime.now().microsecondsSinceEpoch) / - Duration.microsecondsPerDay) - .ceil(); - return '$daysLeft day' + (daysLeft <= 1 ? "" : "s"); -} - String formatDuration(Duration position) { final ms = position.inMilliseconds;