npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dbtranslator

v1.0.0

Published

A simple translation package for Discord bots to handle multiple languages with server-specific language preferences.

Downloads

1

Readme

DBTranslator

npm license issues stars

DBTranslator is a versatile translation package for Discord bots that allows you to manage multiple languages and set server-specific language preferences. It provides flexibility in how you organize your language files and integrates seamlessly with your existing bot setup.

Features

  • 🌐 Multilingual Support: Easily handle multiple languages for your Discord bot.
  • 🛠️ Customizable File Organization: Organize your language files however you prefer.
  • 📁 Persistent Settings: Save server-specific language preferences in a serverData.json file.
  • 💻 No External Dependencies: Operates without requiring additional npm packages.

Installation

Install DBTranslator via npm:

npm install dbtranslator

Usage

Basic Setup

  1. Importing and Initializing

    Import DBTranslator and initialize it with a default language:

    const DBTranslator = require('dbtranslator');
    const translator = new DBTranslator('en'); // Default language is English
  2. Setting Up Translations

    You can organize your language files in any directory you prefer. For example:

    const path = require('path');
    const DBTranslator = require('dbtranslator');
    
    // Set the path to your language files
    const languagesPath = path.join(__dirname, 'path_to_languages');
    
    const translator = new DBTranslator('en', languagesPath);

    Your language files can be in any format you choose, as long as they can be imported correctly by your bot.

  3. Setting and Using Language Preferences

    Use the translator in your bot's message handler to set and use language preferences:

    client.on('messageCreate', message => {
      if (message.content.startsWith('!setlang')) {
        const args = message.content.split(' ');
        const language = args[1];
        const serverId = message.guild.id;
    
        // Set the server's language preference
        translator.setServerLanguage(serverId, language);
        message.channel.send(`Language for this server set to ${language}`);
      }
    
      // Example usage of translation
      const footerText = translator.translate('request_by', message.guild.id) + " " + message.author.username;
      message.channel.send({ content: `Translation Example: ${footerText}` });
    });

Configuration

  • Default Language: Set a default language when initializing the DBTranslator instance.

    const translator = new DBTranslator('en');
  • Language Files: Place your language files in any directory. When initializing DBTranslator, specify the path to your language files if they are not in the default location.

  • Server Preferences: DBTranslator will automatically create a serverData.json file in the package directory to store server-specific language preferences.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contact

Maintained by AmtiXDev. For any questions or suggestions, feel free to open an issue or reach out.

Discord Banner

Discord Banner