Skip to content

BetterLang setup

Dieter Nuytemans edited this page Jun 14, 2021 · 2 revisions

BetterLang setup

First, make sure to add BetterYaml as a dependency to your project, see BetterYaml setup for more information.

We can use BetterLang to read multiple language files that are linked to a single template. It operates similar to OptionalBetterYaml with some minor differences. The language template file must be in the templates folder and all localised files must be in a folder called lang. For an example configuration, see the small setup below:

| - .git/
| - src/
|    | - <redacted>
| - resources
|    | - templates/
|         | - lang.yml
|    | - lang/
|         | - english.yml
|         | - dutch.yml
| - pom.xml

Similar to BetterYaml, the file in the templates folder (lang.yml in this case) contains all placeholders, comments and the layout of the config file. The files in the lang folder, are actual default settings for each language that you can indicate with a code. For clarity, we wrote the full language name as file names but language codes are considered better practice (eg. en-us.yml instead of english.yml). Note that the name of the template file will be used as config file on the server. In other words, the server will never have a file called english.yml or dutch.yml, it will always be lang.yml.

Some example file contents can be found below:

resources/templates/lang.yml
# Hello world plugin header!
	
# This message is sent on plugin startup!
hello_world: {hello_world}

The default-value files themselves, must only contain all default values (comments are ignored in these files). Try to always provide a value for all settings, in all default files. Want to automate this? Check out YAML localisation sync!

resources/lang/english.yml
hello_world: "Hello world!"
resources/templates/dutch.yml
hello_world: "Hallo wereld!"

Wiki navigation

Wiki home

JavaDocs


BetterYaml (config files)

BetterYaml (deprecated, but supported)

Please use OptionalBetterYaml instead.

Setup

How to use BetterYaml

OptionalBetterYaml

Setup

How to use


BetterLang (language files)

Setup

How to use


Validation

Auto-correct faulty configuration values! You can create your own, custom validators.

How to use validators

EXPERIMENTAL: Optional sections

Clone this wiki locally