Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Support changeable/loadable locales

Open MeFisto94 opened this issue 4 years ago • 22 comments

Is your feature request related to a problem? Please describe. ItemMeta#getLocalizedName() is always the english version.

Describe the solution you'd like It would be good to have a convenient way of setting the server locale for this.

Describe alternatives you've considered Using Translatable Message Components should work.

Additional context @Phoenix616 has suggested creating this issue and has the background knowledge for this topic.

MeFisto94 avatar Apr 29 '20 17:04 MeFisto94

My knowledge here is that the LocaleLanguage just loads the en_us.json file from the server. As far as I can tell nothing would stop one from patching that to allow loading other language files from the server folder (maybe a dedicated languages one or via a config option/startup argument?) Currently one would have to modify the file in the server jar directly which is inconvinient.

Ideally such an addition would need to fallback to the existing json for non-existing keys to not break on updates when new keys are added.

Phoenix616 avatar Apr 29 '20 17:04 Phoenix616

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Dec 02 '20 21:12 stale[bot]

Stale who? Stale you! Zim-zalabim, unstale! ✨✨

Proximyst avatar Dec 02 '20 21:12 Proximyst

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 02 '21 16:03 stale[bot]

It's not stale, it's a feature request...

Phoenix616 avatar Mar 03 '21 12:03 Phoenix616

There should be a startup flag so it doesn't download/patch on every server load.

anjoismysign avatar Mar 04 '22 18:03 anjoismysign

@promorrom I'm unsure how this relates to the server locale? Was this commented on the wrong issue or am I just not understanding what you mean by that?

Phoenix616 avatar Mar 04 '22 21:03 Phoenix616

If you edit the server locale (inside the jar), it will download a new jar so you did waste your time and issue is still present. Billy said this is due to "paper's new paperclip system".

image

anjoismysign avatar Mar 05 '22 19:03 anjoismysign

paperclip has always patched modified jars, that's literally nothing new and has been the case for years

The difference in the past was that paperclip produced a singular jar which you could tweak and run standalone, that changed when mojang also stopped producing standalone jars, meaning that you can no loner just patch and run the standalone thing.

modifying the jar as a solution basically makes 0 sense, really the thing should just look on the disk or something for the file rather than tryna use a backwards ass solution, but, that API is deprecated in favor of client side translations, but, given mojang refuses to do this and the locales are used for some stuff, if somebody wants to look at dynamically loading that stuff off mojangs API or letting people just place the locales file somewhere, I'd be open for that

electronicboy avatar Mar 05 '22 19:03 electronicboy

I started working on a PR for adding vanilla language keys from Mojang's asset API to adventure's GlobalTranslator for this issue recently, but I have to ask, is this still necessary? With the addition of support for adventure components nearly everywhere, I can't think of any text that's sent to the client as a raw string to necessitate this feature. Only one I could think of was scoreboard players, but machine maker pointed out a clever workaround of creating teams for invisible player names with prefixes set to translatable components. Does anyone have a good use case for this that's not covered by adventure components? Don't want to put a ton of work into something that'll get rejected for being deprecated/unsupported/whatever :P

qixils avatar Aug 11 '22 05:08 qixils

I think what was brought up is outside of mc usage, IE resolving translatable components to plain text so that they can be displayed on discord

MiniDigger avatar Aug 11 '22 06:08 MiniDigger

Ooh yeah, would be nice for those Minecraft <-> Discord chat plugins. Ok, I'll keep working on it 🙂

qixils avatar Aug 11 '22 15:08 qixils

That seems like such a niche usecase, that it can be done by those plugins themselves right? Why do any changes to the paper server have to happen for that?

Machine-Maker avatar Aug 11 '22 15:08 Machine-Maker

Well, depending on how it's implemented, this could also allow server owners to change the language of translatable components in their server log files, which alone seems pretty worth it to me as that's not something that can be easily done by a plugin.

Regarding the Discord chat use case, sure plugin developers can technically implement their own component flatteners for this, but that's a bit of a tall ask tbf

qixils avatar Aug 11 '22 16:08 qixils

Can someone do a catch up in what the actual problem is?

Leguan16 avatar Aug 11 '22 16:08 Leguan16

The server has no access to languages besides English (US); this is a feature request to allow the server and plugins to fetch other languages somehow (either via local file path or via Mojang's asset API)

qixils avatar Aug 11 '22 16:08 qixils

Ok so this request wants getLocalizedName() to do the same as displayName() and cast it to a TranslatableComponent?

Leguan16 avatar Aug 11 '22 16:08 Leguan16

My usecase for this would be holograms/nametags. those can't use translatables. I ended up just ripping the translation files from the client & adding them to my plugin, but that really isn't an optimal solution.

Malfrador avatar Aug 11 '22 16:08 Malfrador

My usecase for this would be holograms/nametags. those can't use translatables.

I tested in single player and was able to get armor stands to use translatable components for display names o.o


EDIT: /summon armor_stand ~ ~ ~ {CustomNameVisible:1b,CustomName:'{"translate":"block.minecraft.dirt","color":"green","bold":true}'}

2022-08-11_12 41 56

qixils avatar Aug 11 '22 16:08 qixils

Seems like a valid usecase to me.

Leguan16 avatar Aug 11 '22 16:08 Leguan16

AFAIK, the only place you can't use translatable (or components) is scoreboard entries, or game profile names, but you can do everything you want there with team prefixes/suffixes or armor stands for custom name tags.

Changing the server's locale would allow the log to be in a different language, but that still seems really unneeded, and I think that is the only possible reason Paper would want to add this functionality.

Machine-Maker avatar Aug 11 '22 17:08 Machine-Maker

Yeah it seems like I was wrong there and that was fixed/changed. I was doing it in 1.16, and the client just displayed the translation key instead of the translation. But yeah, if that works now I also don't know any other place that doesn't support translatables.

Malfrador avatar Aug 11 '22 19:08 Malfrador