Tractor Mod

Tractor Mod

130k Downloads

[Content Patcher]Can't set images for different languages

DL0101 opened this issue ยท 2 comments

commented

I wanted to add images for different languages, but the code didn't work and the console didn't report an error.
{
"Format":"1.16.0",
"Enabled":"true",
"ConfigSchema":{
"Interface":{
"AllowValues":"true,false", "Default":"true"
},
},
{
"Action":"EditImage",
"Target":"Minigames/TitleButtons",
"FromFile":"interface/TitleButtons.png",
"PatchMode":"Overlay",
"When":
{
"Interface":"true",
}
},
{
"Action":"EditImage",
"Target":"Minigames/TitleButtons.zh-CN",
"FromFile":"interface/TitleButtons.zh-CN.png",
"When":
{
"Language": "zh",
}
},
}

commented

Hi! The language isn't part of the asset name, and your patches apply in all languages by default. You can target specific languages using the language token instead.

The easiest approach is use {{language}} in the FromFile field, like TitleButtons.{{language}}.png. Then just create files like TitleButtons.zh.png, and they'll be applied automatically for the language if they exist:

{
   "Format": "1.16.0",
   "ConfigSchema": {
      "Interface": {
         "AllowValues": "true, false",
         "Default": "true"
      },
   },
   "Changes": [
      {
         "Action": "EditImage",
         "Target": "Minigames/TitleButtons",
         "FromFile": "interface/TitleButtons.{{language}}.png",
         "PatchMode": "Overlay",
         "When": {
            "Interface": "true",
            "HasFile:{{FromFile}}": "true"
         }
      },
      {
         "Action": "EditImage",
         "Target": "Minigames/TitleButtons",
         "FromFile": "interface/TitleButtons.png",
         "PatchMode": "Overlay",
         "When": {
            "Interface": "true",
            "HasFile:interface/TitleButtons.{{language}}.png": "false"
         }
      }
   ]
}

See common fields in the author guide and the language token for more info, and feel free to come ask on Discord if you have any questions!

commented

Thanks a lot!!!