I've created a simple dynamic content app with firebase following this tutorial: https://firebase.google.com/docs/hosting/functions e.g.:
const functions = require('firebase-functions');
exports.bigben = functions.https.onRequest((req, res) => {
const hours = (new Date().getHours() % 12) + 1 // London is UTC + 1hr;
res.status(200).send(`<!doctype html>
<head>
<title>Time</title>
</head>
<body>
${'BONG '.repeat(hours)}
</body>
</html>`);
});
My question is how do I apply i18n to this dynamic content, so I can return a different html response depending on the locale of the request. I read the i18n documentation in firebase but it only suggests that it is possible with static content using hosting: https://firebase.google.com/docs/hosting/i18n-rewrites
I need it to be done inside the cloud functions, so I believe I would need a way to get the locale information inside the function itself, does anyone have any idea on how to do it or any different approaches for this?