cakephp/localized

Can't install localized plugin on CakePHP 4.0.3

Closed this issue · 3 comments

Hello,
after creating a new project (4.0.3) and installing authentication and authorization plugins, I'm not being able to install the localization plugin.
When I run:
composer require cakephp/localized
I get the following problem:
Problem 1 - Can only install one of: cakephp/cakephp[4.0.3, 3.x-dev]. - Can only install one of: cakephp/cakephp[3.x-dev, 4.0.3]. - Can only install one of: cakephp/cakephp[3.x-dev, 4.0.3]. - cakephp/localized 3.5.0 requires cakephp/cakephp ^3.5 -> satisfiable by cakephp/cakephp[3.x-dev]. - Installation request for cakephp/localized ^3.5 -> satisfiable by cakephp/localized[3.5.0]. - Installation request for cakephp/cakephp (locked at 4.0.3, required as ^4.0) -> satisfiable by cakephp/cakephp[4.0.3].
Any idea about what I'm doing wrong?

Hello MiquelRoan,

I am an absolute newbie with cake but I think the error you get is due to the requirements of the composer.json file in the Localized plugin folder.

In any case, i have managed to manually install the Localized plugin in the Plugins folder and it seems to work correctly in Cake 4.0.3.

The problem / doubt I have is how can I dynamically pass the provider.

In the documentation example the provider is loaded by passing the language directly:

$validator->setProvider('fr', 'Localized\Validation\FrValidation');

    `$validator->add('postalcode', 'myCustomRuleNameForPhone', [
        'rule' => 'phone',
        'provider' => 'fr',
        'message' => __('Bad phone number')
    ]);`

But, how can I write it so that it looks something like that:

$validator->setProvider($my_current_language, $path_to_my_current_language_validation);

    `$validator->add('postalcode', 'myCustomRuleNameForPhone', [
       'rule' => 'phone',
        'provider' => $my_current_language,
        'message' => __('Bad phone number')
    ]);`

Hope someone can help us.

Thanks

no compatible version for cake 4, but will be soon