469,582 Members | 2,244 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,582 developers. It's quick & easy.

Why php gettext is needed in real life?

http://hk2.php.net/manual/en/ref.gettext.php

I just wonder why those kind of translation/mapping can't be
implemented in using plain PHP array?

Howard
Jun 27 '08 #1
8 3209
howa wrote:
http://hk2.php.net/manual/en/ref.gettext.php

I just wonder why those kind of translation/mapping can't be
implemented in using plain PHP array?
None.

However, using gettext will allow you to use a large array of software for
easing the work of building translation tables. e.g. Kbabel, GTranslator,
poEdit.

In other words, professional translators will gave an easier time working
with a gettext-enabled program rather than a in-house translation solution.

Cheers,
--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

MSN:i_*************************@hotmail.com
Jabber:iv*********@jabber.org ; iv*********@kdetalk.net
Jun 27 '08 #2
Iván Sánchez Ortega wrote:
In other words, professional translators will gave an easier time
str_replace('gave','have');

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Vamos, hale, hale, que es gerundio! (Yola Berrocal)
Jun 27 '08 #3
howa wrote:
http://hk2.php.net/manual/en/ref.gettext.php

I just wonder why those kind of translation/mapping can't be
implemented in using plain PHP array?

Howard
First, gettext is faster that a php array

Sencondary, translators can use a gui programm for translation the
string (PoEdit, Eclipse Plugin).

But the main reason is: with gettext you can extract and refresh the
strings need translation out of the source code into your gettext
project file.

Joe
Jun 27 '08 #4
On 6$B7n(B4$BF|(B, $B2<8a(B2$B;~(B57$BJ,(B, Joe Scylla <joe.scy...@gmail.comwrote:
>
First, gettext is faster that a php array
I agree with points such as GUI tools, but is gettext faster?

PHP array can be cached into memory using APC/XCache and you can even
use them without any method call.

Howard
Jun 27 '08 #5
howa wrote:
On 6$B7n(B4$BF|(B, $B2<8a(B2$B;~(B57$BJ,(B, Joe Scylla <joe.scy...@gmail.comwrote:
>First, gettext is faster that a php array

I agree with points such as GUI tools, but is gettext faster?

PHP array can be cached into memory using APC/XCache and you can even
use them without any method call.

Howard
Well at least in my benchmarking it is (on Suse and Debian). Remember
that gettext caches loaded translation file in memory.

http://mel.melaxis.com/devblog/2006/...t-fast-enough/

It may depend on the gettext-implementation. There is a user posted in
the comments who had better performance with arrays under Windows.

Joe
Jun 27 '08 #6
On 6$B7n(B4$BF|(B, $B2<8a(B10$B;~(B09$BJ,(B, Joe Scylla <joe.scy...@gmail.comwrote:
Well at least in my benchmarking it is (on Suse and Debian). Remember
that gettext caches loaded translation file in memory.

http://mel.melaxis.com/devblog/2006/...php-localizati...
Look interesting.

But...
1. Do you use any kind of op-cache? E.g. eA or XCache (it might make a
differences of 50-100% for your array / pure php implementation)

2. If using APC, take care of codes such as the following, e.g.

require_once("languages/$lang.php");

it might not be cached.

3. require_once() is slow and might be the bottomneck, try require();
Howard.

Jun 27 '08 #7
howa wrote:
On 6$B7n(B4$BF|(B, $B2<8a(B10$B;~(B09$BJ,(B, Joe Scylla <joe.scy...@gmail.comwrote:
>Well at least in my benchmarking it is (on Suse and Debian). Remember
that gettext caches loaded translation file in memory.

http://mel.melaxis.com/devblog/2006/...php-localizati...

Look interesting.

But...
1. Do you use any kind of op-cache? E.g. eA or XCache (it might make a
differences of 50-100% for your array / pure php implementation)

2. If using APC, take care of codes such as the following, e.g.

require_once("languages/$lang.php");

it might not be cached.

3. require_once() is slow and might be the bottomneck, try require();
Howard.
I have tested gettext against php array implementation with Zend
Optimizer and eAccelerator installed and used object caches with
different storage engines (eAccelerator shared memory api, MySQL, MySQL
memory tables and tmpfs).

Pure gettext was always faster in my benchmarks (Suse 10.x/Debian
3.1/4.0), but is was *more important* for me that gettext is not
remarkable slower.

Pure php may be faster on some systems (Windows, different Apache, other
version of gettext) but in the major cases it won't be much slower. And
gettext

Joe
Jun 27 '08 #8
On Jun 5, 12:06 am, Joe Scylla <joe.scy...@gmail.comwrote:
>
Pure php may be faster on some systems (Windows, different Apache, other
version of gettext) but in the major cases it won't be much slower. And
gettext

Joe
I might suspect the bottomneck is due to the require_once (5000
require_once in a test), you might use xdebug to profile it if you
like.

Personally, I don't think method call is faster then array hashing.
Anyway, just my $0.05 (due to inflation)

Howard
Jun 27 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Daniel CAUSSE | last post: by
1 post views Thread by Dave Patton | last post: by
reply views Thread by abcd | last post: by
13 posts views Thread by cantabile | last post: by
3 posts views Thread by Grard Talbot | last post: by
4 posts views Thread by Mike P2 | last post: by
1 post views Thread by James T. Dennis | last post: by
6 posts views Thread by =?iso-8859-1?B?QW5kcuk=?= | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.