I'm working with the Tower library for i18n and l10n in my web application.
I have the problem of having to localize "just-in-time", i.e with an unanticipated dictionary, and in particular unanticipated supported locales.
I receive HTTP request, from which I can extract the accepted locales in preference order, e.g :
[:de :en-UK :en :fr-FR :fr]
On the other hand, I have to localize from micro-dictionaries which are fetched from a database, in the form :
{:fr "En Français"
:en "In English"
:en-Uk "In English from UK"}
What I would like to do in my program is to find the best matching translations from these 2 elements (in the example, it is :en-UK
; note that I may not know in advance that :de
is unavailable).
I haven't found a way to do that with the Tower library (and I'd like to avoid reinventing the wheel).
Does anyone know how I might proceed?
Thanks in advance!