sveltekit-i18n / lib

Internationalization library built for SvelteKit.
MIT License
491 stars 32 forks source link

Adding log when no translation is found in provided local/fallback #154

Closed ThibaultAndreis closed 11 months ago

ThibaultAndreis commented 11 months ago

I think it would be useful to have logs specifying which translation is missing.

Currently, if no translation is found, no log specifies if it's missing from the provided locale and/or fallback.

I've made a pull request in sveltekit-i18n/base to propose small changes that would add them.

Skylli202 commented 11 months ago

I think that would be helpful. I've had an unpleasant time recently trying to find which translation were missing.

jarda-svoboda commented 11 months ago

Hi @ThibaultAndreis! Thanks for your PR! I see it useful too, but I'd vote for debug log level..

ThibaultAndreis commented 11 months ago

I can change that Should we then add a warn if no tranlsation nor fallback value is found ?

like so :

if (text === undefined) {
    logger.debug(`No translation provided for '${key}' key in fallback '${fallbackLocale}'.`);
    if (rest.hasOwnProperty('fallbackValue')  ) {
      return rest.fallbackValue;
    }
    logger.warn(`No translation nor fallback found for '${key}' .`);
  }
ThibaultAndreis commented 11 months ago

i've made the changes to my PR

jarda-svoboda commented 11 months ago

Published 🚀 @sveltekit-i18n/base@1.3.7