I'm developing a CakePHP plugin which should support multiple languages. The procedure for i18n localisation is documented here, but plugins aren't explicitly covered. Is this structure below supposed to work? Because it isn't for me at the moment, but I might be overlooking something.
/myapp/
/plugins/
/myplugin/
/locale/
default.pot
/nld/
/LC_MESSAGES/
default.mo
default.po
And calling the translation in the plugin controller like so:
Configure::write('Config.language', 'nld');
In my plugin views the localisation function is formatted like this:
__('MyPluginName', 'MyDefaultString')
Some of the posts on CakePHP and the localisation of plugins mention that all locales should go in to /myapp/locale/
, instead of the plugin directory, but wouldn't that defy the purpose of the modular plugin structure? The entries I've read are from 2008 (this one for example), so I hope this isn't the case anymore.
Could anybody provide me with some more details on localising a Cake plugin, perhaps even a small step by step tutorial?
Take a look at Plugin development tips and tricks article:
Localization for plugins is handled well and you can use it simply by giving a plugin name for your po or mo files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With