Giter Site home page Giter Site logo

localized's Introduction

CakePHP Localized plugin

Build Status Coverage Status Latest Stable Version Total Downloads Software License

This plugin contains various localized validation classes for specific countries.

Requirements

This branch is for use with CakePHP 5.x. See version map for details.

Demo

See sandbox.dereuromark.de/sandbox/localized for live sandbox demo on localized validation.

Installation

You can install this plugin into your CakePHP application using composer.

The recommended way to install composer packages is:

composer require cakephp/localized

Load your plugin using

bin/cake plugin load Cake/Localized

or by manually adding 'Cake/Localized' to the array in your app's config/plugins.php.

Model validation

Localized validation classes can be used for validating model fields.

namespace App\Model\Table;

use Cake\ORM\Table;
use Cake\Localized\Validation\FrValidation;
use Cake\Validation\Validator;

class PostsTable extends Table
{
    public function validationDefault(Validator $validator): Validator
    {
        $validator->setProvider('fr', FrValidation::class);
        $validator->add('phoneField', 'myCustomRuleNameForPhone', [
            'rule' => 'phone',
            'provider' => 'fr',
        ]);
    }
}

For further information on validation rules see the CakePHP documentation on validation

PO files

This plugin also houses translations for the client-facing translated strings in the core (the cake domain). to use these files link or copy them into their expected location: resources/locales/<locale>/cake.po

Contributing to Localized

If you find that your country is not part of the Localized plugin, please fork the project on GitHub. Once you have forked the project you can commit your validator class (and any test cases). As soon as you have pushed your changes back to GitHub you can send a pull request and your changes will be reviewed and merged in, or feedback will be given.

Validation methods

There are a few methods that are common to all classes, defined through the interface "ValidationInterface":

  • phone() to check a phone number
  • postal() to check a postal code
  • personId() to check a country specific person ID

Please try to fit your validation rules in that naming scheme. Apart from that you can also define further validation methods in your implementing class, of course.

Issues with Localized

If you have issues with Localized, you can report them at github.com/cakephp/localized/issues.

localized's People

Contributors

ad7six avatar admad avatar annuh avatar antograssiot avatar arhell avatar atkrad avatar benfarhat avatar busgurlu avatar cake17 avatar cauancabral avatar cdburgess avatar ceeram avatar cewi avatar chinpei215 avatar dependabot[bot] avatar dereuromark avatar dmromanov avatar elboletaire avatar fiblan avatar gildonei avatar jrbasso avatar lenzcom avatar lorenzo avatar makallio85 avatar markstory avatar othercorey avatar predominant avatar renan avatar skie avatar slywalker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

localized's Issues

Question - How should I implement the personId for my country?

I would like to implement the personId for Spain, but I've serious doubts about it.

Here in Spain we have at least 7 different personId with different calculations each one:

  • DNI/NIF: The usual NIF.
  • NIF K: for younger than 14.
  • NIF L: for foreign people younger than 14 that are in Spain for less than 6 months.
  • NIE X/Y/Z: The NIF for foreign people.
  • NIF M: for foreign people that do not have a NIE.

You can see all the Spanish NIF types on wikipedia: https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal

That's referring to person ids (NIF), for companies we use other letters.

The question is... should I implement all of them? If so, I guess I should create a separate method for every different calculation, am I right?

I currently have this (ugly, would refactor obviously) method for testing NIFs on my CakePHP 1.3 apps:

