Extract strings

This commit is contained in:
Neeraj Gupta
2024-09-18 12:39:38 +05:30
parent 3577b1f213
commit 5fa05e3406
6 changed files with 252 additions and 8 deletions

View File

@@ -641,6 +641,26 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage(
"Disabling two-factor authentication..."),
"discord": MessageLookupByLibrary.simpleMessage("Discord"),
"discover": MessageLookupByLibrary.simpleMessage("Discover"),
"discover_babies": MessageLookupByLibrary.simpleMessage("Babies"),
"discover_celebrations":
MessageLookupByLibrary.simpleMessage("Celebrations"),
"discover_food": MessageLookupByLibrary.simpleMessage("Food"),
"discover_greenery": MessageLookupByLibrary.simpleMessage("Greenery"),
"discover_hills": MessageLookupByLibrary.simpleMessage("Hills"),
"discover_identity": MessageLookupByLibrary.simpleMessage("Identity"),
"discover_memes": MessageLookupByLibrary.simpleMessage("Memes"),
"discover_notes": MessageLookupByLibrary.simpleMessage("Notes"),
"discover_pets": MessageLookupByLibrary.simpleMessage("Pets"),
"discover_receipts": MessageLookupByLibrary.simpleMessage("Receipts"),
"discover_screenshots":
MessageLookupByLibrary.simpleMessage("Screenshots"),
"discover_selfies": MessageLookupByLibrary.simpleMessage("Selfies"),
"discover_sunset": MessageLookupByLibrary.simpleMessage("Sunset"),
"discover_visiting_cards":
MessageLookupByLibrary.simpleMessage("Visiting Cards"),
"discover_wallpapers":
MessageLookupByLibrary.simpleMessage("Wallpapers"),
"dismiss": MessageLookupByLibrary.simpleMessage("Dismiss"),
"distanceInKMUnit": MessageLookupByLibrary.simpleMessage("km"),
"doNotSignOut": MessageLookupByLibrary.simpleMessage("Do not sign out"),

View File

