CreativeMD / EnhancedVisuals

Original creator is @SirPrimrose
GNU Lesser General Public License v3.0
18 stars 10 forks source link

[Suggestion] Make death messages translatable #139

Closed mpustovoi closed 1 month ago

mpustovoi commented 4 months ago

I wish there was some way to do this, other than force-editing the config for all languages. This would be especially useful for modpack creators. Maybe it is possible to pull the config file depending on the language, if the method via assets/enhancedvisuals/lang/ isn't possible.

CreativeMD commented 1 month ago

Sorry for not responding earlier. Released a new version which allows for death messages to be translated.

mpustovoi commented 1 month ago

So, what's the way? In the assets folder in your mod's file, there is no lang folder and no language file for the localization example.

CreativeMD commented 1 month ago

Any translation will work. You can create a new resourcepack with the translations included.

mpustovoi commented 1 month ago

You mean like this?

{
  "Do you really want to respawn? think of it again.": "<translation1>",
  "Life is hard. Deal with it!": "<translation2>" 
}

Sorry to bother you. I don't have time to test this yet.

CreativeMD commented 1 month ago

Yeah that does work, but maybe you change the death message to something shorter, because I m not 100% sure if spaces work with translation. For example change the first message to death.message.respawn.

mpustovoi commented 1 month ago

I think it depends on the approaches to localization.

1. Using the translation key. If some field is set like this, I can pick the translate key:

  "title": {
    "translate": "type.namespace.name",
    "fallback": "Default name"
  }

No en_us.json file required. However, there's no way for the translator to figure out the translation keys, other than diving into the depths of the mod/datapack files. Therefore, the fallback field is often omitted. So I will write in my resourcepack:

  "type.namespace.name": "<translation>"

It works without fallback field, but this field, for example, makes it easier to manage some advancements for vanilla datapacks, where clients will see the fallback if they don't have a localization resourcepack.

2. Using raw name string. The field is set like this:

  "title": {
    "translate": "Default name"
  }

It still can be translated, even with spaces. However, with short names, overlaps with other names are possible. So it's a bad way.

  "Default name": "<translation>"

3. Untranslatability. The field might be untranslatable:

  "title": {
    "text": "Default name"
  }

or just

  "title": "Default name"

Here there's no way to localize this.

mpustovoi commented 1 month ago

Since there is no lang file with default translations in your mod, I don't know how to find other lines like death.message.respawn.

CreativeMD commented 1 month ago

I'm a bit confused. Just add the translations. Then use the command /cmdconfig change the death messages to your translation keys and that's it. No need for a lang file in enhancedvisuals.

mpustovoi commented 1 month ago

No need for a lang file in enhancedvisuals.

So, it's not possible to support more than one language for a modpack. That's all what I wanted to know.

CreativeMD commented 1 month ago

You can do that as well. Have you ever worked with translations? Maybe try and search for a tutorial. It's pretty simple, in the death messages you define the translation keys you then use in the lang files to translate into different languages.

mpustovoi commented 1 month ago

Yes, I have worked with translations. The most I did was to determine the keys for translating achievements, at the limit of the vanilla game. I just couldn't find where can I define translations in your mod's code.

CreativeMD commented 1 month ago

There is no need to code. As I said you define them yourself, by changing the death messages to something you can translate. Use the command /cmdconfig -> enhancedvisuals -> death messages and then remove all the messages. Add new ones in the format as shown above death.message.respawn, add this translation key to your lang files including the translation. That's it. All minecraft does it check the text against all translations defined in the lang files, if it matches it will print out the translation otherwise it will display the text instead. No need to add anything in code.

mpustovoi commented 1 month ago

Got it. Thanks. I'll do it when I have time.