public function validateNif($check, $options = array())
{
    $nif_codes = 'TRWAGMYFPDXBNJZSQVHLCKE';

    $nif = strtoupper(array_pop($check));

    if (isset($options['allowEmpty']) && !$options['allowEmpty'] && empty($nif)) {
        return false;
    }

    $matches = array();

    if (preg_match('/^([0-9]+)([A-Z]{1})$/', $nif, $matches))
    {
        // DNIs
        array_shift($matches);
        list($num, $letter) = $matches;

        return ($letter == $nif_codes[$num % 23]);
    }
    elseif (preg_match('/^[XYZ]([0-9]+)([A-Z]{1})$/', $nif, $matches))
    {
        // NIEs
        array_shift($matches);
        list($num, $letter) = $matches;
        $num = strtr(substr($nif, 0, 1), 'XYZ', '012') . $num;

        return ($letter == $nif_codes[$num % 23]);
    }
    elseif (preg_match('/^[KLM]{1}/', $nif))
    {
        // NIFs especials
        // Vegeu https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal
        $sum = (string)$this->getCifSum($nif);
        $n = 10 - substr($sum, -1);

        return ($nif[strlen($nif)-1] == chr($n + 64));
    }

    return false;
}

Note that it does not cover all the cases... and it's very huge right now, but is a good sample of how much calculations do we have to ensure a personId is valid.

I can't install via composer, it conflicts with Chronos

I tried to install cakephp/localized using the following commands:

composer require cakephp/localized

composer.phar require --update-with-dependencies "cakephp/localized"

And gives the following error:

$ composer.phar require --update-with-dependencies -W "cakephp/localized"
Using version ^3.5 for cakephp/localized
./composer.json has been updated
Running composer update cakephp/localized --with-all-dependencies
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - cakephp/localized[3.5.0, ..., 3.5.2] require cakephp/cakephp ^3.5 -> satisfiable by cakephp/cakephp[3.5.0, ..., 3.10.0].
    - cakephp/cakephp[3.5.0, ..., 3.5.14] require cakephp/chronos ^1.0.0 -> found cakephp/chronos[1.0.0, ..., 1.3.0] but it conflicts with your root composer.json require (^2).
    - cakephp/cakephp[3.5.15, ..., 3.10.0] require cakephp/chronos ^1.0.1 -> found cakephp/chronos[1.0.1, ..., 1.3.0] but it conflicts with your root composer.json require (^2).
    - Root composer.json requires cakephp/localized ^3.5 -> satisfiable by cakephp/localized[3.5.0, 3.5.1, 3.5.2].


Installation failed, reverting ./composer.json and ./composer.lock to their original content.

If I manually enter cakephp/localized no in composer.json file and give composer.update command, it conflicts with cakephp/database:

$ composer update
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires selective/array-reader ^1.1 -> satisfiable by selective/array-reader[1.1.0].
    - selective/array-reader 1.1.0 requires cakephp/chronos ^2 -> found cakephp/chronos[2.0.0, ..., 2.2.0] but it conflicts with your root composer.json require (^1).
  Problem 2
    - Root composer.json requires cakephp/localized 3.5.2 -> satisfiable by cakephp/localized[3.5.2].
    - Conclusion: don't install cakephp/database 4.0.2 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.0.3 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.0.4 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.0.5 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.0.6 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.0.7 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.0.8 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.0.9 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.1.0 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.1.1 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.1.2 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.1.3 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.1.4 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.1.5 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.1.6 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.1.7 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.2.0 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.2.1 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.2.2 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.2.3 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.2.4 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.2.5 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.2.6 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.2.7 (conflict analysis result)
    - Conclusion: don't install cakephp/database 4.0.1 (conflict analysis result)
    - cakephp/localized 3.5.2 requires cakephp/cakephp ^3.5 -> satisfiable by cakephp/cakephp[3.5.0, ..., 3.10.0].
    - Only one of these can be installed: cakephp/cakephp[3.5.0, ..., 3.10.0], cakephp/database[4.0.0, ..., 4.2.7]. cakephp/cakephp replaces cakephp/database and thus cannot coexist with it.
    - Root composer.json requires cakephp/database ^4 -> satisfiable by cakephp/database[4.0.0, ..., 4.2.7].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

The following dependencies are in my composer.json file:

"cakephp/chronos": "^2",
"cakephp/database": "^4",
"cakephp/validation": "^4.2",

