deleteLocale method
Deletes a locale file permanently.
Implementation
Future<void> deleteLocale(String locale) async {
final normalizedLocale = locale.trim().replaceAll('-', '_');
if (normalizedLocale == config.fallbackLocale) {
throw CatalogOperationException('Cannot delete the default locale "$normalizedLocale".');
}
final dataset = await _repository.load();
if (!dataset.locales.contains(normalizedLocale)) {
throw CatalogOperationException('Locale "$normalizedLocale" does not exist.');
}
await _repository.deleteLocaleFile(normalizedLocale);
// T028: Clean up language group fallback references when a locale is deleted.
// If the deleted locale was a fallback target, remove it from all locales' fallback lists.
// This implements FR-011: automatically clear fallback references when fallback locale is deleted.
// Issue #131: Also collect affected locales for notification
final affectedLocales = await _clearFallbackReferencesOnDelete(normalizedLocale);
// Issue #131: Emit notification if there were affected fallback references
if (affectedLocales.isNotEmpty) {
_emitFallbackCascadeNotification(
deletedLocale: normalizedLocale,
affectedSourceLocales: affectedLocales,
);
}
}