<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <HTML ><HEAD ><TITLE >Internationalization.</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.74b"><LINK REL="HOME" TITLE="Gnome Developers' Information" HREF="book1.html"><LINK REL="UP" TITLE="GNOME Developer's Tutorial." HREF="tutorial.html"><LINK REL="PREVIOUS" TITLE="Adding menus" HREF="tut-menus.html"><LINK REL="NEXT" TITLE="Parsing parameters." HREF="tut-parsing.html"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Gnome Developers' Information</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="tut-menus.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >GNOME Developer's Tutorial.</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="tut-parsing.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="TUT-I18N" >Internationalization.</A ></H1 ><P ><IMG SRC="gnome-hello-2-i18n.jpg"></P ><P > Internationalization (i18n for short) is very easy with GNOME. We use GNU gettext. You need to initialize it with a call to <TT CLASS="FUNCTION" >bindtextdomain</TT > and <TT CLASS="FUNCTION" >textdomain</TT > in your main function. After it a _() to all the strings that need translation. </P ><P > You will need add your file to po/POTFILES.in. Then you can do <TT CLASS="LITERAL" >make gnome-modulename.pot;make update-po</TT >, edit the .po file corresponding to your language and do <TT CLASS="LITERAL" >make install</TT >. Now try your program... Wow! It's speaking in Spanish/Finnish/Latin... </P ><DIV CLASS="WARNING" ><P ></P ><TABLE CLASS="WARNING" WIDTH="100%" BORDER="0" ><TR ><TD WIDTH="25" ALIGN="CENTER" VALIGN="TOP" ><IMG SRC="./stylesheet-images/warning.gif" HSPACE="5" ALT="Warning"></TD ><TD ALIGN="LEFT" VALIGN="TOP" ><P > _() is a macro for the function gettext. So it won't work when initializing arrays of strings or structs. You'll need use the N_() macro around the strings instead. If you want know more about it read the info documentation of GNU gettext. </P ></TD ></TR ></TABLE ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="tut-menus.html" ACCESSKEY="P" ><<< Previous</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="book1.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="tut-parsing.html" ACCESSKEY="N" >Next >>></A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Adding menus</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="tutorial.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Parsing parameters.</TD ></TR ></TABLE ></DIV ></BODY ></HTML >