Files
pluriwave/test/l10n/arb_test_helpers.dart
T

37 lines
932 B
Dart

import 'dart:convert';
import 'dart:io';
/// All 13 supported locale codes backing `lib/l10n/app_*.arb`.
///
/// `flutter test` always runs with the working directory set to the
/// package root, so `lib/l10n/...` below resolves correctly without any
/// extra path juggling.
const List<String> supportedArbLocales = [
'ar',
'bn',
'de',
'en',
'es',
'fr',
'hi',
'id',
'it',
'ja',
'pt',
'ru',
'zh',
];
/// Reads and decodes `lib/l10n/app_<locale>.arb` as a JSON map.
Map<String, dynamic> readArb(String locale) {
final file = File('lib/l10n/app_$locale.arb');
return json.decode(file.readAsStringSync()) as Map<String, dynamic>;
}
/// Real translation keys only -- excludes ICU metadata entries (`@key`)
/// and the `@@locale` marker, which are not themselves translatable
/// strings.
Set<String> realKeys(Map<String, dynamic> arb) {
return arb.keys.where((key) => !key.startsWith('@')).toSet();
}