[glib] ggettext: Include an example of setlocale() and friends in the i18n docs
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] ggettext: Include an example of setlocale() and friends in the i18n docs
- Date: Thu, 15 Jan 2015 14:53:59 +0000 (UTC)
commit 9114923db213a53cdaee7de8dd1ad818919048a2
Author: Philip Withnall <philip withnall collabora co uk>
Date: Thu Jan 15 14:20:33 2015 +0000
ggettext: Include an example of setlocale() and friends in the i18n docs
Include an example main() function, and include a link to the gettext
manual’s section on integrating gettext with build systems.
That should work as a complete reference for how to add i18n support to
an application.
https://bugzilla.gnome.org/show_bug.cgi?id=742972
glib/ggettext.c | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/glib/ggettext.c b/glib/ggettext.c
index 636fdbb..bf74ccb 100644
--- a/glib/ggettext.c
+++ b/glib/ggettext.c
@@ -482,15 +482,33 @@ g_dngettext (const gchar *domain,
* ]|
* For an application, note that you also have to call bindtextdomain(),
* bind_textdomain_codeset(), textdomain() and setlocale() early on in your
- * main() to make gettext() work.
+ * main() to make gettext() work. For example:
+ * |[<!-- language="C" -->
+ * #include <glib/gi18n.h>
+ * #include <locale.h>
+ *
+ * int
+ * main (int argc, char **argv)
+ * {
+ * setlocale (LC_ALL, "");
+ * bindtextdomain (GETTEXT_PACKAGE, DATADIR "/locale");
+ * bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ * textdomain (GETTEXT_PACKAGE);
+ *
+ * // Rest of your application.
+ * }
+ * ]|
+ * where `DATADIR` is as typically provided by automake.
*
* For a library, you only have to call bindtextdomain() and
* bind_textdomain_codeset() in your initialization function. If your library
* doesn't have an initialization function, you can call the functions before
* the first translated message.
*
- * The gettext manual covers details of how to set up message extraction
- * with xgettext.
+ * The
+ * [gettext manual](http://www.gnu.org/software/gettext/manual/gettext.html#Maintainers)
+ * covers details of how to integrate gettext into a project’s build system and
+ * workflow.
*/
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]