An i18n stack that works on cheap shared hosting where Apache’s mod_rewrite [QSA] flag mysteriously drops query strings (yes, really — OVH).
Two functions: lang() and t(). lang() figures out the requested language by:
?lang= from the query string/pt/..., /es/...)t(key) reads a shared dictionary (ui-strings.php) and returns the right translation. Falls back to the EN string, then to the key itself.
On the client, a tiny i18n.js rewrites <a href="/foo"> to <a href="/pt/foo"> after page load when lang() === 'pt'. Keeps links sane without forcing PHP to generate them dynamically everywhere.
No frameworks. No build step. Works on any PHP 7.4+ host that has mb_* extensions enabled.
lang.php — server helpersui-strings.php — EN/PT/ES dict, one big arrayhttps://amplifiedcreations.com/lab/static-php-i18n-ovh