How can I fix this error?

Cake po files for Cakephp 3

It seems like cake.po files inside Locale folder, can't be used with Cakephp 3.
Do you plan to create another repository or branch for Cakephp 3's cake.po files ?

Why don't you allow intl phone validation?

Hello,

According to the fr validation code, you gave up international validation and so entering phone number like +331234567890 or 0033 1234567890 fails.
Isn't it possible to allow a + sign (and so 2 more numbers) in front of a phone number?

And in fact, I suppose that allowing + is available in all languages no?

Cleaner API

As shown in https://sandbox.dereuromark.de/sandbox/localized

There are several methods that are either kind of duplicates with a different name or contain underscore instead of camelBacked.
We should clean up the API here, deprecate one in favor of the correct spelling if possible.

All methods that shouldnt be visible, should be marked protected.

Ukraine Person ID (VAT) deep validation

Person ID have certain format. It encode birth date, gender and have checksum. So it can be validated more deeply than just /^\d{10}$/ with some calculations.
I think i can do pull request for it. Does it make sense?

[question] Update template?

Should we update the cake.pot template when we commit translation updates? Or maybe it should be updated in a separate issue/PR?

I've recently created #125 and #126 and I'm not sure if I should update the template too.

In fact, maybe we could remove it, don't we?

French: incorrect dateAgoInWords translation

hi,
In english, very far date are writtens generated on 12/23/2012
The dateAgoInWords() method generate on %s string. This is here https://github.com/cakephp/cakephp/blob/3653648f88a14f526665f6b0d0b156ea868b4e88/src/I18n/RelativeTimeFormatter.php#L410

The on %s is translated as sur %s. on is well translated by sur in french, but not in date case :/
The right translation, is le %s (the %s in english)

There is a possibility to distinguish that ?
Thanks

New release

Do you think it's worth doing a new release of the package, as master is now 15 commits ahead of the last tag.

This is mostly selfish as I need to use some of the new stuff in a project, and would ideally like to avoid a dev-master in my Composer file.

Thanks! 📦

The plugin class `Cake\Localized\Plugin` cannot be found.

Hello,

im trying to use this plugin for checking phone number on my web site but i have some problems as u see in the title i got error "The plugin class Cake\Localized\Plugin cannot be found." but i followed the instructions like it should be but i can't find any solutions for this i use Cakephp 3.6, the latest version of cakephp also when i load the plugin by command line it write in Application.php at the function bootstrap this line $this->addPlugin('Cake/Localized'); but the plugin is located in vendors folder not anymore in plugin folder so i don't know if the instructions should be updated as i see in others website there are some difference with how to add a plugin in cakephp, i don't know if i was clear cuz i have a bad level in english sorry but i would be really happy if u can give me some tips about how to fix this error.

Incorrect french postcode test

I looked at the postcode test validation and I think there is a bad test:

Why

$this->assertTrue(FrValidation::postal('01001'));

and

$this->assertFalse(FrValidation::postal('01000')); // I think it's correct

But I think

$this->assertFalse(FrValidation::postal(' 1000')); // should assert false

error when downloading with composer

composer: latest version
localized: "cakephp/localized": "2.4.*"
cake: latest 3.x

my autoload (nothing changed here):
"autoload": {
"psr-4": {
"App": "src"
}
}

on composer update I'm getting the following error:
[RuntimeException]
Unable to get primary namespace for package cakephp/localized.
Ensure you have added proper 'autoload' section to your plugin's config as
stated in README on https://github.com/cakephp/plugin-installer

thanks, dan

Localized plugin and CakePHP3.x

So @markstory and I discussed the future of this plugin regarding the next major version of the framework.

So basically:

Validation::phone($number, 'Localized.De')

We have 3 methods defined by the interface:

  • phone()
  • postal()
  • personId()

That need to work this way, for sure.

Any comments regarding this approach?

Installing issue

If you install the plugin with:

composer require cakephp/localized

