# Static-PHP i18n at OVH scale

> An i18n stack that works on cheap shared hosting where mod_rewrite QSA breaks: URL path parsing in PHP + a JS link-rewriter at boot. No frameworks, no build step.

- **Source:** https://amplifiedcreations.com/lab/static-php-i18n-ovh
- **Publisher:** amplified creations (https://amplifiedcreations.com/)
- **Published:** 2026-05-15
- **Updated:** 2026-05-16
- **Language:** en
- **Stack:** PHP, JavaScript, Apache, Cockpit CMS
- **Source code:** https://github.com/PTthe13/amplifiedlabs/tree/main/static-php-i18n-ovh

---

Most i18n stacks assume a real framework. We needed PT and ES versions of a static-ish PHP site on OVH shared hosting, where mod_rewrite's QSA flag sometimes drops query strings before PHP sees them.

Two pieces:

1. **Server side:** a `lang()` helper that reads `$_GET['lang']` first, falls back to a regex against `$_SERVER['REQUEST_URI']` for `/pt/` or `/es/`. Belt and braces — works whether the rewrite forwards QS or not.
2. **Client side:** a 12-line JS at boot that detects the URL locale and rewrites every internal `<a href="/...">` to prepend `/pt/` or `/es/`. Same locale persists through every internal click.

No React, no Next, no router library. Three locales (EN, PT, ES) sitting on a Cockpit headless CMS that holds the translated strings. Sitemap.php emits all three URL variants with hreflang alternates.

Boring stack. Ships fast. Works on hosting that costs €4/month.

---

Published by amplified creations, an independent technology studio in Leiria & Lisboa, Portugal. Contact: info@amplifiedcreations.com · More: https://amplifiedcreations.com/llms.txt
