extract i18n validation messages in Cakephp 2 plugin - cakephp

I am developing a plugin in CakePHP 2.x, and I want to translate the error messages from the models.
I was reading the documentation, but its no clear about how extract exactly.
I changed the domain for my models with:
$validationDomain = 'validation_errors';
so cakephp made a validation_errors.pot file.
I have two folders, 'spa' and 'eng', with 'LC_MESSAGES' into them, and 'manager.po' file where I put the translations for my plugin (with the same name).
Where I have to make the .po file from validation_errors.pot? and how I have to name it?
Thanks!

Related

Whta if I don't use app/webroot/index.php

I know that the index.php requires many files like core,dispatch,bootstrap and so on.This time in my project,I directly use a html inseide which has a ,and
the href is "topath/app/houses/init"(created by myself).The question is that,how about the index.php and the files it requires?Should they be required actually?
Thank you very much.
yes index.php required those files to load cake api, and dispatcher api's.
if you need a plain html then you can use following structure
topath/app/index.html which contain anchor tag to redirect on your
specified app
topath/app/houses is an cakephp app that contains all your houses app
content
if you have multiple cakephp app then you can seperate cake api
keep cake api out side from app
mainapp/cake/ include all cakephp api lib
mainapp/houses/ include all houses app code
update mainapp/houses/app/webroot/index.php to load cake api from
mainapp/cake/
and so on......
hope it will help you

How to use correctly a CakePHP plugin

I've developed a bug tracker using CakePHP 2.4.4. I made this as a standalone cakephp app but now I wanna transfer it to a plugin, in order to reuse it in other projects.
As I already read at the docs (http://book.cakephp.org/2.0/en/plugins.html), I have followed the instructions from there and created the correct folder and files structure. This is what i've done so far: https://github.com/lubbleup/BugCake/tree/plugin
But now,when i try to use the plugin in a separate cakephp installation, I cannot understand how to make of the plugin and, for example, use it's controllers and functionality etc.
can anyone help me out here?
ps:this is my first time trying to create a cakephp plugin
Thank you in advance!
You have to load the plugins your parent app in APP/Config/bootstrap.php
CakePlugin::loadAll();
You do not need AppModel or AppController in your plugin. Your plugin has an own AppController/-Model named PluginNameAppController/PluginNameAppModel.
You can call your plugin at http://host/plugin_name/controller/action/[...]. In your case http://host/bug_cake/issues/view/1 for instance.
But you can also use custom routes in your plugin with plenty of options.
Hope that answers your question—if not, comment.

CakePHP Get translated data from the model

I am using cakephp 2.x to make one site multilingual and I am using the i18n extract and the TranslateBehavior Core Library.
The i18n works fine and the TranslateBehavior Core Library works fine when I try to save data. But when I want to read it I have to say to the controller the specific locale with:
$this->Home->locale = 'spa';
or
$this->Home->locale = 'eng';
Instead the core library makes it automatically by me. I have to specify all the times the locale? Or does exist something that do it automatically?
Thank you very much
There is a detailed article about i18n on Cakephp 1.3, I hope your 2.x will also work on this say theory so you can have a try with that http://codeatomic.com/developing-cakephp-multilingual-website/

cakephp for multiple static sites

I have successfully created a static website using cakephp to create the static html files using the console.
However, what I want to do now is have a console script that can create multiple websites from the same shared data, with each website using data that is unique to it, but sharing the db as a source.
So, how do I set up the app folder in relation to each website? Do I need a separate installation of cakephp for each site? Or can I have a shared App folder in cgi-bin or something like that?
Thanks
You can share the CakePHP core between multiple apps, however you will need a separate 'app' folder for each website (with the appropriate structure). See this question for more details. Essentially you will need to modify the index.php file in each app/webroot folder to point to the CakePHP core. I use this technique and it's much easier to maintain with only one core as opposed to a whole separate installation of Cake for each site.

Using plugin built-in translations in a CakePHP application

I am using a couple of plugins in a CakePHP application that come with predefined translations in their Locale directories.
However, despite I have set the language setting, messages from these plugins are not being translated.
First question: can CakePHP retrieve those plugin translations by default or do I have to create my own translation files every time I use a plugin in a different application?
If CakePHP should retrieve the translations in plugin's Locale directory, is there something else I have to do besides setting Configure::write('Config.language', 'spa')?
Thank you!!
UPDATE: I am using CakePHP 2.1

Resources