Tuesday, March 2, 2010

Re: Translating the autogenerates Labels in views?

On Mar 2, 10:47 am, mivogt-LU <c...@mivogt.net> wrote:
> hi there,
>
> I am looking for a solution to do some very basic translating in my
> project.
> DatabaseTables and all files are named in english within the capephp
> way.
>
> Now I want to have the labels of the input fields in i.e. German
> language.
> Is it possible to add a file where I just place the original and the
> translated names?
>
> Or will I have to change the code in the view.ctp files and add the
> label code in the input field syntax as additional array? (already
> testetd and worked but one big file for all translations would be
> better....)

Use .po files. See here:
http://book.cakephp.org/view/161/Internationalization-Localization

A big heads-up, though: when using the __() function for form labels,
pass true as the second param.

echo $form->input('YourModel.field', array('label' => __('some string,
true));

Use this same pattern anywhere that you need the translated string to
be returned, rather than echoed.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: