Giter Club home page Giter Club logo

Comments (5)

froschdesign avatar froschdesign commented on July 26, 2024 1

@bkilinc

  1. You can use zendframework/zend-i18n-resources and the messages of all validators are already translated. (you may already have seen this)
  2. The AbstractValidator uses the text of the message, because if no translation exists than the message itself is used as fallback by the translator.
  3. You can create a pull request to contribute your proposal. But keep in mind that every change of the current behaviour means a BC break and the need of a new major version. Because nobody knows if a user already has dateInvalid or dateFalseFormat in his translation files which can then lead to incorrect translations.

from zend-validator.

Ocramius avatar Ocramius commented on July 26, 2024

@bkilinc can you maybe outline a test case for what you'd like the behavior to be?

from zend-validator.

bkilinc avatar bkilinc commented on July 26, 2024

I want to use something like this as a translator object. This is not possible, because AbstractValidator does not pass messageKey to translator object.

class myTranslator implements \Zend\Validator\Translator\TranslatorInterface
{
    protected $translations = [
        'dateInvalid'     => "Invalid type given. String, integer, array or DateTime expected",
        'dateInvalidDate'=> "The input does not appear to be a valid date",
        'dateFalseFormat' => "The input does not fit the date format '%format%'",
    ];

    public function translate($messageKey, $textDomain = 'default', $locale = null)
    {
        return $this->translations[$messageKey];
    }
}

from zend-validator.

bkilinc avatar bkilinc commented on July 26, 2024

Thanks, I was creating my custom validator. I would like to use messageKey for looking up translations, because default message may also change. when I saw
"protected function translateMessage($messageKey, $message)"
in "AbstractValidator", I thought I could do this. But now I understand that, it is not possible with current implementation.

from zend-validator.

weierophinney avatar weierophinney commented on July 26, 2024

This repository has been closed and moved to laminas/laminas-validator; a new issue has been opened at laminas/laminas-validator#1.

from zend-validator.

Related Issues (20)

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.