You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I found this really interesting and I looked at the code to see how I can translate it but I found that it's done using docstring and I don't know if there is a way to make them translatable.
Do you know if it is possible to do it in the way that it's written?
Thanks,
The text was updated successfully, but these errors were encountered:
No, the current structure doesn't really lend itself to easily support translations. Of course, we could simple wrap the whole docstring around some gettext-function but that would end up being quite a mess.
A cleaner approach would perhaps be taking the module-path of each function and use that as key to look up the description text somewhere else.
That issue set aside, there is also the question of how to serve the translations. My first idea here would be to generate something like en.html, fr.html, de.html files and add a dropdown to all of them where the user can switch the language.
The big problem is still where to store the translations. @ulope do you have any ideas?
I think serving the translated versions shouldn't be a big problem. From a quick google it seems to be relatively easy to get nginx to serve different static files based on the Accept-Language header. Adding a dropdown that sets an override cookie for the cases where the default fails should also not be that difficult.
As @zerok said it's much less clear where and how the translations should be stored. Since the traditional translation tools (gettext, etc.) are usually geared towards translating (relatively) short UI elements instead of actual page content they aren't very well suited for our site.
We could use some custom system that loads the translations from files (JSON, YAML or even Python come to mind) during generation of the output. That seems a bit cumbersome to me however.
Maybe the best solution would be to drop this "tests-are-content" scheme entirely and just store the whole content in some kind of structured file. We still could have tests for that via pytest's pytest_generate_tests hook.
Hi, I found this really interesting and I looked at the code to see how I can translate it but I found that it's done using docstring and I don't know if there is a way to make them translatable.
Do you know if it is possible to do it in the way that it's written?
Thanks,
The text was updated successfully, but these errors were encountered: