SpongeAPI icon indicating copy to clipboard operation
SpongeAPI copied to clipboard

Translate Sponge's strings

Open zml2008 opened this issue 10 years ago • 8 comments

The end goal of this is to make Sponge fully internationalized, meaning that server owners get messages all in their own language!

  • [x] Make text API support serverside translations -- PR #563
  • [ ] Add GettextTranslation -- Gettext has better tooling
  • [ ] Write Gradle plugin to use gettext to extract strings from translation methods
  • [ ] Make every user-facing message string in Sponge (API + mod) translatable
  • [ ] Setup CrowdIn for people to translate everything

zml2008 avatar Apr 11 '15 22:04 zml2008

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.

gabizou avatar Apr 12 '15 07:04 gabizou

yeah, not those. more user-facing messages was what I'm talking about. updated the issue to be more clear about that.

zml2008 avatar Apr 12 '15 15:04 zml2008

@zml2008 Status update on this.

Zidane avatar Apr 25 '15 03:04 Zidane

This needs further thought with regards to debugging, so calling all @SpongePowered/developers

gabizou avatar Dec 06 '15 23:12 gabizou

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:

  • changing get(Locale locale, Object... args) : String to return a Text
  • adding a resolveLocally() method
    • (could be avoided using a 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 avatar Dec 07 '15 17:12 ST-DDT

@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.

zml2008 avatar Dec 08 '15 15:12 zml2008

do you think this could be expanded to an api that allows plugins to easily support translations as well?

gravityfox avatar Jul 19 '16 09:07 gravityfox

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.

ryantheleach avatar Aug 03 '18 10:08 ryantheleach