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 | |
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
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | include/modules.h | 1 | ||||
-rw-r--r-- | src/modules.c | 39 | ||||
-rw-r--r-- | version.log | 6 |
4 files changed, 45 insertions, 2 deletions
@@ -1,6 +1,7 @@ Anope Version S V N -------------------- Provided by Anope Dev. <dev@anope.org> - 2005 +09/01 A Function to retrieve a module language string. [ #00] 08/21 A NickServ SASET to set options on other nicks (split from SET). [ #00] 08/10 A New Windows installation files. [ #00] 07/04 A Warning when running Anope as root (DON'T DO THAT! :)). [ #00] diff --git a/include/modules.h b/include/modules.h index c2abd3279..ad56cbf87 100644 --- a/include/modules.h +++ b/include/modules.h @@ -338,6 +338,7 @@ extern char *mod_current_evtbuffer; MDE void moduleInsertLanguage(int langNumber, int ac, char **av); MDE void moduleNoticeLang(char *source, User *u, int number, ...); +MDE char *moduleGetLangString(User * u, int number); MDE void moduleDeleteLanguage(int langNumber); /*************************************************************************/ 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 **/ diff --git a/version.log b/version.log index 6d106e05e..28ee9ac01 100644 --- a/version.log +++ b/version.log @@ -8,10 +8,14 @@ VERSION_MAJOR="1" VERSION_MINOR="7" VERSION_PATCH="10" -VERSION_BUILD="865" +VERSION_BUILD="866" # $Log$ # +# 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 +# # BUILD : 1.7.10 (865) # BUGS : # NOTES : Fixed the "limited to" line in the help for /os modlist |