|
Posted by Michael Fesser on 05/11/07 09:52
..oO(shimmyshack)
>On May 11, 1:02 am, Mike P2 <sumguyovrt...@gmail.com> wrote:
>
>> Hi. Does anyone here have experience with PHP gettext functions? I'd
>> like to know how they work better. Also, is gettext more efficient
>> than serializing the language strings into language files and
>> unserializing them at each request?
I've used gettext a while ago, but can't really compare it with other
methods. All I can say is that it worked well and made it quite easy to
extract all translatable strings from the source code to create the
message files.
>I personally don't use _() because of that, although it doesn look
>great, I just use the phpmyadmin way (which has a good lang detect
>script) - as you suggest,
>[...]
>
>---de---
>#allow string to be inserted where appropriate
>$_LANG['user_already_exists'] = 'Der Benutzer %s existiert bereits!';
>
>and so on
>all files have names such as en_GB-utf-8.php
>and are properly encoded - I just stick to utf8.
gettext also works very well with UTF-8, you can even use it in the
message IDs.
>as you say _('heres something that needs to be translated') seems
>strange to me as well because although it certainly makes the code
>readable, so do well chosen variable names.
Given the example above that would be something like
printf($_LANG['user_already_exists'], $userName);
or
printf(_('Der Benutzer %s existiert bereits!'), $userName);
I prefer the second one. For me it's easier to read and easier to modify
if necessary.
Micha
[Back to original message]
|