Skip to main content

Creating Translations

This bot supports translations! Here you will learn how to create a new translation file.

Adding A Language#

If you have fluency in the language you would like to translate to, and would like to contribute it to the project, it will be happily merged.

Please note that language files translated by an online translator will likely not be merged.

Getting Started#

In order to make a new language, fork this project and make sure you've got:

  1. An up-to-date version of the repository
  2. An IDE that allows for linting with eslint and prettier, as well as highlighting (Recommended: VSCode)

Once you have these things, we're ready to begin adding the new language to the bot!

Step 1.#

In order to register a new language pack, you'll need to create a new file with the 2 letter language code (eg. en.js for English) inside of the translations/languages directory.

Step 2.#

Once you have done this, copy and paste the source language for the project which is en.js into your new language. From here, you'll need to change the following parts of the file to the two letter country code for your language.

const translateEN = {
module.exports = {
translateEN,
};

Step 3.#

After modifying the aforementioned parts of the file, you will now need to open up translations/translator.js and add the following, adjusting translateYourNewLanguage and ./yourNewLanguageCide.

const { translateYourNewLanguage } = require('./yourNewLanguageCode');

Once you have done this, you will need to add the language pack to the translations list here, adding your language to the following list like so.

const translations = {
en: translateEN,
fr: translateFR,
yourNewLanguageCode: translateYourNewLanguage,
default: translateEN,
};

Step 4.#

Adding the language to the automated setup handler. To do this, go to scripts/setup.js and navigate to this part of the file

{
type: 'select',
name: 'language',
message: 'Bot Language?',
choices: [
{ title: 'English (Source)', value: 'en' },
{ title: 'French (Translation)', value: 'fr' },
{ title: 'YourNewLanguage (Translation)', value: 'yourNewLanguageCode' },
],
initial: 0,
},

Add your new language in to the choices list, and set the value to be the same as the language code.

Run through the setup handler by doing npm run config and ensure that the new option works successfully.

Congratulations#

You should now successfully have your language pack recognised by the bot, now it's time to start modifying the language file itself.

IMPORTANT: When adding a new language file, you only need to change things that are inside of the backticks, comments, translation codes and variables DO NOT need to be translated.

The translation-template will have provided all values pre-filled in English with all variables used, it is important when translating to keep the formatting as similar as possible, making sure all variables are used when needed.

After You've Translated#

Once you have managed to translate everything accurately, open up a pull-request and it'll be reviewed. All of your translations will be reviewed and the translation pack will be ensured it has been setup properly.

If everything has gone smoothly, your translation pack will be merged into the project.

Thank you! :)