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

364
Vistas
Electron + typescript + i18next problem - i18next::backendConnector [...] fs.readFile is not a function

I've spent almost whole day on trying to configure i18next translations in electron + typescript. I actually have no idea what can i do with it to make it work. I always get the following error: "i18next::backendConnector: loading namespace translation for language en failed TypeError: fs.readFile is not a function".

for boilderplate i've used https://github.com/diego3g/electron-typescript-react

i18n.config file (locales are in same folder and structured: locales/lang/namespace

import i18next, { InitOptions } from 'i18next'
import backend from 'i18next-fs-backend'
import { initReactI18next } from 'react-i18next'

export const DEFAULT_LANGUAGE = 'en'
export const DEFAULT_NAMESPACE = 'common'

const i18nOptions: InitOptions = {
  lng: DEFAULT_LANGUAGE,
  fallbackLng: DEFAULT_LANGUAGE,
  defaultNS: DEFAULT_NAMESPACE,
  fallbackNS: DEFAULT_NAMESPACE,
  interpolation: {
    escapeValue: false,
  },
  debug: true,
  backend: {
    loadPath: './locales/{{lng}}/{{ns}}.json',
    addPath: './locales/{{lng}}/{{ns}}.missing.json',
  },
}

i18next.use(backend).use(initReactI18next).init(i18nOptions)

export default i18next

webpack config:

const path = require('path')
var i18nextPlugin = require('ya-i18next-webpack-plugin').default

module.exports = {
  resolve: {
    extensions: ['.ts', '.tsx', '.js'],
    modules: [path.resolve(__dirname, '../src'), 'node_modules'],
    fallback: {
      fs: false,
    },
  },
  module: {
    rules: require('./rules.webpack'),
  },
  plugins: [
    new i18nextPlugin({
      defaultLanguage: 'en',
      defaultNamespace: 'common',
      languages: ['en', 'pl'],
      functionName: '_t',
      resourcePath: '..public/locales/{{lng}}/{{ns}}.json',
    }),
  ],
}

i18n initialization:

import ReactDOM from 'react-dom'
import App from './app'
import { i18n } from './config'

i18n.init()

ReactDOM.render(<App />, document.getElementById('root'))
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

In electron you need to use IPC (inter-process-communication) to request a file be read or written from the electron's main process. So there is no direct fs (filesystem) access.

Try this i18next backend plugin instead: https://github.com/reZach/i18next-electron-fs-backend

about 4 years ago · Juan Pablo Isaza Denunciar
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