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

Add owo-lib rich translations compatibility #2

Merged
merged 5 commits into from
Jun 28, 2024

Conversation

kikugie
Copy link
Contributor

@kikugie kikugie commented Jun 13, 2024

Rich translations allow creating text with configurable effects using owo-lib: https://docs.wispforest.io/owo/rich-translations/
This format translates nicely to yaml:

soundboard:
  title:
    - text: Soundboard
      color: aqua
      bold: true

In the plugin it is a simple change - whenever the endpoint value is a list, it preserves all its contents and converts to json as is.

@Fallen-Breath
Copy link
Owner

Suggestion: create a boolean switch for it, since it's not that a Minecraft standard. Benefits:

  • People won't trigger this feature unintentionally
  • Better implemetation control if there are similiar features in the future

Gradle, **why** is it so difficult to pass parameters to a filter? You already have it for extensions, just do it here again!
@kikugie
Copy link
Contributor Author

kikugie commented Jun 14, 2024

image

@Fallen-Breath
Copy link
Owner

Are these complex implementations really necessary? thonk

@kikugie
Copy link
Contributor Author

kikugie commented Jun 16, 2024

Apparently yes, because the filtering reader doesn't accept additional constructor args, like extensions do, so the alternative is either to create a non-static inner class or an anonymous class to get variables from the outer scope. The third way messes with how gradle injects passed properties via reflection, but that requires implementing non-api interfaces.

@kikugie
Copy link
Contributor Author

kikugie commented Jun 20, 2024

Any updates on this? Or preferred other methods?

@Fallen-Breath
Copy link
Owner

Fallen-Breath commented Jun 20, 2024

Any updates on this? Or preferred other methods?

I want to have a try myself to see if there's any better implementation on this when I have time. If you really needs this feature, you can use your fork for now (e.g. via jitpack)

@kikugie
Copy link
Contributor Author

kikugie commented Jun 21, 2024

A cleaner approach, where Yamlang2JsonlangMapper is an inner class that can pull fields from YamlangConvertor

@Fallen-Breath
Copy link
Owner

Yeah this approach is much nicer

@kikugie
Copy link
Contributor Author

kikugie commented Jun 21, 2024

Hhhh big bummer:
image

Gradle requires a constructor that only accepts a Reader, where as inner classes sneakily get another argument.

@kikugie
Copy link
Contributor Author

kikugie commented Jun 21, 2024

Since Gradle is not very welcoming of configurable filters, this is going to be cursed anyway. I'd leave as default behavior because you don't use lists in normal translation files.
The last alternative is to throw away the Gradle copy spec function and simply do the same process manually.
If no other solution works, I'll just host the fork on my maven in case someone needs the rich translation support.

@Fallen-Breath
Copy link
Owner

Fallen-Breath commented Jun 25, 2024

You can simply use this method to pass argument to the filter: https://docs.gradle.org/current/javadoc/org/gradle/api/file/CopySpec.html#filter(java.util.Map,java.lang.Class)

Changes are already pushed to your branch and it's now working. You can have another check to see if that's what you want

@Fallen-Breath Fallen-Breath merged commit 3db95aa into Fallen-Breath:master Jun 28, 2024
1 check passed
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.

2 participants