This is a pragmatic i18n test harness for a bilingual/ multilingual website. It mirrors a Login/Register view and lets you switch languages with a selector. Preference is persisted in a cookie and respected on next visit.
- Languages: English (en), Spanish (es), Japanese (ja), German (de), French (fr).
- Preference order:
?lang=xxquery >langcookie >Accept-Languageheader >en. - Accessible tabs, semantic HTML, zero dependencies.
- PHP arrays for translations; add new languages under
i18n/<code>.php.
# Build image
docker build -t mrhappy-i18n .
# Run container on http://localhost:8080
docker run --rm -p 8080:80 mrhappy-i18nOr with Compose:
docker compose up --build
# open http://localhost:8080You only need PHP:
php -S localhost:8000 -t .
# open http://localhost:8000- Copy
i18n/en.phptoi18n/it.php(for example). - Translate values in
$Tand save. - Add the language code to
$SUPPORTEDinindex.php. - Add a
lang.name.itentry in all language packs for proper display name.
- Demo only: forms do not submit/ store data.
- Cookie:
lang,Lax, TTL 365 days. - Fallback prioritizes explicit URL
?lang=over cookies to make demos deterministic for stakeholders.
index.php
i18n/
en.php es.php ja.php de.php fr.php
Dockerfile
docker-compose.yml
README.md