Mystical World

Mystical World

19M Downloads

[Suggestion] Remove hard-coded info from mw's Patchouli API

RisingInIris2017 opened this issue · 10 comments

commented

Describe your suggestion:

Now, MysticalWorld Mod has its own Patchouli guidebook. It's pretty good, but some information, for example, MW animals' information, is hard-coded in AnimalSpawnInfo.java.

Let's have a look at a picture: (attached below)
In this picture, There are 2 entries, namely, "Groups of" and "Biome tagged with", is hard-coded.
But there are still pieces of information, which were hard-coded into your API but I have not mentioned.

These pieces of hard-coded information is difficult to be localized.

Dear devs, I think an easy-to-be-localized Patchouli guidebook will help your brilliant mod to be much more popular internationally, isn't it?
So my suggestion is, how about remove these hard-coded texts from your API, but let them be called, and store them in another file (maybe a JSON, a LANG file, etc. )?
I think this will great benefit your mod.

Describe alternatives you've considered:

Remove these hard-coded texts from your API, but let them be called, and store them in another file (maybe a JSON, a LANG file, etc. )?

Additional context:

20200208135040

commented

Yes, unfortunately book.json's macros don't (as far as I'm aware, at least in 1.12) allow for macros to be defined in the language file rather than in the macro. Perhaps it wasn't intended for them to contain text that would need to be translated.

It is also unfortunate that Patchouli for 1.12.2 is not accepting any updates... I will dig around and see what I can find.

commented

Thats a fair point. It shouldn't be too hard to make the code values into localisable ones.

commented

I understand the issue you've raised and it definitely has the potential to be a problem. I would like to find the best solution for you. Unfortunately, outside of the English phrases "Groups of:" and "Biomes tagged with:", all of the other information you've mentioned is not actually hard-coded, but a representation of the configuration file.

In the case of biome tags, while they might be in English, they are simply a capitalised copy of the Forge "BiomeDictionary" tags (such as MESA, FOREST, PLAINS, MOUNTAIN, SWAMP, etc). While it may be possible to provide our own internal translations (returning "I18n.format("forge.biomes.tags.TAG)"), this will not work in every case, as the BiomeDictionary tags are designed to be extended by mod authors, and even a simple typo in the configuration file could result in the creation of a new key.

Likewise, the group size is determined by the values from the configuration of "min" and "max". There's not really any easy way that I'm aware of to localise this numerical range.

What I can definitely do is localise "Standard group sizes.", "Groups of:", "Default biomes." and "Biomes tagged with:", which means that the template can more easily be used with different translations.

I can't really see a simple solution that would fit the biomes tags for every situation, but I'll keep pondering it.

commented

Thanks for your explanation! Now I have known the difficulty we are faced.
One of the reasons why I wrote this issue is that I am going to send you a pull request for localization for Patchouli guidebook of MW. I will do this once you have some way to solve the hard-code problems of Patchouli API.

I have found that your book.json is also a hard-to-localize file.
I did not list it in the issue above, but this does matter.
Should I post another issue for book.json? Maybe it is unnecessary, in my opinion.

I believe in that with our cooperation, MW will be more widely known among Minecraft Mod players.
Thank you again!

commented

unfortunately book.json's macros don't (as far as I'm aware, at least in 1.12) allow for macros to be defined in the language file rather than in the macro.

I am worried about this ,too.
But I have turned to my friend, who is a Minecraft modder, and he give me a piece of codes, maybe it is helpful.

Here is the book.json file used by his own mod.
Line 3,
"landing_text" : "guide.smith_guide.landing_text",
the key is Patchouli text key, the value is a unlocalized name.
Then there is a line in his en_us.lang.
Line 244,
guide.smith_guide.landing_text=Welcome to Smiths' Guide. This is still a WIP book because we haven't finished planning the story yet.
By doing this he managed to have his Patchouli guidebook's book.json localized.

Maybe this is a good suggestion. You may have a try.

commented

Unfortunately, macros are applied as a straight substitution:

actualText = actualText.replace(key, book.macros.get(key));

There's no conversion to language key that I can find in the source code, unlike these other keys which are automatically translated if they are a language key; unfortunately, there isn't any way to change this as Vazkii's development team have decided to cease all support for 1.12.2 for Patchouli, Quark, etc, and do not appear to be accepting even patches...

commented

While it may be possible to provide our own internal translations (returning "I18n.format("forge.biomes.tags.TAG)"), this will not work in every case, as the BiomeDictionary tags are designed to be extended by mod authors, and even a simple typo in the configuration file could result in the creation of a new key.

@noobanidus Hi. How about checking if the language key can be translated, if true then translate it, before current logic? So that pack makers are able add their own translations for some unusual biome tags

commented

@Snownee I'd need a syntax for that though first, as the information I'm getting from the configuration is simply the values "HOT", "SWAMP", etc. If someone wants to put forth a standard for translating this, I'm perfectly happy to use that -- and translate to that -- and have the processor look in that key for a value before falling back on the default.

EDIT: i.e., forge.biome.tag.swamp=Swamp, etc.

commented

@noobanidus I think that one is good enough

commented

At least you may insert a language key into book.json, making its name can be localized.
It is possible to put language key into book.json's "text" objects, indeed.