views:

354

answers:

5

I have been looking at a few options for enabling localization and internationalization of a dynamic php application. There appears to be a variety of tools available such as gettext and Yahoo's R3 and I am interested in hearing from both developers and translators about which tools are good to use and what functionality is important in easing the task of implementation and translation.

+1  A: 

We've been tinkering withZend_Translate, since we use the Zend Framework anyway. It's very well documented and so far extremly solid.

In the past, I've pretty much used my own home-grown solution mostly. Which involves language files with constants or variables which hold all text parts and are just echo'ed in the view/template later on.

As for gettext, in the past I've heard references about PHP's gettext implementation being faulty, but I can't really back that up nor do I have any references right now.

Till
+3  A: 

PHP gettext implementation works very smoothly. And po files with po edit and gettext are about as good a way as you can get to deal with localization bearing in mind that no solution of this kind can completely handle the complexities of the various languages. For example, the gettext method is very good on plural forms, but nothing I've seen can handle things like conjugation.

For more info see my post here: http://stackoverflow.com/questions/39562/how-do-you-build-a-multi-language-web-site#41379

reefnet_alex
+1  A: 

There are a number of useful extensions in pecl: http://pecl.php.net/packages.php?catpid=28&catname=Internationalization

In particular, you may want to check out php-intl, which provides most of the key i18n functions from International Components for Unicode (ICU)

A: 

Xataface can be used to quite easily internationalize an arbitrary PHP/MySQL application. It support translation of both your static text, and your database data. All you have to do is add a line or 2 of code to a couple of places in your application and it's good to go.

http://xataface.com/documentation/tutorial/internationalization-with-dataface-0.6

+1  A: 

the database driven solution to show the messages is not always the good one, I worked in a site with more than 15 languages and translations were an issue.

so our design was:

  • translation app in php-mysql (translation access, etc.)
  • then translations are written in php arrrays
  • these arrays are also cached in APC to speed up the site.

so to localize different languages you only need do an include

like

<?php
include('lang/en.php');
include('lang/en_us.php'); // this file overrides few keys from the last one.
?>
Gabriel Sosa
double include seems to be a very smart idea!
Mike