Open zml2008 opened 2 years ago
Personally, I'm looking towards this (with some obsession, apparently). 🤯
Regarding the limitations you listed...
By the way, what are prospects of gettext
integration? "Portable Object" is already an advantageous syntax for translators: with integral plurals logic, comments and flags. I guess that I should use gettext-commons
for this. Just wanted your take on this.
1) TranslatableComponent can only take other Component
s as arguments
2) default locale -- missing keys don't ever receive extra formatting
3) yup!
I've tried doing gettext formatting in java projects years back -- the biggest bottleneck was iirc the need for something to generate pot
files -- I had a fork of gettext-maven-plugin at https://github.com/zml2008/gettext-maven-plugin, not sure if anything similar exists for Gradle.
To do localization properly, I still think you'd need some sort of wrapper around Components, since components can't really serialize the arbitrary types that could be part of a MessageFormat.
Thanks for your observant response, @zml2008.
There is gettext-plugin
for Gradle with *.pot
generation, format and merge tasks. Didn't try it myself yet, but I hope it's something.
If I'm not wrong, gettext
is already one heck of a task for someone's pipeline, with ahead-of-time compilation and whistles. So, I'd understand if it wouldn't have a spotlight in docs. While gettext is awesome for internationalization, it doesn't cover l10n much (especially if we talk about serialization of arbitrary types in Java, as it probably shouldn't anyway).
Perhaps support can be added for choice formats in MessageFormat
?
Example:
import java.text.MessageFormat
fun main() {
for (i in 1..5) {
println(MessageFormat("There {0,choice,1#is|1<are} {0,number,integer} {0,choice,1#player|1<players} connected.").format(arrayOf(i)))
}
}
Output:
There is 1 player connected.
There are 2 players connected.
There are 3 players connected.
There are 4 players connected.
There are 5 players connected.
Playground:
We have a basic localization system within Adventure, using TranslationRegistry
There should be a documentation page explaining it, how it interacts with vanilla translations, and its limitations.
Limitations include:
This could mention moonshine, and potentially whatever is added to MiniMessage for localization