1
0
mirror of https://github.com/anope/anope.git synced 2026-06-29 05:46:37 +02:00

Made gettext work on Debian and updated some documentation

This commit is contained in:
Adam
2010-10-28 16:25:33 -04:00
parent 257fb256e9
commit b8df88a1bc
5 changed files with 43 additions and 30 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ if(WIN32)
# Add README.txt to list of files for CPack to ignore
add_to_cpack_ignored_files("README.txt$" TRUE)
endif(IN_SOURCE)
set(DOCS DEFCON FAQ INSTALL LANGUAGES MODULES NEWS ${CMAKE_CURRENT_BINARY_DIR}/README.txt WIN32.txt)
set(DOCS DEFCON FAQ INSTALL LANGUAGE MODULES NEWS ${CMAKE_CURRENT_BINARY_DIR}/README.txt WIN32.txt)
install(FILES ${DOCS}
DESTINATION docs
)
+36
View File
@@ -0,0 +1,36 @@
Anope Mutli Language Support
----------------------------
1) Building Anope with gettext support
2) Adding a new language
3) Using languages with modules
1) Building Anope with gettext support
To build Anope with gettext support gettext and its devlopmental libraries must be installed on the system.
Anope does not require locales to be installed or enabled on the system, but does require the locales-all
package on Debian and Debian based systems.
Building Anope on Windows with gettext support is explained in docs/WIN32.txt
2) Adding a new language
Anope uses gettext (http://www.gnu.org/software/gettext/) to translate messages for users. To add a new language
install gettext and run `msginit -l language -o anope.language.po -i anope.pot`. For example if I was translating to
Spanish I could run `msginit -l es_ES -o anope.es_ES.po -i anope.pot`. Open the newly generating .po file and start
translating. Once you are done simply rerun ./Config; make && make install and add the language to your services.conf.
Poedit (http://www.poedit.net/) is a popular po file editor, and we recommend using it or another editor designed to edit
po files (especially on Windows).
If you have finished a language file translation and you want others to use it, please send it to team@anope.org
(don't forget to mention clearly your (nick)name, your e-mail and the language name). You'll of course get full credit for it.
3) Using langages with modules
Module authors can easially add the ability to have their modules translated by adding _() around the strings they
need translated (messages to the user, etc). See a few of the modules in /modules/extras (cs_appendtopic, hs_request)
for examples of this. If you want to translate a module someone has made, first generate a .pot file if there is none.
Run `xgettext -s -d modulename -o modulename.pot --from-code=utf-8 modulename.cpp`. Then, run msginit on the .pot file
with `msginit -l language -o modulename.language.po -i modulename.pot`. Translate the new .po file, then place it in
the lang folder and rerun ./Config; make && make install.
-25
View File
@@ -1,25 +0,0 @@
Anope Mutli Language Support
----------------------------
1) Adding a new language
2) Using languages with modules
1) Adding a new language
Anope uses gettext (http://www.gnu.org/software/gettext/) to translate messages for users. To add a new language
install gettext and run `msginit -l language -o anope.language.po -i anope.pot`. For example if I was translating to
Spanish I could run `msginit -l es_ES -o anope.es_ES.po -i anope.pot`. Open the newly generating .po file in a good
editor, there many pot file editors available, and start translating. Once you are done simply rerun ./Config;
make && make install and add the language to your services.conf.
If you did a language file translation and you want others to use it, please send it to team@anope.org (don't forget
to mention clearly your (nick)name, your e-mail and the language name). You'll of course get full credit for it.
2) Using langages with modules
Module authors can easially add the ability to have their modules translated by adding _() around the strings they
need translated (messages to the user, etc). See a few of the modules in /modules/extras (cs_appendtopic, hs_request)
for examples of this. If you want to translate a module someone has made, first generate a .pot file if there is none.
Run `xgettext -s -d modulename -o modulename.pot --from-code=utf-8 modulename.cpp`. Then, run msginit on the .pot file
with `msginit -l language -o modulename.language.po -i modulename.pot`. Translate the new .po file, then place it in
the lang folder and rerun ./Config; make && make install.
+4 -3
View File
@@ -30,9 +30,9 @@ void InitLanguages()
}
if (!bindtextdomain("anope", (services_dir + "/languages/").c_str()))
{
Log() << "Error calling bindtextdomain, " << Anope::LastError();
}
else
Log(LOG_DEBUG) << "Successfully bound anope to " << services_dir << "/languages/";
#else
Log() << "Can not load languages, gettext is not installed";
#endif
@@ -60,9 +60,10 @@ const Anope::string GetString(Anope::string language, LanguageString string)
#if GETTEXT_FOUND
++_nl_msg_cat_cntr;
setenv("LANGUAGE", language.c_str(), 1);
setlocale(LC_ALL, "en_US");
setlocale(LC_ALL, language.c_str()); // This is only required by some systems, but must not be C or POSIX
const char *ret = dgettext("anope", language_strings[string].c_str());
unsetenv("LANGUAGE");
setlocale(LC_ALL, "");
return ret ? ret : "";
#endif
+2 -1
View File
@@ -305,9 +305,10 @@ void Module::SendMessage(BotInfo *from, User *to, const char *fmt, ...)
{
++_nl_msg_cat_cntr;
setenv("LANGUAGE", language.c_str(), 1);
setlocale(LC_ALL, "en_US");
setlocale(LC_ALL, language.c_str()); // This is only required by some systems, but must not be C or POSIX
message = dgettext(this->name.c_str(), fmt);
unsetenv("LANGUAGE");
setlocale(LC_ALL, "");
}
#endif