How can I localize strings in cakePhp? I havent had any success with the online documentation. Thanks for any help.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are a couple of steps:
.pofiles for that language__()or__d()helper methodsHere’s an excerpt from one of my projects:
That snippet will set the language. All you need to do is provide the appropriate
.pofiles in the/app/locale/eng/LC_MESSAGES/directory. The CakePHP book provides sufficient information on this, I think.If you choose to use just one
.pofile, you’ll wrap your strings with the__()helper. I chose multiple.pofiles in order to avoid one massive file, so I used the__d()helper so that I could specify which domain (domain == name of the.pofile without the.poextension).UPDATE
I should add that you’ll need to use the
Translatebehavior to help you with database content that requires translation.