Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move error log to only show if key for default value is missing #598

Merged
merged 1 commit into from
Nov 27, 2023
Merged

move error log to only show if key for default value is missing #598

merged 1 commit into from
Nov 27, 2023

Conversation

henrikhertler
Copy link

Description

As discussed here #540: It would be nice to only print an error to the console if the translation couldn't be found in any fallback language. Therefore I created this PR.

This will prevent "polluting" logs as the system works as intended and will only log an error if no key in any fallback language is found.

Linked Issues

#540

Additional context

Following the Boy Scout rule (Always leave the code you are working on a little bit better than you found it.) I also tried to make the function I touched more readable.

This is my first contribution. Feel free to remark on anything I can improve. 😌

@coveralls
Copy link

Coverage Status

coverage: 90.828% (-0.04%) from 90.869%
when pulling b0f56b7 on henrikhertler:move-does-not-exist-log
into 3fc33c1 on toonvanstrijp:main.

@toonvanstrijp
Copy link
Owner

@henrikhertler thanks for your contribution! All tests are passing, and this addition will for sure help keep your logs clean! 🎉

@toonvanstrijp
Copy link
Owner

@rubiin I don't have time to make a release, can you please do it? 🙇🏻 👀

@rubiin
Copy link
Collaborator

rubiin commented Nov 27, 2023

@rubiin I don't have time to make a release, can you please do it? 🙇🏻 👀

sure thing

@rubiin rubiin merged commit da1e793 into toonvanstrijp:main Nov 27, 2023
3 checks passed
@lvisb
Copy link

lvisb commented Jan 11, 2024

I am still receiving the error message. Version 10.4.0.

@henrikhertler should the line this.logger.error(translationKeyMissing); be inside the clause: if (this.i18nOptions.logging && this.i18nOptions.throwOnMissingKey)?

@henrikhertler
Copy link
Author

@lvisb it worked for my use case, I tested it.

Just to double check:
Are you sure that you properly set up a fallback language?
And your translation is in the fallback language?

If yes, maybe @toonvanstrijp or @rubiin can have a look again.
If you could isolate the relevant parts of your code and create a small, standalone example, that would be very helpful.

@lvisb
Copy link

lvisb commented Jan 15, 2024

@henrikhertler Yes, I have properly set up a fallback language, and the translation is indeed in the fallback language.

I've created a small, standalone example with the relevant parts of the code for easier analysis. You can find it at this link: https://github.com/lvisb/nesti-18n-error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants