Search code examples
cakephpcakephp-1.3translate

Cakephp website with English and Arabic support for the same database


Im building a website in CakePHP 1.3. My requirement is to have a website with arabic and english support. I want that if a user is entering the information in arabic so when the english user sees the same information it should be in english and vice versa.

As far as localing the labels ive done that using po files. Its pretty straight forward. But for the database im using the Cakephp's built-in Translate Behaviour. But it again doesn't translate anything and creates another copy of the data with the current locale that is in use.

Please help me in which direction i should move.

I want to know the best practices that should be followed for this kind of scenario. May be translating db values is not the best solution and should save the values as in whatever language they are coming.

Any help and suggestions would be highly appreciated.


Solution

  • It isn't actually possible to have CakePHP automatically translate data that is entered.

    The Translate Behavior allows you to enter the same content in multiple languages and then retrieve the appropriate language from the database, based on the language that you currently have set in your config. It doesn't actually translate anything for you.

    Theoretically, you could add a function to the Model::beforeSave() callback that would submit the Arabic text to a service like Google Translate and then save both Arabic and English versions to their appropriate tables, but the results won't necessarily be very good. As @deceze said in his comment to your question, machine translation is a hard problem.