Phantom81 Posted June 27, 2008 Share Posted June 27, 2008 I was wondering what is the best thing to do when we develop multi-language web application. In the past I use DB to store my language data. So at each page loading, the page call the DB and retrive all language string for this page. But I also see in other application (like osCommerce) the use of files (french.php, english.php, ...) where a bunch of variable are set in the file. This two method work, so now I would like to argue about which one is better and why. Quote Link to comment Share on other sites More sharing options...
keeB Posted June 27, 2008 Share Posted June 27, 2008 I know in Java, localization usually comes in 'properties' files. Here's a prototype in PHP: Template <p> There was an error ${my.error.string} </p> errors.en_us.properties my.error.string=The command ${opname} is not recognized. Please try again. operation.unavailable.error=The command ${opname} is temporarily unavailable. Please try later. errors.sp_mx.properties my.error.string=Desconocido Operacion ${opname}. operation.unavailable.error=Operacion ${opname} indisponible. Render <?php $user = UserDao::getUser($_SESSION['username']); // populate the user model object try { $a = Localization::Load($user->getLocale()) //load the proper localization file } catch (LocaleNotFoundException) { $a = Localization::Load(Localization.DEFAULT); } $p = new Template("mytemplate.tpl"); $p->render($a); ?> Quote Link to comment Share on other sites More sharing options...
Phantom81 Posted June 28, 2008 Author Share Posted June 28, 2008 I have no problem to program one way or the other. I was looking for the best pratice. Person who use multi-language application store string in file or in DB? -File is easy to edit -DB who load only string for a page use less memory than load all string for all pages like a file Quote Link to comment Share on other sites More sharing options...
keeB Posted June 28, 2008 Share Posted June 28, 2008 Did I not share with you the best practice I am aware of? Quote Link to comment Share on other sites More sharing options...
Phantom81 Posted June 28, 2008 Author Share Posted June 28, 2008 Did I not share with you the best practice I am aware of? Yes, thank you. But I would like to have some explaination and arguments. You method use one big file or multiple small files? In .net they use localization file too. One for each page, I don't like this pratice because the data is in multiple files and for change data or add a language, you have to edit all files. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.