Conversation with #smarty at 2004-02-22 17:44:08 on chealer@irc.freenode.net (irc) (17:44:08) : The topic for #smarty is: Smarty 2.6.2 released! http://smarty.php.net/ || FORUM: http://www.phpinsider.com/smarty-forum/index.php || WIKI: http://smarty.incutio.com/ (17:44:22) chealer: hey people :) (17:44:28) Ci-Dev\away: "* fix all E_NOTICE warnings" (17:44:42) Ci-Dev\away: Ok, and thanks again. (17:45:29) chealer: I have something like an RFE (17:45:44) Ci-Dev\away: E? (17:45:45) chealer: it's a proposition I made to TikiWiki about a month ago on http://tikiwiki.org/I18nDev (17:45:50) Ci-Dev\away: Request for E...? (17:46:00) chealer: Request For Enhancement (17:46:07) Ci-Dev\away: kk (17:46:07) chealer: It's more an RFC actually (17:46:10) chealer: Comment :) (17:46:19) chealer: about one page of read (17:46:25) Ci-Dev\away: RFC abbrev is very common, so I knew that. (17:46:44) chealer: I thought this was more Smarty stuff than TikiWiki specific (17:47:06) chealer: so if someone has some minutes, take a look and tell me what you think about it (17:47:07) messju: Ci-Dev\away: i'll fix the notices in mailto (17:47:49) Ci-Dev\away: You're a developer? (17:48:05) chealer: hi messju (17:49:31) messju: yes (17:50:21) chealer: messju: are you Smarty's lead coder? (17:50:45) messju: no, that's monte ohrt (17:51:13) messju: i skimmed over the tiki-link you posted (17:52:25) messju: but i don't know much about the current implementation of i18n in tikiwiki (17:53:57) chealer: cool. It's about translations (17:54:06) chealer: we use {tr}string{/tr} (17:54:21) chealer: and we store strings and translated strings in a language.php (17:54:31) chealer: is that a standard Smarty procedure? (17:54:51) messju: i wouldn't call it "standard" but it's common, i think (17:55:22) messju: i see you have prefilter.tr *and* block.tr . that's new to me (17:57:24) chealer: hum, I don't know what this means. I guess I have poor Smarty knowledge to propose such things (17:57:52) messju: so, what's the RFE actually? (17:59:17) chealer: it's about replacing an English string as reference by a line number to look in the language.php (18:00:34) chealer: I think we have something like 3000 strings, and it's taking important PHP memory to handle (18:01:26) chealer: with line numbers we could only check the relevant lines (each page using a small part of all available translations) (18:02:03) bharat: chealer, have you considered using gettext? (18:02:50) chealer: hum, no...I was more asking expecting to be answered it's already done, and how :) (18:03:20) fc [~fc@adsl-64-170-118-179.dsl.snfc21.pacbell.net] entered the room. (18:03:52) bharat: let me rephrase. "it's already done using gettext, which is a very efficient and powerful localization system" (18:04:01) bharat: http://www.gnu.org/software/gettext/gettext.html (18:05:05) chealer: OK...but this needs an external software, doesn't it? (18:05:05) bharat: we use this in our project, if you want to see sample code (18:05:16) bharat: it requires that PHP is compiled with gettext support (18:05:26) chealer: and that's no standard? (18:05:37) bharat: it's pretty standard on non-us boxes (18:05:58) chealer: hum OK (18:06:01) bharat: it's not ubiquitous, though (18:06:20) messju: bharat: i know gettext is designed for stand-alone applications, do you have any real-live experience with it and php? (18:06:28) bharat: yep (18:06:34) bharat: Gallery uses it extensively (18:06:44) bharat: G2 uses it as a custom callback from Smarty templates (18:06:57) messju: ah, i see. (18:07:16) bharat: I evaluated several different localization options and decided upon gettext because it was the only one that could handle pluralization issues correctly (18:08:10) chealer: ah that's interesting (18:08:32) chealer: With a quick look it didn't seem to adress the performance issue though (18:08:36) bharat: the more common model of embedding strings into a PHP file and then calling printf/sprintf on them breaks pretty badly when you want to handle localized pluralization (18:08:42) chealer: using a text as input (18:09:04) SiliSurfing is now known as Silicate (18:09:04) bharat: gettext compiles its strings into a binary database format and does random access on the data (18:09:41) messju: bharat: it doesn't read the whole on each request? (18:09:57) messju: that's what i always feared, but never traced. (18:09:57) bharat: no. it actually caches the data in the httpd process (18:11:27) bharat: I believe that in order for the strings-in-php solution to match gettext for speed, you'd need to have a PHP precompiler (like PHPA) around (18:13:03) chealer: I don't understand what it caches in httpd (18:13:41) messju: chealer: it doesn't read all strings on each request. (18:21:20) chealer: ok, it seems good for this point. There are 3 other advantages I noted, do you know if it adresses them also? (18:23:13) bharat: Seems like you don't need #1, since you can keep the strings in English in the .tpl without the performance loss (18:23:22) bharat: If you don't need #1, you don't need #2 either (18:23:36) bharat: or #3. (18:24:05) bharat: in my project, I have a callback that does translation. So in my template file, you'd see something like this: (18:24:14) fc left the room (quit: Read error: 110 (Connection timed out)). (18:24:17) bharat: {g->text text="This is some text that will get localized"} (18:24:45) bharat: then I've got some simple scripts that extract all of that text into strings files, and then I run the gettext utilities on it. (18:25:14) bharat: The gettext utilities create language specific .po files for the localizers, who go through those files and perform the translation (18:25:23) bharat: then those .po files are compiled into .mo files which ship with the product (18:25:46) bharat: so the template files contain only english (or whatever primary language you want to use) and all the localizations live in their own language specific directories (18:26:42) bharat: Gallery 1 has about 35 locales translated this way (but it doesn't use Smarty). Gallery 2 has about 15 translated this way (18:26:59) bharat: (and G2 uses Smarty so it's a pretty comprehensive example) (18:27:07) messju_ [jeanette@pD9E56809.dip.t-dialin.net] entered the room. (18:27:46) messju left the room (quit: Nick collision from services.). (18:27:46) messju_ is now known as messju (18:32:03) chealer: ok, and when you fix an English typo do the translators have to retranslate their strings or is it fixed cautomatically? (18:32:36) chealer: by the way there were 4 advantages I listed, advantages is highlighted in the text (18:32:45) chealer: but I must go eat for some time now (18:33:19) messju: and i must go sleep (18:41:36) bharat: chealer: the translation is marked "fuzzy" and the translators can see exactly what changed and get an idea of whether or not they should fix it. there are some really good tools for manipulating .po files (18:41:40) bharat: night messju (19:13:17) chealer: sounds good bharat (19:14:17) chealer: does it support context (different translations depending on the meaning of the string)? (19:15:48) bharat: I don't think that it does (19:16:13) bharat: generally this has not been a problem for us, because we make each string express a unique concept (19:16:36) bharat: we're able to do this because gettext supports plurallization (19:17:19) bharat: if you use constants in PHP files, then you typically wind up having smaller strings because you're trying to juggle pluralization issues, and then you wind up having the problem where a specific string doesn't have enough context for you to translate it correctly (19:17:45) bharat: we still have that problem in some cases where we have to have small strings (like page titles, for example) but I don't have a solution for that (19:31:32) squeese left the room (quit: Read error: 110 (Connection timed out)). (19:58:25) chealer: thanks bharat