There are several ways to change locale, you can try all of them to find what works for you,
Use Args when launching
const browser = await puppeteer.launch({
headless: false,
args: ['--lang=bn-BD,bn']
});
Send the language as Header
await page.setExtraHTTPHeaders({
'Accept-Language': 'bn'
});
Forcefully set the language
// Set the language forcefully on javascript
await page.evaluateOnNewDocument(() => {
Object.defineProperty(navigator, "language", {
get: function() {
return "bn-BD";
}
});
Object.defineProperty(navigator, "languages", {
get: function() {
return ["bn-BD", "bn"];
}
});
});
For the sake of testing, I'll test this in multiple languages, including es
, and here is the result.
Google search:
BrowserLeaks:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…