summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes1
-rw-r--r--include/modules.h1
-rw-r--r--src/modules.c39
-rw-r--r--version.log6
4 files changed, 45 insertions, 2 deletions
diff --git a/Changes b/Changes
index 84504b310..22999767e 100644
--- a/Changes
+++ b/Changes
@@ -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