src/Zicht/Bundle/FrameworkExtraBundle/Controller/TranslationController.php
public function translateAction(Request $request, $locale, $domain = null)
    {
        $queryIds = $request->query->get('id');

        if ($domain) {
            if ($queryIds) {
                if (!is_array($queryIds)) {
                    $queryIds = [$queryIds];
                }

                $translations = $this->getTranslationsForDomainAndIds($locale, $domain, $queryIds);
            } else {
                $translations = $this->getTranslationsForDomain($locale, $domain);
            }
        } else {
            $translations = $this->getTranslationsForLocale($locale);
        }

        return new JsonResponse(
            $translations
        );
    }
public function translateAction(Request $request, $locale, $domain = null)
    {
        $queryIds = $request->query->get('id');

        if ($domain) {
            if ($queryIds) {
                if (!is_array($queryIds)) {
                    $queryIds = [$queryIds];
                }

                $translations = $this->getTranslationsForDomainAndIds($locale, $domain, $queryIds);
            } else {
                $translations = $this->getTranslationsForDomain($locale, $domain);
            }
        } else {
            $translations = $this->getTranslationsForLocale($locale);
        }

        return new JsonResponse(
            $translations
        );
    }
public function translateAction ( Request $ request , $ locale , $ domain = null ) { $ queryIds = $ request -> query -> get ( 'id' ) ; if ( $ domain ) { if ( $ queryIds ) { if ( ! is_array ( $ queryIds ) ) { $ queryIds = [ $ queryIds ] ; } $ translations = $ this -> getTranslationsForDomainAndIds ( $ locale , $ domain , $ queryIds ) ; } else { $ translations = $ this -> getTranslationsForDomain ( $ locale , $ domain ) ; } } else { $ translations = $ this -> getTranslationsForLocale ( $ locale ) ; } return new JsonResponse ( $ translations ) ; }
Wrapper for the translator-service

The id's and domain are optional. When withheld the controller will return all the translations for the locale and (optional) the domain
If id's are passed, they should be passed in the query-parameters, ie:

One id:
/translate/nl/messages?id=eticket.can_not_be_rendered_no_barcode

Multiple id's:
/translate/nl/messages?id[]=eticket.can_not_be_rendered_no_barcode&id[]=eticket.col1&id[]=eticket.copy_warning&id[]=form_label.form.email

@param Request $request
@param string $locale
@param string $domain
@return JsonResponse

@Route("/translate/{locale}/{domain}")
@Route("/translate/{locale}")
Wrapper for the translator - service