Re: gettext vs custom ways



..oO(shimmyshack)

On May 11, 1:02 am, Mike P2 <sumguyovrt...@xxxxxxxxx> 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
.



Relevant Pages

  • Re: GNU gettext
    ... The gettext documentation explains how the keys work. ... translation files, or that you'd need to write a small utility to help ... gettext was desined for plain C, the keys are C strings ... as a developer you have no clue what every language ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: language support
    ... You need to use gettext. ... Mark translatable strings in your source using _and N_ ... and manually translate with gettextwhere required. ... This is documented in the GNU gettext and GNU libc manuals. ...
    (comp.os.linux.development.apps)
  • Re: Addition: gettext
    ... translatable strings and translations. ... translations without any messing with resource files. ... One of the best features of gettext is the merging of new and changed ... I don't know how resource files work, ...
    (comp.lang.cpp)
  • Re: Multiple languages form
    ... Unlike VB where you can set up different language strings in a resource file ... and use LoadResString to get a string based on the local language settings ... > But VbScript Editor don't save multiple language strings. ...
    (microsoft.public.outlook.program_forms)
  • gettext vs custom ways
    ... Does anyone here have experience with PHP gettext functions? ... than serializing the language strings into language files and ... each page request and then use the strings kind of like phpBB does ... encode every string before sending it to the template engine. ...
    (comp.lang.php)

Loading