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

Less verbose translation logging #70

Closed
Blacklands opened this issue Aug 14, 2021 · 8 comments
Closed

Less verbose translation logging #70

Blacklands opened this issue Aug 14, 2021 · 8 comments
Assignees
Labels
Type: Enhancement Improvements to existing features. Type: Question Request for clarification or more information.

Comments

@Blacklands
Copy link

Blacklands commented Aug 14, 2021

(Version used: 1.4.4-RC3)

Is there a way to just disable the internationalization functionality?
I have just started using Kord Extensions, and I am not interested in using the resource bundles (not at the moment, at least). I just want to be able to provide strings directly.

The (old) documentation mentions that "translations are optional". While this seems to be true (everything works fine), I am still getting an exception thrown for every single name and description of a slash command I set up for my bot.

I am seeing two debug lines in the log stating

Getting bundle (translations.kordex.strings, en_GB) for locale en_GB
Unable to find translation for key '[name/description contents of the slash command]' in bundle 'null'

And then a

java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key [same as above]
	at java.util.ResourceBundle.getObject(ResourceBundle.java:563) ~[?:?]
	at java.util.ResourceBundle.getObject(ResourceBundle.java:557) ~[?:?]
	at java.util.ResourceBundle.getString(ResourceBundle.java:520) ~[?:?]
	at com.kotlindiscord.kord.extensions.i18n.ResourceBundleTranslations.get(ResourceBundleTranslations.kt:57) ~[kord-extensions-1.4.4-RC3.jar:?]
	at com.kotlindiscord.kord.extensions.i18n.ResourceBundleTranslations.translate(ResourceBundleTranslations.kt:66) [kord-extensions-1.4.4-RC3.jar:?]
	at com.kotlindiscord.kord.extensions.i18n.TranslationsProvider.translate(TranslationsProvider.kt:54) [kord-extensions-1.4.4-RC3.jar:?]
	at com.kotlindiscord.kord.extensions.i18n.TranslationsProvider.translate$default(TranslationsProvider.kt:49) [kord-extensions-1.4.4-RC3.jar:?]
	at com.kotlindiscord.kord.extensions.commands.slash.SlashCommand.getTranslatedName(SlashCommand.kt:149) [kord-extensions-1.4.4-RC3.jar:?]
	at com.kotlindiscord.kord.extensions.commands.slash.SlashCommandRegistry.sync$suspendImpl(SlashCommandRegistry.kt:155) [kord-extensions-1.4.4-RC3.jar:?]
(long rest of the stacktrace)

While this does not affect any functionality as far as I can tell, it is fairly annoying for development, since I am basically getting two full (long) stacktraces thrown into the console for every single slash command I set up, making it hard to read anything else there.

Is this a bug, or something that was simply missed so far? Or is it supposed to be like that?
If it is, how can I disable it?
I can't even just catch the exceptions, as far as I am aware (I've only recently starting migrating from Java to Kotlin), since they happen somewhere in a coroutine, and I am using the provided DSL to set up the slash commands so I can't put a try-catch block there, either, can I?

If there is no resource bundle set up, should the code be trying to find translation keys at all?
Alternatively, is there a switch to just turn off internationalization entirely, if one is not interested in using it? (Or at least during development, until one starts to add translations.)

@boring-cyborg
Copy link

boring-cyborg bot commented Aug 14, 2021

Hello, and thanks for opening an issue! As this is the first time you've created an issue on this repository, we'd just like to offer you a warm welcome to the project, and the following pointers:

  • Most importantly, all issues must adhere to our Code of Conduct. Please give it a quick read if you haven't already.

  • While our team is passionate about the projects we've created here, we're all volunteers. Please don't be offended if it takes time for us to get to your issue - we'll be here as soonas we can be!

  • Please provide as much information as possible when asking a question, reporting a problem, or submitting a feature request. This will help us to address your issue quickly and efficiently. If you forgot to add some information, no worries - feel free to edit the issue and add anything you missed!

    Thanks for contacting us! If you have any further questions, please feel free to join us on Discord in the #dev-kotdis channel (or #kordex-discussion for Kord Extensions projects), or to contact a staff member directly.

@gdude2002
Copy link
Member

Hey, thanks for the issue!

I was thinking about this the other day - currently they're debug level messages, which can indeed get annoying. My current plan is to switch them to trace logging.

The i18n stuff can't be disabled since it's a core part of the framework - it's relied upon by pretty much everything. The logging is there to let you know about missing translations, indeed - I think setting them to trace level and removing the traceback should be enough though, right?

@gdude2002 gdude2002 self-assigned this Aug 14, 2021
@gdude2002 gdude2002 added Type: Enhancement Improvements to existing features. Type: Question Request for clarification or more information. labels Aug 14, 2021
@gdude2002
Copy link
Member

This will be done in the latest push, as well as giving an explicit package name to the logger in case you want to change the logging settings yourself - it'll be com.kotlindiscord.kord.extensions.i18n.ResourceBundleTranslations.

@Blacklands
Copy link
Author

Blacklands commented Aug 14, 2021

Thanks for the quick response!

I didn't even realize that the stacktraces are part of the logging messages! I had been thinking that they are just printed to stdout by the runtime.
In that case, one could set their logging framework to (effectively) filter out that specific output (e.g. with a RegEx filter). (EDIT: Or by setting that specific logger explicitly to something lower than debug, yes.)

I think changing the log level to trace (and/or removing the traceback) is also worth considering, yes. The trace level to me means something like "I know this logging output is going to be a big mess, but I really need all of the information!" - so it feels like these messages belong more to trace than they belong to debug.

@gdude2002
Copy link
Member

Well, like I say, it's already been pushed up. I'll likely get a release out soonish, since Kord's in another snapshot cycle, but we'll see.

@gdude2002 gdude2002 reopened this Aug 14, 2021
@gdude2002
Copy link
Member

Don't close it yet, it's not in a release yet haha

@Blacklands
Copy link
Author

I apologize for the confusion; I started writing my response but then I went away and came back later to finish it, and ended up missing your update.
Anyway, thanks for solving this so quickly!

@gdude2002
Copy link
Member

I'll be getting a release out shortly, so I'm closing this now - keep an eye on the releases section!

@gdude2002 gdude2002 changed the title Disable Internationalisation Less verbose translation logging Aug 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Improvements to existing features. Type: Question Request for clarification or more information.
Projects
None yet
Development

No branches or pull requests

2 participants