Language codecs, AKA translator module?
Cantido opened this issue · 0 comments
Is your feature request related to a problem? Please describe.
Liberator sets the :language
key in conn.assigns
after some content negotiation, but its work with languages ends there. There is no help provided as far as translations are concerned. Your handler would have to check conn.assigns[:language]
and branch from there, which is exactly what Liberator is designed to help avoid.
Describe the solution you'd like
Since it is content negotiation, I've considered continuing the pattern I set with encodings and media types, and to pass the result from the handlers into a translator function. My guess is that module would replace key names with localized versions, if you were dealing with maps.
Describe alternatives you've considered
Just not doing anything with languages and leaving the user on their own. That doesn't sound nice, and as mentioned earlier, the user would have to write code in a pattern that is antithetical to Liberator's philosophy.
Additional context
See at line 186 in Liberator.Evaluator
how we use the media type and encoding headers to automatically format and encode the body. Create a Translator
behavior, but since Liberator's default language is *
, don't implement the behavior. Or, alternatively, implement a no-op behavior similar to Liberator.MediaType.TextPlainCodec
for when the language is *
.
Help wanted
If you have an internationalized API, tell me about some of your challenges and how you overcame them. I'd like to be a little more informed on this subject.