Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda