[nycphp-talk] Reading in strings from text file
David Krings
ramons at gmx.net
Mon Dec 10 17:07:15 EST 2007
John Campbell wrote:
>
> I highly recommend *not* doing it this way.
I am not surprised about this advice.
> 1) A session is the worst place to put the data because there is a
> different session file for each user. If you do want to do this, use
> a singleton pattern to access the array bundle.
I have no idea what a singleton pattern is.
> 3) Performance will be suboptimal.
That is what I considered to be the case and thus the reason why I asked.
> 2) Plurals, and translation re-ordering will be nearly impossible.
> 4) You will have to build your own tools for the translators.
> 5) Dealing with merges is going to be a pain.
> 6) You need to give the translators context for the strings.
I did not mention this before, but I have collected first hand experience in
i18n as both project manager and translator. Context for strings would have
been the application. I expect from any translator who is halfways serious
about a useful translation that he/she knows the app. Most of the time
translators do not as the companies hiring them don't want to pay for their
time spent in training. In my case, the app is gosh darn easy and there will
be CSH available.
> 7) Your system will have to deal with non-translated strings appropriately.
That is something that I would have considered if going ahead with my now
shattered plan.
> The good news is that all of these problems associated with i18n, have
> been solved. Gettext is the GNU standard and you get all of the tools
> for free (PoEdit for translators, msgmerge, binary encoding for
> performance) Gettext seems confusing and complicated at first, but
> you will appreciate it once you have tried something else.
>
> I know this doesn't answer your question about the performance, but it
> is unlikely that you will be able to successfully internationalize an
> application with 1000+ strings if your plan is to use array bundles.
>
> Just so you understand the difficulty of i18n'ing an app, consider this string:
> "Your Visa card with last four digits 1234 expires on Dec 15, 2007".
>
> In another language, it may need to be written as:
> "On 15:Drb:2007, expires, last 4 digits 1234, is your Visa"
I know about the difficulties in dealing with i18n. I never heard about
gettext and I will take a look at it. I just hope it uses a string text file
format that allows for using spellcheckers, but maybe that is included in PoEdit?
> Also, your application code will become unreadable if you use array
> bundles. Consider:
> echo $translation_bundle[ERR::CC_EXP];
> vs the gettext way:
> echo _("Your credit card has expired");
>
> I find the latter much more readable.
I'll take a look at it and then cast my verdict. I worked with too many
developers who implemented i18n in a way that made quick and easy translations
close to impossible, for example by insisting on using alphanumeric monikers
as keys. That totally sucked.
Thanks for the tip and saving me from spending time on something stupid. :)
David
More information about the talk
mailing list