and you load it with:

bin/cake plugin load Localized

Then you add in bootstrap.php: Plugin::load('Localized');
But it must be: Plugin::load('Cake/Localized');

I don't know if this is a particular issue or no, but possibly can help to someone
Regards

15-digit Brazilian CNPJ

Created by César de Tassis Filho, 21st Mar 2013. (originally Lighthouse ticket #18):


New Brazilian CNPJs are 15 digits instead of 14 (that is already implemented) and I don't know at what point the 14-digit validation is compatible.
The validation needs to be updated to support those new CNPJs.
There are already some implementations saying they support 15-digit CNPJ (like this one for jQuery: http://blog.shiguenori.com/2009/05/29/validar-cpf-cnpj-com-jquery-validate/), but I did not found any official website telling how it should be validated.

Synchronizing with cakephp versions

Hello there,

I have started some days ago with french translations of cakephp 2.4.1, which have been merged in cakephp-fr/locale-2. . I've been suggested to submit them here too, but Localized plugin is tailored for version 2.1 and the templates (.pot files) have changed notably since. I think a mix of versions would lead to a mess.

Also, it would make sense if translations for several versions of cakephp were kept available and updatable.

After considering several angles of the problem, I have started working on my own fork,
which would include translations for several releases of cakephp in all languages.
Support for a new release is created semi-automatically with dedicated tools,
described here

There is still a lot to do but I'd like to know if you think it is worthwhile, and if you would help me.

Thanks in advance,
RockyRoad

Polish 14-digit REGON

Hello,

Currently, In a repo have a function regon, but this function only checks numbers that consist of 9 digits. In special cases, a government agency may assign 14 digit number.
Example: 96998880588057

I think that should be a function that checks the second case.

More:
http://www.krs-online.com.pl/sprawdzanie_regon.html
https://pl.wikipedia.org/wiki/REGON
I would like to emphatize sentence:

Ponieważ jeden ze współczynników wagowych wynosi zero to weryfikacja „długiego” REGON-u wymaga weryfikacji 9 cyfr z wagami jak dla 9-cyfrowego numeru, a następnie weryfikacji długiego REGON-u z innymi wagami.

because not every project checks this condition (ex. https://github.com/marioosh/common_numbers )

Thanks in advance.

Some translations are missing for Cakephp 5.x

I've copied resources/locales/fr_FR/cake.po of this plugin in my app folder in order to translate messages of cake core (as I did for previous version 4.x).

But unlike version 4.x where everything seemed to be translated, it seems that for version 5.x some translations are missing.

For example : email validation message "the provided value must be an e-mail address" stays in english.

Aren't .po files out of date ?

Add localized slugging

I propose

src/Inflector/LocalizedInflector.php
src/Inflector/InflectorDe.php

etc as e.g. normal inflection (default cake core) of Any-Latin; Latin-ASCII; [\u0080-\u7fff] remove is invalid for German for example.
Refs https://stackoverflow.com/questions/50412085/how-to-make-textslug-convert-german-umlauts-properly

Here one would expect de-ASCII; Any-Latin; Latin-ASCII; [\u0080-\u7fff] remove.
We cannot hardcode this into bootstrap however for a multi-language site, as this will kill the others, e.g.
Turkish Söğütlü wouldn't be Sogutlu anymore, but Soeguetlue.

So for this we should add localized ones per language - and invoke that based on that language then inside the business logic.
Is there a better way to avoid too many classes?
Maybe with some simple config instead?

Could not find validation handler error

I just cloned this git for my project and inside BdValidation class I just added the following code

public static function mobile($check) {
        return false;
    }

but when I am writing rule in my model. then when I am submitting form it is showing an error that says Warning (512): Could not find validation handler mobile for mobile [CORE/Cake/Model/Validator/CakeValidationRule.php, line 283]

Referenced files

  1. Controller/PostsController.php
class PostsController extends AppController
{
    function create()
    {
        $this->Post->create();
        $this->Post->save($this->request->data);
    }
}
  1. Model/Post.php
<?php
App::uses('BdValidation', 'Localized.Validation');

class Post extends AppModel {

    public $validate = array(
        'mobile' => array(
            'valid' => array(
                'rule' => array('mobile', null, 'bd'),
                'message' => 'Must be valid BD postal code'
            )
        )
    );
}
  1. View/Posts/create.ctp
<?php echo $this->Form->create('Posts');?>
<?php echo $this->Form->input('Post.posts');?>
<?php echo $this->Form->input('Post.mobile');?>
<?php echo $this->Form->submit();?>

But when I am gonna use other class like MxValidation then it's working! So what's wrong with BdValidation class?

Ukrainian language code uk

I just realized that CakePHP itself (cakephp/localized) uses 'ua' for Ukrainian and it is impossible to use both plugin's and cakephp/localized localization in case localization for plugin correctly uses uk for Ukrainian because it's impossible to set more than one defaultLocale.

Code uk for Ukrainian language is correct because all this locale stuff goes back to
gettext that relies to ISO 639 two-letter language code

My suggestion is rename resources/locales/ua to resources/locales/uk but keep UaValidation.php as refers to Ukraine as country which code is UA according to gettext appendix ISO 3166 two-letter country code and also keep for a while UkValidation.php linked to GbValidation.php as @deprecated which is current state. And UaValidation.php is still usable as far as defaultLocale indiferrent and used manually

$validator->setProvider('ua', 'Cake\Localized\Validation\UaValidation');

It's also possible to use resources/locales/uk_UA to minimize disambiguation with that Uk->Gb part. uk_UA is correct either and will work for both defaultLocale setting uk or uk_UA

Can't install localized plugin on CakePHP 4.0.3

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?

Installation using composer fails in CakePhp 4

$ composer require cakephp/localized
Using version ^3.5 for cakephp/localized
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- cakephp/localized 3.5.2 requires cakephp/cakephp ^3.5 -> satisfiable by cakephp/cakephp[3.5.0, 3.5.0-RC1, 3.5.0-RC2, 3.5.1, 3.5.10, 3.5.11, 3.5.12, 3.5.13, 3.5.14, 3.5.15, 3.5.16, 3.5.17, 3.5.18, 3.5.2, 3.5.3, 3.5.4, 3.5.5, 3.5.6, 3.5.7, 3.5.8, 3.5.9, 3.6.0, 3.6.0-RC1, 3.6.0-RC2, 3.6.0-beta1, 3.6.0-beta2, 3.6.0-beta3, 3.6.1, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15, 3.6.2, 3.6.3, 3.6.4, 3.6.5, 3.6.6, 3.6.7, 3.6.8, 3.6.9, 3.7.0, 3.7.0-RC1, 3.7.0-RC2, 3.7.0-RC3, 3.7.0-beta1, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.8.0, 3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.12, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.9.0-RC1, 3.x-dev] but these conflict with your requirements or minimum-stability.
- cakephp/localized 3.5.1 requires cakephp/cakephp ^3.5 -> satisfiable by cakephp/cakephp[3.5.0, 3.5.0-RC1, 3.5.0-RC2, 3.5.1, 3.5.10, 3.5.11, 3.5.12, 3.5.13, 3.5.14, 3.5.15, 3.5.16, 3.5.17, 3.5.18, 3.5.2, 3.5.3, 3.5.4, 3.5.5, 3.5.6, 3.5.7, 3.5.8, 3.5.9, 3.6.0, 3.6.0-RC1, 3.6.0-RC2, 3.6.0-beta1, 3.6.0-beta2, 3.6.0-beta3, 3.6.1, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15, 3.6.2, 3.6.3, 3.6.4, 3.6.5, 3.6.6, 3.6.7, 3.6.8, 3.6.9, 3.7.0, 3.7.0-RC1, 3.7.0-RC2, 3.7.0-RC3, 3.7.0-beta1, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.8.0, 3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.12, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.9.0-RC1, 3.x-dev] but these conflict with your requirements or minimum-stability.
- cakephp/localized 3.5.0 requires cakephp/cakephp ^3.5 -> satisfiable by cakephp/cakephp[3.5.0, 3.5.0-RC1, 3.5.0-RC2, 3.5.1, 3.5.10, 3.5.11, 3.5.12, 3.5.13, 3.5.14, 3.5.15, 3.5.16, 3.5.17, 3.5.18, 3.5.2, 3.5.3, 3.5.4, 3.5.5, 3.5.6, 3.5.7, 3.5.8, 3.5.9, 3.6.0, 3.6.0-RC1, 3.6.0-RC2, 3.6.0-beta1, 3.6.0-beta2, 3.6.0-beta3, 3.6.1, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15, 3.6.2, 3.6.3, 3.6.4, 3.6.5, 3.6.6, 3.6.7, 3.6.8, 3.6.9, 3.7.0, 3.7.0-RC1, 3.7.0-RC2, 3.7.0-RC3, 3.7.0-beta1, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.8.0, 3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.12, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.9.0-RC1, 3.x-dev] but these conflict with your requirements or minimum-stability.
- Installation request for cakephp/localized ^3.5 -> satisfiable by cakephp/localized[3.5.0, 3.5.1, 3.5.2].

Installation failed, reverting ./composer.json to its original content.

add genitive cases

Created by euromark, 3rd Dec 2010. (originally Lighthouse ticket #13):


here for german for example - genitive of names and other nouns:

/**
 * correct genitive form of a noun
 * `@param` string $word
 * `@param` bool $enforceApostrophe (only for personal names)
 * `@return` string $result
 * `@see` http://de.wikipedia.org/wiki/Genitiv
 * `@static`
 * 2010-08-25 ms
 */
function genitive($word, $enforceApostrophe = false) {
    $suffix = 's';
    $word   = trim($word);

    if (in_array(mb_substr($word, -1), array('s', 'ß', 'x', 'z'))) {
        // Hans’ Tante
        $suffix = '’';

    } elseif (mb_substr($word, -2) == 'ce') {
        // Alice’ Tante
        $suffix = '’';

    } elseif ($enforceApostrophe) {
        // // According to the new spelling "Peter's" etc is allowed again if you want to make it clear that it is the basic form of a personal name.
        $suffix = '’'.'s';
    }

    return $word . $suffix;
}

Can I add a localized method?

I have put the validation in the App \ Model \ validation path.
I have added the static method to the interface and method in the corresponding xxvalidation.

But when I try to use it:

$validator = new Validator();
        // add the provider to the validator
        $validator->provider('es', 'App\Model\Validation');
        // use the provider in a field validation rule
        $validator->add('username', 'username', [
            'rule' => 'username',
            'provider' => 'es',
			'message' => 'El nombre de usuario introducido no es válido'
        ])
		->isEmptyAllowed('username',false);
		;
        return $validator;

Give me the error Unable to call method "username" in "is" provider for field "username".
If I modify the original vendor / cakephp / localized class if that works correctly.
what can i do?

Cake doesn't load plugin

Hi. I use CakePHP 2.6, but when I try to use your plugin, Cake doesn't load it.
I put the line in bootstrap.php

CakePlugin::load('Localized');

and before I unzipped the Localized folder (naming it 'Localized') into the app/Plugin directory.

But when I look into the DebugKit Toolbar, looking for the loaded plugins, the Localized plugin doesn't appear! Can you help me?

Include a localized 'date' and 'number' rules to ValidationInterface

I know we can pass format to date method in Validation lib, but I think we can help newcomers adding all of widely used data types (like date and decimals) with different formats in differents countrys to that lib.

So, would do you think be nice to provide a 'date' and 'number' validation rule with default normalized format?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.