I am developing a multilingual site. I use array to save translations in one file which I include it inside settings.php.
//Example of english
$LANG['welcome']="Welcome";
$LANG['status']="Status";
I am wondering about two things:
- How would be the best option to print those arrays?
a)
Echo all html and inside html I use
echo "
<body>
<div>
<p>{$LANG['welcome']}</p>
</div>
";
b)
Close php and write html and inside html I open and close php for each time
<div><p><?php echo $LANG['welcome']; ?></p></div>
Each one has own downsides. Option a) spends extra resources to print html. Option b) spends extra resources to close and open php each time (could means that single script needs to open and close php even 30 times per script). Is that bad or is the ammount of resources spend for this negligible?
Also how do you translate words inside javascript? Somebody gave me idea to use
<script src="javascript.js.php" type="text/javascript" />
and
<?php
header("Content-type: text/javascript");
?>
// Javascript down here
for those 3 javascript files where I need translations.
Is this method ok?
Thank you!