Open zml2008 opened 9 years ago
Make every string in Sponge (API + mod) translatable
Some things (like DataQuery keys) obviously should not be translatable. I hope you weren't considering that as a possibility.
yeah, not those. more user-facing messages was what I'm talking about. updated the issue to be more clear about that.
@zml2008 Status update on this.
This needs further thought with regards to debugging, so calling all @SpongePowered/developers
This could be implemented using the features added in #808 and mostly its prior PR #779, but that would require changes to the Translation
interface.
Namely:
get(Locale locale, Object... args) : String
to return a Text
resolveLocally()
method
instanceOf SpongeTranslation
).And on the implementation side.
MixinTextTranslatable.createComponent(Locale)
.
@Override
protected IChatComponent createComponent(Locale locale) {
if (this.translation instanceof SpongeTranslation) {
ChatComponentTranslation ret = new ChatComponentTranslation(this.translation.getId(), unwrapArguments(this.arguments, locale));
((IMixinChatComponentTranslation) ret).setTranslation(this.translation);
return ret;
} else {
return SpongeTexts.toComponent(translation.get(locale, arguments), locale);
}
}
And on the plugin/translation side
TranslationImpl
public Text get(Locale, Object... args) {
return Texts.format(dictionary.getTranslation(getId(), locale), args);
}
I already thought about adding that feature to my PR #808, but this would probably be outside of its scope and will also blow up that PR even more. (But I could (try to) do that If you want, including creating a separate PR for it)
@ST-DDT none of that is needed -- this works as is today, just needs the proper tooling (a gradle plugin) for gettext to generate pot files and the appropriate resource bundles.
do you think this could be expanded to an api that allows plugins to easily support translations as well?
We are hoping to finally have the Text Implementation internal to Sponge come API 8, which will pave the way to this and other translations working nicely finally.
The end goal of this is to make Sponge fully internationalized, meaning that server owners get messages all in their own language!