Explorer reports addition
We have added a new Explorer feature to reports, with a timeline scrubber and easy anomaly detection.
Test your application's localization (l10n) and internationalization (i18n) features across different languages, regions, and cultural contexts
LoadForge can record your browser, graphically build tests, scan your site with a wizard and more. Sign up now to run your first test.
Test your application's localization (l10n) and internationalization (i18n) features across different languages, regions, and cultural contexts.
from locust import HttpUser, task, between
import random
import json
class LocalizationUser(HttpUser):
"""Test localization and internationalization features"""
wait_time = between(1, 3)
def on_start(self):
"""Initialize localization testing configuration"""
self.locales = {
'en-US': {'language': 'English', 'currency': 'USD', 'rtl': False},
'en-GB': {'language': 'English', 'currency': 'GBP', 'rtl': False},
'de-DE': {'language': 'German', 'currency': 'EUR', 'rtl': False},
'fr-FR': {'language': 'French', 'currency': 'EUR', 'rtl': False},
'ja-JP': {'language': 'Japanese', 'currency': 'JPY', 'rtl': False},
'ar-SA': {'language': 'Arabic', 'currency': 'SAR', 'rtl': True}
}
self.current_locale = random.choice(list(self.locales.keys()))
self.locale_config = self.locales[self.current_locale]
self.client.headers.update({
'Accept-Language': self.current_locale,
'X-Locale': self.current_locale,
'X-Currency': self.locale_config['currency']
})
print(f"User initialized with locale: {self.current_locale}")
@task(3)
def test_language_content(self):
"""Test language-specific content delivery"""
endpoints = ['/api/v1/content/homepage', '/api/v1/content/navigation']
endpoint = random.choice(endpoints)
with self.client.get(
endpoint,
name=f"Language Content - {self.current_locale}",
catch_response=True
) as response:
if response.status_code == 200:
try:
content = response.json()
if 'language' in content and content['language'] == self.current_locale:
print(f"Correct language content: {self.current_locale}")
response.success()
else:
response.success() # Content might not include language field
except json.JSONDecodeError:
response.success()
else:
response.failure(f"Language content failed: {response.status_code}")
@task(3)
def test_currency_formatting(self):
"""Test currency formatting and conversion"""
with self.client.get(
'/api/v1/pricing/products',
name=f"Currency Format - {self.current_locale}",
catch_response=True
) as response:
if response.status_code == 200:
try:
pricing_data = response.json()
expected_currency = self.locale_config['currency']
if 'currency' in pricing_data:
if pricing_data['currency'] == expected_currency:
print(f"Correct currency: {expected_currency}")
response.success()
else:
response.failure(f"Wrong currency: expected {expected_currency}")
else:
response.success()
except json.JSONDecodeError:
response.failure("Invalid JSON in pricing data")
else:
response.failure(f"Currency formatting failed: {response.status_code}")
@task(2)
def test_locale_switching(self):
"""Test dynamic locale switching"""
available_locales = list(self.locales.keys())
new_locale = random.choice([loc for loc in available_locales if loc != self.current_locale])
switch_data = {'locale': new_locale, 'current_locale': self.current_locale}
with self.client.post(
'/api/v1/user/locale',
json=switch_data,
name=f"Locale Switch - {new_locale}",
catch_response=True
) as response:
if response.status_code == 200:
try:
result = response.json()
if result.get('locale') == new_locale:
print(f"Successfully switched locale to {new_locale}")
response.success()
else:
response.failure("Locale switch failed")
except json.JSONDecodeError:
response.failure("Invalid locale switch response")
else:
response.failure(f"Locale switch failed: {response.status_code}")
@task(1)
def test_rtl_language_support(self):
"""Test right-to-left language support"""
if self.locale_config['rtl']:
with self.client.get(
'/api/v1/content/rtl-test',
name=f"RTL Support - {self.current_locale}",
catch_response=True
) as response:
if response.status_code == 200:
content_str = str(response.content)
rtl_indicators = ['dir="rtl"', 'text-align: right']
has_rtl = any(indicator in content_str for indicator in rtl_indicators)
if has_rtl:
print(f"RTL support detected for {self.current_locale}")
response.success()
else:
response.failure(f"RTL test failed: {response.status_code}")
Update these settings for your localization testing:
# Supported Locales
SUPPORTED_LOCALES = ['en-US', 'en-GB', 'de-DE', 'fr-FR', 'ja-JP', 'ar-SA']
# Currency Settings
CURRENCY_MAPPING = {
'en-US': 'USD', 'en-GB': 'GBP', 'de-DE': 'EUR',
'fr-FR': 'EUR', 'ja-JP': 'JPY', 'ar-SA': 'SAR'
}
# RTL Languages
RTL_LANGUAGES = ['ar-SA', 'he-IL', 'fa-IR']
Use LoadForge's region selection to test localization from appropriate geographic locations:
This locustfile ensures your application works correctly across different languages, regions, and cultural contexts.