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

__h has strange behavior when he doesn't have the key #485

Open OfirKariv opened 2 years ago

OfirKariv commented 2 years ago

Hey guys,

While using __h to get all the translations on a certain key, when I am inserting an invalid key the result is a follow:

key: "test_key"

response: [ "en-US" : "test_key", "es-ES" : "test_key", "fr-FR" : "test_key" ]

I wish there was a way to know your ,module didn't find any value for this key.

mashpie commented 2 years ago

you may configure a function that acts as middleware on every call for a missing key:


  // used to alter the behaviour of missing keys
  missingKeyFn: function (locale, value) {
    return value
  },