From our weekly sponsor: Design every part of your website with the brand new Divi Theme Builder. Try it for free.
Here’s an easy way to translate your web site using PHP. The idea is to have several files for each language you want to provide. Each one of these files have the name of the ISO code and the txt extension. For this demo I only use the german language as an alternative to the default language of the site – english. The content of these files are the words / sentences with their translation in the form:
The PHP class provided will parse this file, create an array which maps both word and it’s translation pair. You just need to insert the following in your php code :
$translate = new Translator($outputlanguage);//$outputlanguage: ISO code (example: de,en,...) --> these are the names of each file $translate->__('word to translate');
<h2><?php $translate->__('Registration'); ?></h2>
and in your de.txt file we would have: