Cakephp i18n gets local translations

I have to say that cakephp (using version 1.3, because the project was built with that) has a weird i18n concept. I've successfully translated static strings, but dynamic ... cake ideas for how to manage multilingual content seem a little bit, let's say to me. I set up an i18n table (split it into multiple tables later when I got it working) and attached the translation behavior to the desired models. So far so good that in the add-actions I added a select box containing the locales (en_us, de_de ...) so that the user can decide which one to keep. Bevore keeping records I did$this->Modelname->locale = $locale;

to indicate the model in which the language is used. The entry is saved successfully, buttttt, so problems arise: - I have an index action with a lot of entries, I want the user to be able to have different translations for each element (say: one element is translated into English (by us) and German , the other is translated into English (us), Italian and French, how can I give the user the ability to edit / delete single translations? - I used internal actions $this->Modelname->bindTranslation(...)

where I needed to get the locale names (what translations are there) so that the user can decide which of these change, is there another, more elegant way to do this? Also, when I do this:$this->Modelname->bindTranslation(...);

and then instead of find () method I use paginate (), it doesn't return any translations ... = /

I hope someone understood my slightly complex text and can help me; -)

Thanks in advance!


source to share

1 answer

I have a solution for Cakephp2.0 that probably works with Cakephp1.3, also I've never tested it. You have to rename the material and edit some things, but it might work. In case: I recommend that you update Cakephp2.0 while you are in an early state of your project. 1.3 has been deprecated since Cakephp2.1 was finally released. I've gone through this update process about two or three times and it's a day of work, maybe two. In my case, the project is restarted from scratch. I really don't trust this updated shell, although it does do a great job.

Shortly speaking.

My method involves overwriting the existing TranslateBehavior, adding a new TranslationBehavior, helper and component.

Here's a zip with files.

Once I figure out how to use GIT correctly, I'll pull out its request. The ticket with files is already in: ;)

The usage is pretty simple. In the controller, you include a component and a helper. Models receive the "Translation and Translation" behavior. Translatio comes first because of the callback question. But the script will still throw an exception.

The component will find all languages ​​existing in the "Locale" folder itself and save them in the Configure class.

In the view, you use $ this-> Translation-> input ('Modelname.field') ;. The model name is important because I have not yet figured out the way to detect this automatically, because I am not sure if the FormHelper instance in my helper is the same as in the view. And I have a time leak. ^^

TranslationBehavior will check EACH! language fields based on the field name.

If you have questions: Ask ^^ Through me not very often, I will try to take a look at this question;)

Hello func0der



All Articles