Quick tip:

When have a code like this:

{% raw %}{% trans %}prefix.{{ varname }}{% endtrans %}{% endraw %}

And receive this error:

Twig_Error_Syntax: A message inside a trans tag must be a simple text

You can use the following piece of code as workaround.

{% raw %}{{ ("prefix." ~ varname)|trans }}{% endraw %}

PS: maybe this is not the best way to go.