liberapay.com
liberapay.com copied to clipboard
Widget i18n is skewed by bad HTTP caching
CloudFlare only respects Accept-Encoding
in the Vary
header (What headers can I vary the cache on?), we use Accept-Language
.
An alternative solution to using Cloudflare Workers could be to send all the translations to the browser and use JavaScript to pick one of them based on NavigatorLanguage. It would be cheaper but less efficient.
Edit: this alternative requires JavaScript on the client, whereas a Cloudflare Worker can generate an SVG.
This is kinda annoying, maybe it should indeed be done client-side.
that doesn't look right next to the paypal widget. This is with java script enabled. would it not be better to define the default language right in the widget string?
Firefox preferred language is english, the website language is the important part though, if that is english, the button should be english, if it is french then the button should be french (regardless of browser preference, or geo location)
Translating the website using the google translate widget i get:
Somehow I feel that the LibreDonate button should be more of a marketing tool and the librepay or donate button text is sortof a trademark, best not to change it at all (similar to paypal).
I've fixed this issue by adding a (no-)caching rule to Cloudflare. This solution doesn't scale, but the current rate of requests for widgets seems to be low enough for the webapp and database to handle without any caching.