Search code examples
symfonylocale

Locale keyword translation in English


I read the tutorial and translation is working properly good. My problem is to handle keywords. Here you can see an example:

http://symfony.com/doc/current/book/translation.html#creating-translations

I can run the keyword symfony.is.great -> J'aime Symfony2, when my language is French. But how can I translate symfony.is.great -> Symfony2 is great? Translate it to English. I miss that part in the docs or I don't really get it! My default language is Englisch!

I do have an messages.fr.xliff and messages.en.xliff.

Part of my messages.en.xliff:

<?xml version="1.0" encoding="UTF-8" ?>
    <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
        <file source-language="en" datatype="plaintext" original="file.ext">
            <trans-unit id="3">
                <source>symfony2.is.great</source>
                <target>Symfony is great</target>
            </trans-unit>
...

Solution

  • The section of the doc you shared just show you the different ways you can define your translation keys (real messages or keywords).

    Take a look at this part of the doc. For the translation process to work fine you've to use the same key in your two message catalog files. The right translation is then loaded according to the _locale stored on the session.

    Also, each time you create a new translation resource be sure to clear your cache so that the new file is taken into account.