-
-
Save jamiebuilds/89dba0f6f94c185b5625f22c3bb95461 to your computer and use it in GitHub Desktop.
Screenreader locale bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { contextBridge, ipcRenderer } = require('electron') | |
contextBridge.exposeInMainWorld('electronContext', { | |
getLocale: () => ipcRenderer.invoke('getLocale') | |
}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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