0.2.0 • Published 3 years ago

discord-i18n v0.2.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Discord i18n is a powerful Node module that allows you to easy setup and use i18n at your Discord bot using the discord.js module/framework.

Features

  • Unlimited and custom locales
  • Easy setup
  • Use as you like
  • Open source (you can add new features)

Example usage

// Fake client, just for testing.
const di18n = require('discord-i18n');
const client = Object.create(null);
const path = require('path');

client.di18n = new di18n.Client();
client.di18n.configure({ // Configure the client before init.
    directory: path.join(__dirname, '/locales'), // The directory where the translation files will be located.
    locales: ['en-US', 'en-UK' 'pt-BR', 'pt-PT', 'es-ES'], // The accepted locales.
    options: {
        autostart: true // Auto start the client, without using the init() function.
    }
});

/*
en-US.json file example (min):
{ "test": { "message": "Hi, my name is {{name}}! Example variable: {{variable}}" }, "variables": { "variable": "this is a variable" } }
*/

const variable = client.di18n.getVariable('en-US', variables.variable); // Returns "this is a variable".
console.log(client.di18n.ft('en-US', 'test.message', { name: 'Dan', variable })); // Log in console "Hi, my name is Dan! Example variable: this is a variable" message.

Links

Contributing

Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the documentation.

License

This repository is under Apache 2.0 license.

0.2.0

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago