[TYPO3-mvc] translate error messages

Franz Koch typo3.RemoveForMessage at elements-net.de
Tue Feb 15 15:54:16 CET 2011


Hey Peter,

> which approach are us using/ is avilable to translate errors?
>
> I have used something like:
>
> <f:translate
> key="error.{error.propertyName}.{errorDetail.code}">{errorDetail.message}</f:translate>
>
>
> which I didn't feel to comfortable with in the end, as it lead to dozens
> of similar translation strings.
>
> Maybe I'll just head for error.{error.propertyName} and make all failed
> validations into one message.
>
> Anything else? what are u using?

I'm using a mixture of a custom viewHelper where I map various error 
codes to a generic type like 'required' or 'invalid' and property 
specific translations.
In the viewHelper I also check for various translation keys 
automatically - first property and code specific and then step by step 
fall back to a generic message if no property specific one is available 
in the language files:

errors.[propertyName].[errorCode] = Code specific message
errors.[propertyName].[invalid/required] = generalized message
errors.[errorCode] = Code specific, generalized message
errors.[invalid/required] = fallback

AFAIK I posted my viewHelper or at least some code snippets already on 
this list on a similar topic, but it's not a big deal to do anyway.


I think it'll be good if validation errors would also transport a 
generic errorType like "invalid" and "required" so that localization 
could be eased up a bit. Having to find out all error codes and 
categorize them in a custom viewHelper is not that nice. How do you guys 
think about this?

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list