TranslateParser API
This content is for v15. Switch to the latest version for up-to-date documentation.
The TranslateParser
is responsible for formatting the translated messages
and using parameters that are passed in.
Usually, you would not use the TranslateParser
directly. It’s called in the
background when a translation string is requested in your app.
It’s also most likely that you don’t have to create your own parser at all.
The default parser
The TranslateParser
service has 2 methods which might sometimes be useful:
interpolate
Interpolates a string to replace parameters or calls the interpolation function with the parameters.
Example:
Returns This is a banana!
Example:
Returns This is a banana!
getValue
Gets a value from an object by composed key. The .
is interpreted as sub-object:
Example:
Returns value
.
Custom parser
A TranslateParser
implements this interface - you can create your
own parser and plug in into the TranslateModule
using
the config.