RE: translating in different languages

From: Date: Mon, 05 Mar 2001 10:41:50 +0000
Subject: RE: translating in different languages
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-304@lists.php.net to get a copy of this message
Hi, See below for my comments. > -----Message d'origine----- > De : Roel Vanhout [mailto:roel@2e-systems.com] > Envoye : lundi 5 mars 2001 10:58 > A : smarty@lists.ispi.net > Objet : [smarty] RE: translating in different languages > > > On Mon, Mar 05, 2001 at 07:10:42AM +0100, Alain Fontaine wrote: > > Smarty is a template system, so I don't really see why it > should be able to > > handle translation as well. As with OOP, 'keep it simple' :). Anyway, > > I think that translations would be a natural thing to integrate into a > template system, in the end, translating is a display issue: you just > want your texts to show up in another language, without having to worry > about more. > Translating text is not really a display issue in my eyes. Let's put it this way: text belongs more to the 'content' layer of the site than to the 'presentation' layer of the site. > > there's no problem at all with using stphp and smarty together, for > > Stphp doesn't look as convenient to me. It's ok for sites with a few > pages, but putting > > eval (ST ("TheThreeMusketeers", "\$string", "en")); > echo "<p><b>$string</b>"; > > in templates will not make it look better, and make the job of template > editors harder. You're right, using stphp that way will break the concept of templates, and that's definitely not the way to do it. But look at it this way, for instance: A smarty template would contain the {ErrorMessage} placeholder, like this: -- <HTML> <BODY> <h1>{ErrorMessage}</h1> </BODY> </HTML> -- The PHP code could look like this: -- eval (ST ("ErrorMessage", "\$string", $languageID)); $mySmarty->Assign("ErrorMessage",$string); $mySmarty->Display("template.tpl"); -- Voila! Isn't this easy ? $languageID would be a variable stored in the user's session: "fr" or "en" or "de", and so on (I've done it that way at least). > [cut] > of string substitutions. Also, with stphp and gettext you are limited to > storing the translations in files, while it would in some places be > easier to use a database. stphp does support DBM files, which offer excellent speed for this kind of things. I've used stphp on a site with 4 languages and over 4000 strings, and it just flies. As for the reason to use a database, I don't really see why? You will never do anything else on the string table than SELECT string FROM table WHERE language=fr for instance. I don't see the need of a database for that kind of operation. Performance certainly is NOT a reason, because at the very base, your db tables are also stored as files on disk (most of the time, anyway). > > > instance. Or using several template files (file_en.tpl, file_fr.tpl, > > file_de.tpl) for different languages. Or am I missing the point here ? > > Uhm, yes, if you suggest this, you are missing the point :-) Let's say I > translate my templates in 10 languages (which is what I need it for, and > this number of languages will likely increase in the future). Now I want > to add a paragraph between the header and the start of the actual text > on the page. If I follow your suggestion, I would have to change 10 > templates. You're right, using several files is missing the point. I don't know what bug bite me the moment I wrote that :) I think this is a very interesting discussion, and I'm waiting for your comments ;).

« previous php.smarty.general (#304) next »