Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to localise a CakePHP plugin?

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?

like image 308
mensch Avatar asked Nov 13 '22 21:11

mensch


1 Answers

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.

like image 172
bancer Avatar answered Dec 11 '22 02:12

bancer