SpongePowered / SpongeAPI

A Minecraft plugin API
http://www.spongepowered.org/
MIT License
1.14k stars 344 forks source link

Translate Sponge's strings #564

Open zml2008 opened 9 years ago

zml2008 commented 9 years ago

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

gabizou commented 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.

zml2008 commented 9 years ago

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

Zidane commented 9 years ago

@zml2008 Status update on this.

gabizou commented 8 years ago

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

ST-DDT commented 8 years ago

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:

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)

zml2008 commented 8 years ago

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

gravityfox commented 8 years ago

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

ryantheleach commented 5 years ago

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.