
Building a Multi-Language Site Without WPML: Our Custom Translation Stack
WPML costs $99/year. Polylang adds complexity. We built a custom translation system for two sites and it took less time than configuring either plugin. Here's how we handle 5 languages across DropThe and Facil.guide , a senior-friendly tech guide site launching in English, Spanish, French, Portuguese, and Italian. Architecture Three components. That's it. 1. URL Router Language detection from URL prefix: function dt_detect_language () { $uri = $_SERVER [ 'REQUEST_URI' ]; $prefixes = [ 'es' , 'fr' , 'pt' , 'it' ]; foreach ( $prefixes as $lang ) { if ( strpos ( $uri , "/ $lang /" ) === 0 ) return $lang ; } return 'en' ; // default } No database lookups. No cookies. No session state. Pure URL-based, which is exactly what Google wants for hreflang. 2. String Translation Function function __ ( $key , $lang = null ) { static $strings = []; $lang = $lang ?: dt_detect_language (); if ( ! isset ( $strings [ $lang ])) { $file = "/translations/ { $lang } .json" ; $strings [ $lang ] = file_exists
Continue reading on Dev.to Tutorial
Opens in a new tab



