Skip to content

Language_Files

Nutty101 edited this page Jun 17, 2019 · 1 revision

Language File Usage in my plugins:

The language files for most of my plugins look rather complex but in essence, they are not that hard to manage. They offer the ability to change the entire interface without modifying any code.

By default, the plugin will utilize the en_def language file. This file is overwritten every time the plugin starts up. This is to ensure that the plugin always has the correct language to function in the event of an update. When you want to make changes to the languages that can persist over multiple updates, just create a new file and populate only the lines that you want to change. I will revert to the en_def file for all other lines.

Allowing for custom messages:

For the sake of this tutorial, let's make a new English language file with changes that we want on our server. The first thing you want to do is open the config.yml file inside the plugin's folder {plugins/NPC_Destinations/config.yml}.

language: en_def

Change the language setting to en_us, and upon reloading the plugin will look in {plugins/NPC_Destinations/Languages} for a file named en_us-destinations.yml.

language: en_us

Your own language file:

For this example, let's change some lines related to the debug command's output.

debug_messages:
  path_processing: "[{\"text\":\"[\",\"color\":\"yellow\"},{\"text\":\"NPCDest\",\"color\":\"green\"},{\"text\":\"] \",\"color\":\"yellow\"},{\"text\":\"Processing for (<npc.id>) <npc.name>\",\"color\":\"GREEN\"}]"
  path_taskqueued: "[{\"text\":\"[\",\"color\":\"yellow\"},{\"text\":\"NPCDest\",\"color\":\"green\"},{\"text\":\"] \",\"color\":\"yellow\"},{\"text\":\"Pathfinding task for (<npc.id>) <npc.name> queued up\",\"color\":\"GREEN\"}]"

The above lines are what happens when an NPC has a new location to navigate to. One is that it has started, the second is when the engine is busy and the request has to be queued up.

path_processing: [NPCDest] Processing for (<npc.id>) <npc.name>
path_taskqueued: [NPCDest] Pathfinding task for (<npc.id>) <npc.name> queued up

In the new language file {plugins/NPC_Destinations/Languages/en_us-destinations.yml} let's paste the lines below (the formatted messages with the JSON encoding).

debug_messages:
  path_processing: "[{\"text\":\"[\",\"color\":\"yellow\"},{\"text\":\"(<npc.id>) <npc.name>\",\"color\":\"green\"},{\"text\":\"] \",\"color\":\"yellow\"},{\"text\":\"Processing has started for a new location\",\"color\":\"GREEN\"}]"
  path_taskqueued: "[{\"text\":\"[\",\"color\":\"yellow\"},{\"text\":\"(<npc.id>) <npc.name>\",\"color\":\"green\"},{\"text\":\"] \",\"color\":\"yellow\"},{\"text\":\"A pathfinding task has been queued\",\"color\":\"GREEN\"}]"

Would now look like the following to users:

path_processing: [(<npc.id>) <npc.name>] Processing has started for a new location
path_taskqueued: [(<npc.id>) <npc.name>] A pathfinding task has been queued

06.17.19 - At this time, the plugin does not support language changes with the /nd reload command. That will change very soon :)

Clone this wiki locally