Reputation: 3885
I would like to add translation to my site to all sorts of languages. I thought of defining chunks of code in different language files, Is that possible to create seperate files for translation in something like this manner ? :
the generic file:
// index.php
// say $_SESSION['lang'] = rtlLANG;
<?php include($_SESSION['lang'].".php");?>
<html>
<body>
<?php MAIN_WELCOME_MESSAGE; ?>
</body>
</html>
// some rtlLANG.php
define("MAIN_WELCOME_MESSAGE","
echo '<table style="direction:ltr;">';
echo 'welcome rtl language readers';
");
// some ltrLANG.php
define("MAIN_WELCOME_MESSAGE","
echo '<table style="direction:rtl;">';
echo 'welcome rtl language readers';
");
is it possible to somehow define these chunks of code ? (I know that not as it is at least) How can I implement different ways to layout my content for each language otherwise ?
Upvotes: 0
Views: 83
Reputation: 5290
there are many ways for implementing multilang support. here's my suggestion:
from my experience with html/css it's best to create 2 versions of the design - rtl and ltr. if you use MVC you could set a dir for the views (or templates).
you should have a list of languages, and for each you need to say whether it's ltr or rtl.
now for the actual translation: in your views/templates or html code/error and notice messages you can load the actual text. you can either write your own code, or (i'd recommend) use gettext (http://www.gnu.org/s/gettext/)
Upvotes: 0
Reputation: 180065
Use the standard (cross language, too) library gettext. http://php.net/gettext
Upvotes: 2