Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
Switch language from Angular12 menu in Electron

I have an Angular 12 app with two languages (spanish and english). In index page I have a login screen with Toolbar-menu with language selecction.

I have used i18n as way to internazionalice the app. When I build the angular app the menu to switch between languages works fine. The results language-app are 'dist/es' and 'dist/en'

The component.html code:

<mat-menu #idiomas="matMenu">
    <a mat-menu-item i18n href="/es">Español</a>
    <a mat-menu-item i18n href="/en">Inglés</a>
</mat-menu>

The main.js to inizialice Electron:

const { app, BrowserWindow } = require('electron')

const url = require("url");
const path = require("path");

function createWindow () {

    //Obtenemos el idioma del usuario//get user locale
    const language = app.getLocale();


    const win = new BrowserWindow({
        webPreferences: {
            nodeIntegration: true
        }
    })

    win.loadFile(__dirname+'/dist/'+language+'/index.html')
}

app.whenReady().then(createWindow)

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') {
        app.quit()
    }
})

app.on('activate', () => {
    if (BrowserWindow.getAllWindows().length === 0) {
        createWindow()
    }
})

Electron loads fine getting de user locale with: __dirname+'/dist/'+language+'/index.html'

When I click at language angular menu the screen becomes blanck, and I don't see anything in console

Thanks for the help!

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!