save method
Save configuration to a YAML file
Implementation
Future<void> save(String path) async {
final buffer = StringBuffer();
buffer.writeln('# Shard I18n Migration Configuration');
buffer.writeln();
buffer.writeln(
'# Key generation strategy: msgid (natural language) or stable_id (semantic IDs)',
);
buffer.writeln('key_strategy: $keyStrategy');
buffer.writeln();
buffer.writeln('# Feature mapping for sharding');
buffer.writeln('# Maps source directories to JSON file names');
buffer.writeln('feature_mappings:');
if (featureMappings.isEmpty) {
buffer.writeln(' lib/pages/auth/: auth.json');
buffer.writeln(' lib/pages/profile/: profile.json');
buffer.writeln(' lib/widgets/: core.json');
} else {
for (final entry in featureMappings.entries) {
buffer.writeln(' ${entry.key}: ${entry.value}');
}
}
buffer.writeln();
buffer.writeln('# Patterns to exclude from migration');
buffer.writeln('exclude:');
if (excludePatterns.isEmpty) {
buffer.writeln(' - lib/generated/');
buffer.writeln(' - \'**/*_test.dart\'');
buffer.writeln(' - lib/config/');
} else {
for (final pattern in excludePatterns) {
buffer.writeln(' - $pattern');
}
}
buffer.writeln();
buffer.writeln('# Confidence threshold for automatic extraction (0-100)');
buffer.writeln(
'# Strings below this threshold will prompt for user review',
);
buffer.writeln('auto_extract_threshold: $autoExtractThreshold');
buffer.writeln();
buffer.writeln('# Source locale (baseline language)');
buffer.writeln('source_locale: $sourceLocale');
buffer.writeln();
buffer.writeln('# Target locales to set up (leave empty for English only)');
buffer.writeln('target_locales:');
if (targetLocales.isEmpty) {
buffer.writeln(' # - de');
buffer.writeln(' # - fr');
buffer.writeln(' # - es');
} else {
for (final locale in targetLocales) {
buffer.writeln(' - $locale');
}
}
buffer.writeln();
buffer.writeln('# Preserve original string formatting (multiline, etc.)');
buffer.writeln('preserve_formatting: $preserveFormatting');
buffer.writeln();
buffer.writeln('# Generate stable IDs for volatile/marketing copy');
buffer.writeln('stable_ids_for_volatile: $stableIdsForVolatile');
await File(path).writeAsString(buffer.toString());
}