Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>1</strong> - Duplicating the entire site will force you to repeat every code touch-up into the 2 folders :-[</p> <p><strong>2</strong> - If you mean somenting like</p> <pre><code>&lt;?php if($lang=='en') { ?&gt; &lt;p&gt;English text&lt;/p&gt; &lt;? } else { ?&gt; &lt;p&gt;Text français&lt;/p&gt; &lt;? } ?&gt; </code></pre> <p>This solution is perfect to manage two languages in the same page.<br> But you still have duplicated tags.</p> <p><strong>3</strong> - Change only content it's really satisfaction.<br> Maybe proliferate of if statements can weigh down php compiling... I don't know.<br> Anyway document can be more concise with this approach:</p> <pre><code>&lt;?php function interpreter($buffer) { $pieces = explode('#', $buffer); if (isset($_GET['lang'])) $begin=$_GET['lang']; else $begin = 1; // 1 to display français, 2 to display english $tot = count($pieces); for ($i=$begin; $i&lt;$tot; $i+=3) { // remove one language unset($pieces[$i]); } foreach ($pieces as $value) { // recompose the text $output .= $value; } return $output; } ob_start("interpreter"); ?&gt; &lt;a href="?lang=#1#2#"&gt;#Français#English#&lt;/a&gt; &lt;p&gt;#English text#Texte français#.&lt;/p&gt; &lt;?php ob_end_flush() ?&gt; </code></pre> <p>The text between <code>ob_start</code> and <code>ob_end_flush</code> is parsed AFTER php compiling.<br> That means are affected strings coming eg. from echo statement, not inside &lt; ?php ?> tags.<br> Also content coming from php include IS affected.<br> But NOT external css or javascript.</p> <p>Keep attention delimiter <code>#</code> isn't a caracter yet used elsewhere.<br> Maybe you'll prefer to replace with <code>||</code> or <code>^^</code></p> <p>Of course in the future you can adapt this solution into 3 languages or more. But if you have to insert the "Third language translation#" in many lines of a big site, maybe the solution from MatW fits you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload