NYCPHP Meetup

NYPHP.org

[nycphp-talk] Reading in strings from text file

csnyder chsnyder at gmail.com
Mon Dec 10 17:17:24 EST 2007


On Dec 10, 2007 12:49 PM, David Krings <ramons at gmx.net> wrote:
> Hi!
>
> I am about to start on a module for i18n and wonder if anyone has experience
> on how long it takes to read in let's say 1,000 strings of about 30 characters
> on average from a text file that has numeric keys, with those keys  becoming
> the key of an array that in the end is to be stored in $_SESSION. Is there a
> better place than $_SESSION to hold this? What I really want to prevent is to
> have each script that generates text output have to read in its own strings as
> this adds management needs to make sure the right strings are picked up.
> Anyone knows how well this would scale with 10,000 or 100,000 strings? Sure, I
> could try it out, but asking NYPHP is way faster.
>
> David

+1 for gettext. It's extremely fast, very capable, and there is the
weight of many other projects behind it.

In the simplest case, you simply wrap all of your output strings in _(
) and keep going. When you're ready to translate, the command line
scripts will scan your code for all those instances, and then generate
plain text files that you can give to translators to work on.

That said, it is not the easiest thing to learn how to make it all
work. And the downside to the lightning fast speed is that you have to
restart Apache whenever you change one of the .po files. In practice
this isn't such a big deal.

Anyway, feel free to ask specific questions here when/if you start using it.

-- 
Chris Snyder
http://chxo.com/



More information about the talk mailing list