SF.net SVN: geany:[3153] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sat Oct 25 18:56:27 UTC 2008
Revision: 3153
http://geany.svn.sourceforge.net/geany/?rev=3153&view=rev
Author: eht16
Date: 2008-10-25 18:56:27 +0000 (Sat, 25 Oct 2008)
Log Message:
-----------
Add main_locale_init() to the plugin API.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/main.c
trunk/src/main.h
trunk/src/plugindata.h
trunk/src/plugins.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-10-25 18:56:12 UTC (rev 3152)
+++ trunk/ChangeLog 2008-10-25 18:56:27 UTC (rev 3153)
@@ -3,6 +3,8 @@
* src/main.c, src/plugins.c:
Fix deprecated usage of g_win32_get_package_installation_directory(),
pass NULL as package name.
+ * src/main.c, src/plugins.c, src/plugindata.h:
+ Add main_locale_init() to the plugin API.
2008-10-24 Frank Lanitz <frank(at)frank(dot)uvena(dot)de>
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2008-10-25 18:56:12 UTC (rev 3152)
+++ trunk/src/main.c 2008-10-25 18:56:27 UTC (rev 3153)
@@ -412,10 +412,30 @@
}
-static void locale_init(void)
+/**
+ * Initialises the gettext translation system.
+ * This is a convenience function to set up gettext for internationalisation support
+ * in external plugins. You should call this function early in @ref plugin_init().
+ * If the macro HAVE_LOCALE_H is defined, @a setlocale(LC_ALL, "") is called.
+ * The codeset for the mesaage translations is set to UTF-8.
+ *
+ * Note that this function only setup the gettext textdomain for you. You still have
+ * to adjust the build system of your plugin to get internationalisation support
+ * working properly.
+ *
+ * @param locale_dir The location where the translation files should be searched. This is
+ * usually the @a LOCALEDIR macro, defined by the build system.
+ * E.g. $prefix/share/locale.
+ * Only used on non-Windows systems. On Windows, the directory is determined
+ * by @c g_win32_get_package_installation_directory().
+ * @param package The package name, usually this is the @a GETTEXT_PACKAGE macro,
+ * defined by the build system.
+ *
+ * @since 0.16
+ **/
+void main_locale_init(const gchar *locale_dir, const gchar *package)
{
-#ifdef ENABLE_NLS
- gchar *locale_dir = NULL;
+ gchar *l_locale_dir = NULL;
#ifdef HAVE_LOCALE_H
setlocale(LC_ALL, "");
@@ -423,18 +443,17 @@
#ifdef G_OS_WIN32
gchar *install_dir = g_win32_get_package_installation_directory(NULL, NULL);
- /* e.g. C:\Program Files\Geany\share\locale */
- locale_dir = g_strconcat(install_dir, "\\share\\locale", NULL);
+ /* e.g. C:\Program Files\geany\lib\locale */
+ l_locale_dir = g_strconcat(install_dir, "\\share\\locale", NULL);
g_free(install_dir);
#else
- locale_dir = g_strdup(GEANY_LOCALEDIR);
+ l_locale_dir = g_strdup(locale_dir);
#endif
- bindtextdomain(GETTEXT_PACKAGE, locale_dir);
- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
- textdomain(GETTEXT_PACKAGE);
- g_free(locale_dir);
-#endif
+ bindtextdomain(package, l_locale_dir);
+ bind_textdomain_codeset(package, "UTF-8");
+ textdomain(package);
+ g_free(l_locale_dir);
}
@@ -763,7 +782,9 @@
memset(&ui_widgets, 0, sizeof(UIWidgets));
setup_paths();
- locale_init();
+#ifdef ENABLE_NLS
+ main_locale_init(GEANY_LOCALEDIR, GETTEXT_PACKAGE);
+#endif
parse_command_line_options(&argc, &argv);
signal(SIGTERM, signal_cb);
@@ -1032,6 +1053,7 @@
* Plugins may call this function if they changed any of these files (e.g. a configuration file
* editor plugin).
*
+ * @since 0.15
**/
void main_reload_configuration(void)
{
Modified: trunk/src/main.h
===================================================================
--- trunk/src/main.h 2008-10-25 18:56:12 UTC (rev 3152)
+++ trunk/src/main.h 2008-10-25 18:56:27 UTC (rev 3153)
@@ -61,4 +61,6 @@
void main_reload_configuration(void);
+void main_locale_init(const gchar *locale_dir, const gchar *gettext_package);
+
#endif
Modified: trunk/src/plugindata.h
===================================================================
--- trunk/src/plugindata.h 2008-10-25 18:56:12 UTC (rev 3152)
+++ trunk/src/plugindata.h 2008-10-25 18:56:27 UTC (rev 3153)
@@ -41,7 +41,7 @@
enum {
/** The Application Programming Interface (API) version, incremented
* whenever any plugin data types are modified or appended to. */
- GEANY_API_VERSION = 102,
+ GEANY_API_VERSION = 103,
/** The Application Binary Interface (ABI) version, incremented whenever
* existing fields in the plugin data types have to be changed or reordered. */
@@ -333,6 +333,8 @@
typedef struct MainFuncs
{
void (*reload_configuration) (void);
+ void (*locale_init) (const gchar *locale_dir, const gchar *package);
+
}
MainFuncs;
Modified: trunk/src/plugins.c
===================================================================
--- trunk/src/plugins.c 2008-10-25 18:56:12 UTC (rev 3152)
+++ trunk/src/plugins.c 2008-10-25 18:56:27 UTC (rev 3153)
@@ -263,7 +263,8 @@
};
static MainFuncs main_funcs = {
- &main_reload_configuration
+ &main_reload_configuration,
+ &main_locale_init
};
static GeanyFunctions geany_functions = {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list