Back to results for “Localization”
Flutter › Internationalization & Localization (i18n)

How can you properly test that your app's own localization genuinely and correctly works across all of its supported languages, including verifying that longer translated text does not actually genuinely break your existing carefully designed layouts?

Advanced

Answer

Testing localization thoroughly typically involves writing widget tests that properly render your app under each individual one of its own genuinely supported locales, verifying that the genuinely correct expected translated text actually appears as intended, and also specifically testing with a considerably longer artificial pseudo locale, since some languages such as German genuinely tend to produce considerably longer translated text than the original English source text, which can potentially and unexpectedly cause a specific button or label to visually overflow or wrap awkwardly in a way that simply never actually happened at all with the shorter original English text.
testWidgets('renders correctly in German', (tester) async {
  await tester.pumpWidget(MyApp(locale: Locale('de')));
  expect(find.text('Wilkommen'), findsOneWidget);
});
Real-world example A team discovers through dedicated localization specific testing that their German translation for a particular specific button label was noticeably considerably longer than the original English text, causing that specific button to visually overflow awkwardly, and properly fixes the underlying layout to correctly and gracefully accommodate that longer translated text instead.

Common follow-ups: What is a genuinely useful pseudo locale specifically used for stress testing potential text length related layout issues?;How do you actually properly and correctly automate running this exact same specific kind of localization test across every single one of your app's own genuinely supported languages?