Skip to content

How do you create/test an i18next plugin? #1379

@reZach

Description

@reZach

I'm trying to test the i18next-electron-fs-backend i18next plugin I wrote, that is testable in this repo. The plugin is meant to mimic the i18next-node-fs-backend, but within Electron.

TL;DR - this plugin is meant to make use of the ipcRenderer/ipcMain modules Electron provides to facilitate writing to disk, while maintaining SOC (separations of concerns) to keep your app secure.

I'm sad, because the documentation for creating plugins is quite sparce, but I think I've managed to write enough in order for the plugin to work. I am running into a problem, because I don't know how to test my plugin! As you can see in the source code of the plugin, I've written console.log statements in the relevant methods (read, create, etc) but I do not see anything in the console (below) when the component renders. The proper i18next::translator: missingKey en translation Detail.SampleText Detail.SampleText (I assume) messages displays, but nothing else happens.

image

A fully-functioning demo is available for you to test locally:

-- command line
git clone https://github.com/reZach/secure-electron-template.git
cd secure-electron-template
npm i
npm run dev

-- electron app
Click the "Click me to go the main page." link
Notice Console

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions