title: Easy way to translate a website
body: <h1>Question</h1>
  
  <p>I have a fairly static website with just a few basic PHP usage. Now the customer would like to have this website translated. I <em>do</em> have a solution, but it's cumbersome and I was wondering how others are doing it and what is the standard (in frameworks, etc.).</p>
  
  <h1>My Way</h1>
  
  <p>My way (I have simplified it a bit for the sake of easier understanding): I generate a PHP array for each language from the database and store this array in a language file, like es.php for Spanish.</p>
  
  <p>I then translate a string in HTML using a tr function like this:
  <br/>Before:<code>&lt;h1&gt;Hello World&lt;/h1&gt;</code><br/>
  After: <code>&lt;h1&gt;&lt;?php echo tr('Hello World'); ?&gt;&lt;/h1&gt;</code> which gives <code>&lt;h1&gt;Hola Mundo&lt;/h1&gt;</code> for Spanish.<br/></p>
  
  <h1>The Problem</h1>
  
  <p>This is cumbersome and error prone. I have to go through each .php file and replace all the hardcoded strings with this PHP tag with echo.<br/>
  Is there a better way? How are others doing it? If needed, I can elaborate on my implementation.</p>