toonvanstrijp / nestjs-i18n

The i18n module for nestjs.
https://nestjs-i18n.com
Other
642 stars 106 forks source link

ERROR [I18nService] Translation "<key>" in "<language>" does not exist. #501

Closed Susccy closed 1 year ago

Susccy commented 1 year ago

Why is this error constantly thrown in the console despite the translations working fine with fallback languages? If a fallback language is provided, this shouldn't be an error because it is expected and wanted behavior. It should be a warning at most but even then I'd want to be able to disable the log completely as it is totally unnecessary.

rubiin commented 1 year ago

A minimal reproduction is needed

Susccy commented 1 year ago

The behavior can be easily deduced from the source code:

https://github.com/toonvanstrijp/nestjs-i18n/blob/08b68df1aeb15a6e09882e2eb417b79154a7ddf4/src/services/i18n.service.ts#L102-L123

The unnecessary error is logged in line 111. As you can see it will still try more languages after the error is logged, meaning it is expected behavior when utilizing fallback languages and thus not an error. Here it should be a warning at most.

Only if the translation couldn't be found in any fallback language, then it should throw an error.

toonvanstrijp commented 1 year ago

@Susccy I agree that the log on line 111 should not be presented since it's indeed expected behaviour. Would you be able to create a PR that removes this log, but still gives a log when the translation couldn't be found in any fallback language?

Susccy commented 1 year ago

I will look into it when I have time.