Internationalised applications must handle different languages, locales and formatting rules. Playwright can help you verify that translations appear correctly and that locale-specific formatting behaves as expected.
Testing Localised UI and Formatting
You can pass locale or language settings via URLs, cookies, headers or configuration and then assert on translated text and formatting.
// i18n-locales.spec.ts
import { test, expect } from '@playwright/test';
test('shows translated text for German locale', async ({ page }) => {
await page.goto('https://demo.myshop.com/de-DE');
await expect(page.getByText('Warenkorb')).toBeVisible();
});
Internationalisation tests are particularly important for pricing, dates, number formatting and legal content, where mistakes may have serious consequences.
Common Mistakes
Mistake 1 โ Using English-only selectors for localised tests
This is brittle.
โ Wrong: Selecting elements by English text when you expect translations.
โ Correct: Use roles, test IDs or language-agnostic attributes.
Mistake 2 โ Testing only one locale
This misses regional differences.
โ Wrong: Assuming that if it works in en-US, it works everywhere.
โ Correct: Identify key locales based on user base and test those explicitly.