Abhoryo / APYJsFormValidationBundle

This bundle performs validations of a form in javascript. (i18n compatible and several javascript frameworks supported)
92 stars 23 forks source link

Can't get error message translations #51

Closed sunviwo closed 9 years ago

sunviwo commented 10 years ago

I followed the bundle's implementation step by step and it seems working perfectly, except I can't get error message translations when I change the user's locale. I created a validators.fr.yml file in the app/Resources/translations folder and put in it all my translations for fr locale. But messages are constantly in English. I check whether Bazinga loaded my translations and yes, it did. I looked to the html output in Google Chrome Development tools and there was a js link like this , containing all translations in this form: Translator.add("validators:valid.notblank", "Ce champ est n\u00e9cessaire"); But no matter how I do, I'm not getting this message in the page. Any help ?

Abhoryo commented 10 years ago

Check the getComputeMessage() function to see if the traduction is find (if (!Translator.has('{{ translation_group }}:'+key)) {) or if this is a problem of the BazingaExposeTranslation Bundle.

sunviwo commented 10 years ago

Here is the getComputeMessage() function:

function getComputeMessage(key, placeholders, number) {
        Translator.placeHolderPrefix = '{{ ';
        Translator.placeHolderSuffix = ' }}';
        // Default translations
        if (!Translator.has('validators:'+key)) {
            Translator.add('validators:'+key, key);
        }

        return Translator.get('validators:'+key, placeholders, number) ||
               Translator.get('validators:'+key, placeholders);
    }
Abhoryo commented 10 years ago

I know the function, I just ask you too debug this function with your case.