@@ -2976,6 +2976,167 @@ class S {
);
}
/// `Discover`
String get discover {
return Intl.message(
'Discover',
name: 'discover',
desc:
'The text to display for the discover section under which we show receipts, screenshots, sunsets, greenery, etc.',
args: [],
);
}
/// `Identity`
String get discover_identity {
return Intl.message(
'Identity',
name: 'discover_identity',
desc: '',
args: [],
);
}
/// `Screenshots`
String get discover_screenshots {
return Intl.message(
'Screenshots',
name: 'discover_screenshots',
desc: '',
args: [],
);
}
/// `Receipts`
String get discover_receipts {
return Intl.message(
'Receipts',
name: 'discover_receipts',
desc: '',
args: [],
);
}
/// `Notes`
String get discover_notes {
return Intl.message(
'Notes',
name: 'discover_notes',
desc: '',
args: [],
);
}
/// `Memes`
String get discover_memes {
return Intl.message(
'Memes',
name: 'discover_memes',
desc: '',
args: [],
);
}
/// `Visiting Cards`
String get discover_visiting_cards {
return Intl.message(
'Visiting Cards',
name: 'discover_visiting_cards',
desc: '',
args: [],
);
}
/// `Babies`
String get discover_babies {
return Intl.message(
'Babies',
name: 'discover_babies',
desc: '',
args: [],
);
}
/// `Pets`
String get discover_pets {
return Intl.message(
'Pets',
name: 'discover_pets',
desc: '',
args: [],
);
}
/// `Selfies`
String get discover_selfies {
return Intl.message(
'Selfies',
name: 'discover_selfies',
desc: '',
args: [],
);
}
/// `Wallpapers`
String get discover_wallpapers {
return Intl.message(
'Wallpapers',
name: 'discover_wallpapers',
desc: '',
args: [],
);
}
/// `Food`
String get discover_food {
return Intl.message(
'Food',
name: 'discover_food',
desc: '',
args: [],
);
}
/// `Celebrations`
String get discover_celebrations {
return Intl.message(
'Celebrations',
name: 'discover_celebrations',
desc: '',
args: [],
);
}
/// `Sunset`
String get discover_sunset {
return Intl.message(
'Sunset',
name: 'discover_sunset',
desc: '',
args: [],
);
}
/// `Hills`
String get discover_hills {
return Intl.message(
'Hills',
name: 'discover_hills',
desc: '',
args: [],
);
}
/// `Greenery`
String get discover_greenery {
return Intl.message(
'Greenery',
name: 'discover_greenery',
desc: '',
args: [],
);
}
/// `Please note that machine learning will result in a higher bandwidth and battery usage until all items are indexed. Consider using the desktop app for faster indexing, all results will be synced automatically.`
String get mlIndexingDescription {
return Intl.message(

View File

@@ -420,6 +420,25 @@
"mlConsentPrivacy": "Please click here for more details about this feature in our privacy policy",
"mlConsentConfirmation": "I understand, and wish to enable machine learning",
"magicSearch": "Magic search",
"discover": "Discover",
"@discover": {
"description": "The text to display for the discover section under which we show receipts, screenshots, sunsets, greenery, etc."
},
"discover_identity": "Identity",
"discover_screenshots": "Screenshots",
"discover_receipts": "Receipts",
"discover_notes": "Notes",
"discover_memes": "Memes",
"discover_visiting_cards": "Visiting Cards",
"discover_babies": "Babies",
"discover_pets": "Pets",
"discover_selfies": "Selfies",
"discover_wallpapers": "Wallpapers",
"discover_food": "Food",
"discover_celebrations": "Celebrations",
"discover_sunset": "Sunset",
"discover_hills": "Hills",
"discover_greenery": "Greenery",
"mlIndexingDescription": "Please note that machine learning will result in a higher bandwidth and battery usage until all items are indexed. Consider using the desktop app for faster indexing, all results will be synced automatically.",
"loadingModel": "Downloading models...",
"waitingForWifi": "Waiting for WiFi...",

View File

@@ -58,7 +58,7 @@ extension SectionTypeExtensions on SectionType {
case SectionType.face:
return S.of(context).people;
case SectionType.magic:
return "Discover";
return S.of(context).discover;
case SectionType.moment:
return S.of(context).moments;
case SectionType.location:
@@ -250,7 +250,7 @@ extension SectionTypeExtensions on SectionType {
case SectionType.face:
return SearchService.instance.getAllFace(limit);
case SectionType.magic:
return SearchService.instance.getMagicSectionResutls();
return SearchService.instance.getMagicSectionResutls(context);
case SectionType.moment:
return SearchService.instance.getRandomMomentsSearchResults(context);

View File

@@ -4,12 +4,14 @@ import "dart:io";
import "package:computer/computer.dart";
import "package:flutter/foundation.dart";
import "package:flutter/widgets.dart";
import "package:logging/logging.dart";
import "package:path_provider/path_provider.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/file_uploaded_event.dart";
import "package:photos/events/magic_cache_updated_event.dart";
import "package:photos/extensions/stop_watch.dart";
import "package:photos/l10n/l10n.dart";
import "package:photos/models/file/extensions/file_props.dart";
import "package:photos/models/file/file.dart";
import "package:photos/models/ml/discover/prompt.dart";
@@ -65,7 +67,45 @@ class MagicCache {
}
}
String getLocalizedTitle(BuildContext context, String title) {
switch (title) {
case 'Identity':
return context.l10n.discover_identity;
case 'Screenshots':
return context.l10n.discover_screenshots;
case 'Receipts':
return context.l10n.discover_receipts;
case 'Notes':
return context.l10n.discover_notes;
case 'Memes':
return context.l10n.discover_memes;
case 'Visiting Cards':
return context.l10n.discover_visiting_cards;
case 'Babies':
return context.l10n.discover_babies;
case 'Pets':
return context.l10n.discover_pets;
case 'Selfies':
return context.l10n.discover_selfies;
case 'Wallpapers':
return context.l10n.discover_wallpapers;
case 'Food':
return context.l10n.discover_food;
case 'Celebrations':
return context.l10n.discover_celebrations;
case 'Sunset':
return context.l10n.discover_sunset;
case 'Hills':
return context.l10n.discover_hills;
case 'Greenery':
return context.l10n.discover_greenery;
default:
return title; // If no match, return the original string
}
}
GenericSearchResult? toGenericSearchResult(
BuildContext context,
Prompt prompt,
List<EnteFile> enteFilesInMagicCache,
Map<int, int> fileIdToPositionMap,
@@ -79,9 +119,10 @@ GenericSearchResult? toGenericSearchResult(
.compareTo(fileIdToPositionMap[b.uploadedFileID!]!);
});
}
final String title = getLocalizedTitle(context, prompt.title);
return GenericSearchResult(
ResultType.magic,
prompt.title,
title,
enteFilesInMagicCache,
params: {
"enableGrouping": prompt.recentFirst,
@@ -92,12 +133,12 @@ GenericSearchResult? toGenericSearchResult(
ctx,
MagicResultScreen(
enteFilesInMagicCache,
name: prompt.title,
name: title,
enableGrouping: prompt.recentFirst,
fileIdToPosMap: fileIdToPositionMap,
heroTag: GenericSearchResult(
ResultType.magic,
prompt.title,
title,
enteFilesInMagicCache,
).heroTag(),
),
@@ -255,7 +296,8 @@ class MagicCacheService {
await File(await _getCachePath()).delete();
}
Future<List<GenericSearchResult>> getMagicGenericSearchResult() async {
Future<List<GenericSearchResult>> getMagicGenericSearchResult(
BuildContext context) async {
try {
final EnteWatch? w =
kDebugMode ? EnteWatch("magicGenericSearchResult") : null;
@@ -296,6 +338,7 @@ class MagicCacheService {
}
for (final p in prompts) {
final genericSearchResult = toGenericSearchResult(
context,
p,
magicIdToFiles[p.title] ?? [],
promptFileOrder[p.title] ?? {},

View File

@@ -177,9 +177,10 @@ class SearchService {
return searchResults;
}
Future<List<GenericSearchResult>> getMagicSectionResutls() async {
Future<List<GenericSearchResult>> getMagicSectionResutls(
BuildContext context) async {
if (localSettings.isMLIndexingEnabled && flagService.internalUser) {
return MagicCacheService.instance.getMagicGenericSearchResult();
return MagicCacheService.instance.getMagicGenericSearchResult(context);
} else {
return <GenericSearchResult>[];
}