mashpie / i18n-node

Lightweight simple translation module for node.js / express.js with dynamic json storage. Uses common __('...') syntax in app and templates.
MIT License
3.08k stars 419 forks source link

Locales generated with empty object #479

Closed archansel closed 3 years ago

archansel commented 3 years ago

My locales en.json and the other languages were created but don't have any translation. I use singleton implementation and use it using response object

// Config
i18n.configure({
  locales: ['en', 'id'],
  directory: path.join(__dirname, '/locales'),
  autoReload: true,
  objectNotation: true,
});

// Espress middleware
app.use(i18n.init);

// Translation
res.__('err.denied:Access denied')

I can write in manually but it will be painful and prone to error. Is there a way I can generate the translation files?

mashpie commented 3 years ago

did you try to configure with updateFiles: true

archansel commented 3 years ago

Turns out I have to access the endpoint to generate the object, is it expected? most localization libraries that I use usually generate when starting the node

mashpie commented 3 years ago

i18n generates file when res.__('err.denied:Access denied') is called

archansel commented 3 years ago

Noted