generateLocaleKeys function
Extracts string literals from lib/**/*.dart, generates locale_keys.dart,
then prompts for translation locales and optionally replaces strings with
LocaleKeys.xyz.tr. Uses a progress spinner during extraction.
Implementation
Future<void> generateLocaleKeys() async {
final currentDir = Directory.current;
final libDir = Directory('${currentDir.path}/lib');
if (!libDir.existsSync()) {
ConsoleLog.error('❌ No lib folder found. Run inside Flutter project root.');
exit(1);
}
final map = await runWithSpinner<Map<String, String>?>(
'Extracting strings and generating locale keys',
() => _extractAndWriteLocaleKeys(libDir),
);
if (map == null || map.isEmpty) return;
ConsoleLog.success('LocaleKeys generated successfully.');
await generateTranslationFiles();
await replaceStringsWithLocaleKeys(extractedKeyValueMap: map);
}