Skip to content

Instantly share code, notes, and snippets.

@jamiebuilds
Created May 9, 2024 21:59
Show Gist options
  • Save jamiebuilds/89dba0f6f94c185b5625f22c3bb95461 to your computer and use it in GitHub Desktop.
Save jamiebuilds/89dba0f6f94c185b5625f22c3bb95461 to your computer and use it in GitHub Desktop.
Screenreader locale bug
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'">
<link href="./styles.css" rel="stylesheet">
<title>Hallo Welt</title>
</head>
<body>
<button>Hallo Welt</button>
<script src="./renderer.js"></script>
</body>
</html>
const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('node:path')
function createWindow () {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
mainWindow.loadFile('index.html')
}
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})
ipcMain.handle("getLocale", () => {
return app.getLocale()
})
{
"name": "adhoc-diamond-sip-55l5p",
"productName": "adhoc-diamond-sip-55l5p",
"description": "My Electron application description",
"keywords": [],
"main": "./main.js",
"version": "1.0.0",
"author": "jamiebuilds",
"scripts": {
"start": "electron ."
},
"dependencies": {},
"devDependencies": {
"electron": "27.1.3"
}
}
const { contextBridge, ipcRenderer } = require('electron')
contextBridge.exposeInMainWorld('electronContext', {
getLocale: () => ipcRenderer.invoke('getLocale')
})
globalThis.electronContext.getLocale().then(locale => {
document.documentElement.lang = locale;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment