diff options
author | geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2005-09-01 15:56:01 +0000 |
---|---|---|
committer | geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b <geniusdex geniusdex@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864> | 2005-09-01 15:56:01 +0000 |
commit | 79a81468e6c217d4428677442b22d6d13f96a6ad (patch) | |
tree | af29b1e92b4dc0d7a3b770272b8551dabd129861 /src | |
parent | 79ef8a938a183baefe15b06a4854717a944310d6 (diff) |
BUILD : 1.7.10 (866) BUGS : NOTES : Added a moduleGetLangString() function to allow modules to retrieve their language strings instead of only being able to send a NOTICE with them
git-svn-id: svn://svn.anope.org/anope/trunk@866 31f1291d-b8d6-0310-a050-a5561fc1590b
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@616 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r-- | src/modules.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/modules.c b/src/modules.c index ea99ec241..71cf97cba 100644 --- a/src/modules.c +++ b/src/modules.c @@ -2492,7 +2492,8 @@ void moduleNoticeLang(char *source, User * u, int number, ...) if ((mod_current_module_name) && (!mod_current_module || strcmp(mod_current_module_name, mod_current_module->name))) { mod_current_module = findModule(mod_current_module_name); } - /* Find the users lang, and use it if we cant */ + + /* Find the users lang, and use it if we can */ if (u->na && u->na->nc) { lang = u->na->nc->language; } @@ -2527,6 +2528,42 @@ void moduleNoticeLang(char *source, User * u, int number, ...) } /** + * Get the text of the given lanugage string in the corrent language, or + * in english. + * @param u The user to send the message to + * @param number The message number + **/ +char *moduleGetLangString(User * u, int number) +{ + va_list va; + char buffer[4096], outbuf[4096]; + char *fmt = NULL; + int lang = NSDefLanguage; + char *s, *t, *buf; + + if ((mod_current_module_name) && (!mod_current_module || strcmp(mod_current_module_name, mod_current_module->name))) + mod_current_module = findModule(mod_current_module_name); + + /* Find the users lang, and use it if we can */ + if (u->na && u->na->nc) + lang = u->na->nc->language; + + /* If the users lang isnt supported, drop back to English */ + if (mod_current_module->lang[lang].argc == 0) + lang = LANG_EN_US; + + /* If the requested lang string exists for the language */ + if (mod_current_module->lang[lang].argc > number) + return mod_current_module->lang[lang].argv[number]; + /* Return an empty string otherwise, because we might be used without + * the return value being checked. If we would return NULL, bad things + * would happen! + */ + else + return ""; +} + +/** * Delete a language from a module * @param langNumber the language Number to delete **/ |