Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

217
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda