Skip to content

Style Guide

Leo edited this page Dec 14, 2023 · 4 revisions

The main purpose of the Translations Framework is to provide a simple way for handling locale files. At the sime time, it allows the separation of style and localization, which are two very different things.

The Framework does not enforce this separation, but as a server administrator I have thought about this a lot and want to introduce a style guide that helps to achieve that goal.

Existing Styles

There is a collection of styles that is guaranteed to exist. I really want to encourage you to use these styles and let the server owner decide about the actual look. Let me explain this in more detail with the following example:

update_available="<gray>[<blue>MyPlugin</blue>]</gray> <green>New update available at:</green> <click:...><hover:...><blue><ul>https://www.spigotmc.org/resources/translations-framework.113792/</ul></blue></hover></click>"

The translation string is fully valid. But it is a combination of style and translation and when you would ever like to fix the look and feel of your plugin, you were required to do it in every translation file separately.

Now lets look at the very same example but with the use of general styles.

prefix="<prefix>MyPlugin</prefix>"
update_available="<msg:prefix/><text>New update available at <url>https://www.spigotmc.org/resources/translations-framework.113792/</url></text>"

Now as you can see, we only declare actual text and not how its supposed to be styled. The style comes from the style files, which might look like so:

prefix="<gray>[<c_primary>{slot}</c_primary>]</gray> "
text="<gray>"
url="<click:...><blue><ul>{slot}</ul></blue></click>"

Which can be easily changed for ALL messages from all plugins in all locales - in one single line.

Prefixes

Now what happened to the prefix in our example?

prefix="<prefix>MyPlugin</prefix>"

Let me clarify things. The line is supposed to solve the issue of ever changing prefix styles. Meaning, the prefix formatting is declared in the global_styles.properties, the prefix name is defined in the locale properties files.

/plugins/lang/global_styles.properties

prefix="<gray>[<primary>{slot}</primary>]</gray> "

It contains a space in the end and falls back to primary color if none set. It frames each prefix with gray square brackets.

/plugins/MyPlugin/lang/en.properties

prefix="<prefix><primary>MyPlugin</primary></prefix>"

It uses the above declared style and only inserts the plugin name and leaves it to the styles how it will look. But it might be important for you to use your own plugins color, right? So we also insert another tag, that will now use the local primary color from /plugins/MyPlugin/lang/styles.properties. Make sure you define it :P

And the final result might be grafik