Modules:QuickList:LanguageStrings

From Anope Wiki

Jump to: navigation, search

Contents

Language Strings

You can respond to users in their set language using Anope's module language system.

moduleInsertLanguage

Add language strings for a given language.

void moduleInsertLanguage(int langNumber, int ac, char **av)

You specify the language you're inserting via the langNumber. The following languages are currently supported:

  • LANG_EN_US - English (US)
  • LANG_FR - French
  • LANG_DE - German
  • LANG_IT - Italian
  • LANG_PT - Portugese
  • LANG_ES - Spanish
  • LANG_TR - Turkish
  • LANG_CAT - Catalan
  • LANG_GR - Greek
  • LANG_NL - Dutch
  • LANG_RU - Russian
  • LANG_HUN - Hungarian
  • LANG_PL - Polish

The strings itself are specified as an array of strings in av. You must specify the amount of strings you're adding in ac.

moduleNoticeLang

Notice a user with the correct string in their set language.

void moduleNoticeLang(char *source, User *u, int number, ...)

This will send a notice to user u with source as the source of the message. You can specify the string number to be sent in number. Any variables can be passed using printf-style format specifiers in the language string; the arguments should be appended after number.

moduleGetLangString

Retrieve a set language string in a user's language.

char *moduleGetLangString(User *u, int number)

This will retrieve the language string numbered number in the language of choice for user u. This can be used to do something else with the message than noticing the user; sending a channel message or mail for example.

Example

#include <module.h>

#define LANG_NUM_STRINGS 2
#define LANG_STRING_NOTICE 0
#define LANG_STRING_LOG 1

int AnopeInit(int argc, char **argv)
{
    User *u;
    char *str;
    char *langtable_en_us[] = {
        "This message is being noticed to you, %s!",
        "This message is being logged in the language set by %s."
    };
    
    moduleInsertLanguage(LANG_EN_US, LANG_NUM_STRINGS, langtable_en_us);
    if ((u = firstuser())) {
        moduleNoticeLang(s_OperServ, u, LANG_STRING_NOTICE, u->nick);
        if ((str = moduleGetLangString(u, LANG_STRING_LOG)))
            alog(str, u->nick);
    }
    return MOD_CONT;
}
Personal tools