Create an API for plugin-defined text translations#563
Create an API for plugin-defined text translations#563
Conversation
4af025f to
786d159
Compare
786d159 to
17c2a56
Compare
|
Why have you removed |
|
The built-in Java |
|
@kenzierocks This list contains an exact and unlike Java's also complete list of locales available in Minecraft, which can be used to detect the language the client is using |
|
True. Can we have those be set to constants instead of |
|
@Minecrell that's called player.getLocale()... And the complete list of locales available is in some standards document somewhere. I don't really see any use cases for maintaining a list of possible MC languages. |
|
@zml At the end, we're creating an API that's supposed to be easily usable, so providing additional convenience for the API user is nothing bad. With this class you don't need to Google first, you can simply check the player's locale from one of the default locales available in Minecraft. As a side note: some of the Minecraft locales are not standardized, because there are no exact specifications for some languages. Due to this, Minecraft has also changed locale codes in the past which would result in breaking plugins which is definitely something we want to prevent as much as possible. Maintaining this list (actually generated automatically from Minecraft's resource index) requires almost no effort together with a Minecraft update, but additional effort from plugin developers without this automation. Additionally I think this removal is really out of scope for a PR for plugin-defined translations, this should be discussed in a separate issue. |
|
is there an instance in which this list would be actually be used? Because I can't think of any? |
|
If implemented properly you can use it like |
|
However, nobody should be using fixed locales. You'd never get a translation for a specific Locale, you almost never compare a locale using the Locale instance (instead using its toString to get a strings file) -- your use cases are not particularly realistic. |
|
Simply because it does not seem useful if you code a generic, well configurable plugin does not mean there are no use cases at all. For custom plugins there are often things hardcoded that are really unlikely to change, and even if you just use it for debugging. Keep in mind in theory you could also use it for a configuration to provide an easier way to configure locales with the name instead of their locale codes. |
|
so you're saying just because it's not useful for well-written plugins, it might be useful for badly-written plugins? Why should we be supporting anything but well-written plugins? |
|
@zml2008 This discussion is getting more and more off-topic, you can't see "well-written" plugins from a generalized view, it always depends on which environment and which people a plugin is developed for. For a custom plugin where direct configuration isn't that important (as it will almost never change) implementing a complex configuration would be wasted time. Just because something is hard-coded, doesn't directly mean it's not a "well-written" plugin. As for the removal of |
|
You know you still haven't given any specific use cases for this. Every program that supports localizations does it through resource files. We have the advantage of having Java's standard library which has user-friendly name mappings for most Locales, and resource file lookup is done using the locale codes. Anyway, special-purpose plugins that you're referring to generally don't have localizations at all -- having a translated plugin at all requires a multilingual dev and/or a large enough audience to crowdsource translations. I don't really see the point in splitting this into a separate PR at this point -- might as well just go for a yes/no on keeping Locales @Zidane? |
17c2a56 to
6fa0f80
Compare
There was a problem hiding this comment.
How does the server detect whether the translation is (or supposted to be) included in the minecraft client?
Some full mods (client and server) may want to resolve the text client side because they also provide resourcepacks. There should probably an interface or a method whether the translation should be resolved on the server side. An internal Set of keys could work as well, but mods should be able to add to it.
There was a problem hiding this comment.
mods with resource packs get translations from the GameRegistry. Those are clientside translations. Anything doing serverside translations uses a different Translation implementation appropriate to its translation store.
|
@zml2008 how are we going to handle the eventual addition of client side plugins? |
|
They can either have resource bundles clientside and use translation instances from the GameRegistry (which still do translations clientside, since we don't have all languages serverside), or have all messages in a ResourceBundle and just do the translations on whatever side the code that sends the message is on (I don't think there's much/any client->server sending of translation strings though). |
There was a problem hiding this comment.
I think we should keep the getters without language to get it in the default language of the server (which is also the same as used in Texts.toPlain(Text) without locale argument)
There was a problem hiding this comment.
Should add @see SpongeTranslationHelper for example impl instead of copying it inline
There was a problem hiding this comment.
SpongeTranslationHelper will probably be switched over to gettext once the necessary tooling is ready, so probably not good to point to it in the docs for the resource bundle implementation.
6fa0f80 to
61a3d71
Compare
61a3d71 to
ff8c439
Compare
This PR expands the translatable interface to be more friendly to server-side translations. It also lays the groundwork for making every string in SpongeAPI translatable. This API moves the change from untranslated string to translated string from wherever the Text is created to directly before the text is sent to the CommandSource.
Miecraft's resource pack client-side strings are still supported, but not recommended because usage is more complicated.