Can we add the possibility of inline translation using Accept-Language header? #156
Open
1 task done
Labels
type:feature_request
Feature request
Is there an existing issue for this?
Describe the problem to be solved
The current translation (l10n) works fine but it bothers me that the l10n.js is added at the bottom of the page, async and deferred. My connection is not slow and I can see the page blinking
I would love to implement this, but I'm a newbie with go
Suggest a solution
I think a very simple solution would be:
On startup we read the translations, which are already in
l10n.js
, and store it in a hashOn
errorpage.go
we initialize the props as usual (props.Message = page.Message()
), after this we check the Accept-Header for the language codes, sort by weight and get the first that matches one of the available languages, if the language is not detected or isen
we just skip the translation, if different thanen
we call a function that just returns the value for the key message, just as the l10n already does. Then just for caching we add the lang-code to propsAdditional context
My pseudo code would be something like this:
The text was updated successfully, but these errors were encountered: