feat(localization): Implement Swedish localization and error messages
- Added localization support for Swedish and English languages. - Integrated localized strings for user messages in the API error mapper. - Updated UI components to use localized strings for labels and messages. - Ensured all error messages are context-aware and utilize the localization framework. - Created regression test to prevent common ASCII fallbacks in Swedish UI text.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
test('Flutter lib should not contain common ASCII fallbacks for Swedish UI text', () {
|
||||
const forbiddenSpellings = <String, String>{
|
||||
'Forsok': 'Försök',
|
||||
'gatt ut': 'gått ut',
|
||||
'behorighet': 'behörighet',
|
||||
'Natverksfel': 'Nätverksfel',
|
||||
'ovantat': 'oväntat',
|
||||
'Lagg': 'Lägg',
|
||||
'Valj': 'Välj',
|
||||
'Mangd': 'Mängd',
|
||||
'Oppnad': 'Öppnad',
|
||||
'Bast fore': 'Bäst före',
|
||||
'Inkop': 'Inköp',
|
||||
'Ovrigt': 'Övrigt',
|
||||
'Okant': 'Okänt',
|
||||
'hamta': 'hämta',
|
||||
'tillgangligt': 'tillgängligt',
|
||||
'raknar': 'räknar',
|
||||
};
|
||||
|
||||
final offenders = <String>[];
|
||||
final files = Directory('lib')
|
||||
.listSync(recursive: true)
|
||||
.whereType<File>()
|
||||
.where((file) => file.path.endsWith('.dart'));
|
||||
|
||||
for (final file in files) {
|
||||
final content = file.readAsStringSync();
|
||||
for (final entry in forbiddenSpellings.entries) {
|
||||
if (content.contains(entry.key)) {
|
||||
offenders.add('${file.path}: found "${entry.key}"; use "${entry.value}"');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
expect(
|
||||
offenders,
|
||||
isEmpty,
|
||||
reason: offenders.isEmpty ? null : offenders.join('\n'),
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user