Skip to content

Instantly share code, notes, and snippets.

@webdevilopers
Created February 7, 2016 13:24
Show Gist options
  • Save webdevilopers/5bdc808e175425ee23ab to your computer and use it in GitHub Desktop.
Save webdevilopers/5bdc808e175425ee23ab to your computer and use it in GitHub Desktop.
Translate validation default messages in Symfony2
<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="file.ext">
<body>
<trans-unit id="1">
<source>Dieser Wert sollte nicht leer sein.</source>
<target>Bitte ausfüllen</target>
</trans-unit>
<trans-unit id="2">
<source>Dieser Wert sollte nicht null sein.</source>
<target>Bitte ausfüllen</target>
</trans-unit>
<trans-unit id="22">
<source>This value should not be blank</source>
<target>Bitte ausfüllen</target>
</trans-unit>
<trans-unit id="23">
<source>This value should not be null</source>
<target>Bitte ausfüllen</target>
</trans-unit>
</body>
</file>
</xliff>
Dieser Wert sollte nicht leer sein.: Bitte ausfüllen
Dieser Wert sollte nicht null sein.: Bitte ausfüllen
Dieser Wert sollte nicht leer sein: Bitte ausfüllen
Dieser Wert sollte nicht null sein: Bitte ausfüllen
This value should not be blank: Bitte ausfüllen
This value should not be null: Bitte ausfüllen
@webdevilopers
Copy link
Author

Following this answer by @cheesemacfly:
http://stackoverflow.com/questions/14984112/overwrite-the-notblank-constraint-message-on-symfony2-1-globally

All files are located under app/Resources/translations. Cache cleared. No change.

Any idea?

Twitter discussion:
https://twitter.com/webdevilopers/status/696324723588911104

@webdevilopers
Copy link
Author

Must have copied a xlf file by @chobi that was actually "missing the point" too:
https://github.com/chobie/Symfony2VagrantSandbox/blob/master/www/Symfony/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/translations/validators.de.xliff#L94

<?xml version="1.0"?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
    <file source-language="en" datatype="plaintext" original="file.ext">
        <body>
            <trans-unit id="22">
                <source>This value should not be blank.</source>
                <target>Bitte ausfüllen</target>
            </trans-unit>
            <trans-unit id="23">
                <source>This value should not be null.</source>
                <target>Bitte ausfüllen</target>
            </trans-unit>
        </body>
    </file>
</xliff>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment