views:

41

answers:

1

The CakePHP book has a section on Internationalization & Localization. Bascially what it says is Cake will generate a pot file and we have to create a .po for different language file from the pot file.

My problem is I want the user to be able to edit these localized text so instead of storing the localized text in the .po file I want to store them in the database.

So how can I store the localized text in the database?

+1  A: 

There's a Behavior for that.

Personally I find the TranslateBehavior to be rather inflexible though, so I usually just go with a separate table connected to the main model via a belongsTo relationship which contains all the translations. I then pick the one to display in the View.

deceze
That sounds strange. The Translate Bahavior is for the model data. So I have to create a model to store all the labels that I use in my views. If I do it that way then I won't be able to use something like <?php __('Posts') ?> this anymore, right?
Sunny
Yes, if you want to store user editable translations in the database, you need to use a model. At that point, your labels are not simply "translatable view elements", they're data like any other data in the database. `__()` will only look up translations in .pot files, so yes, you need to use something else.
deceze