Skip to content
This repository has been archived by the owner on Sep 12, 2020. It is now read-only.

Translations

GrafDimenzio edited this page Jul 23, 2020 · 6 revisions

Translations

If you want to add a translation option to your plugin, Synapse can help you with this.

Your plugin class which inherits from Synapse.Plugin has a translation class.

You only need to create a dictionary with a key in which you specify the translation and the value, to be the default translation.

Then with this.Translation.CreateTranslations(dictionary), the default translation will be written in \Synapse\ServerConfigs\Server-{Port}\{PluginName}-translation.txt

With this.Translation.GetTranslation(Key) can you load the translation and if the {PluginName}-translation.txt has been changed, it will show the new translation

Example:

using Synapse;
using System.Collections.Generic;

namespace Example
{
    public class Example : Plugin
    {
        public override void OnEnable()
        {
            var translations = new Dictionary<string, string>()
            {
                {"commandfailed", "You have no permission to use this command!"},
                {"commandsucces", "Command was executed!"}
            };

            this.Translation.CreateTranslations(translations);

            string commandfailed = this.Translation.GetTranslation("commandfailed"); // If the translation was changed the String for commandfailed will also change.
            string commandsucces = this.Translation.GetTranslation("commandsucces");
        }

        public override string GetName => "YourPluginName";
    }
}

If you understand even the Translation System you know all the Features of Synapse! Now the last thing to do is do look at the ApiList to find useful Methods you can use in your Plugin, learn from the Example Plugin to learn how to write an entire Plugin, try to learn to work with: Mec a useful Tool for delays, Components to easily store informations for each Player or other gameobjects or you can learn to do a Harmony Patch!

Clone this wiki locally